mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Send compile metrics (#3576)
* Support analytics events with a custom sampling rate * Send compile metrics for beta users GitOrigin-RevId: 86379f58e0bb4983a56cb6f0dcd6da916de3b8ba
This commit is contained in:
parent
1c0b897835
commit
70fb5da37d
2 changed files with 28 additions and 3 deletions
|
@ -5,6 +5,7 @@ import PreviewPane from '../../../features/preview/components/preview-pane'
|
|||
import { react2angular } from 'react2angular'
|
||||
import { rootContext } from '../../../shared/context/root-context'
|
||||
import 'ace/ace'
|
||||
|
||||
const AUTO_COMPILE_MAX_WAIT = 5000
|
||||
// We add a 1 second debounce to sending user changes to server if they aren't
|
||||
// collaborating with anyone. This needs to be higher than that, and allow for
|
||||
|
@ -689,7 +690,31 @@ App.controller('PdfController', function(
|
|||
|
||||
// display the combined result
|
||||
if (response != null) {
|
||||
response.finally(annotateFiles)
|
||||
response.finally(() => {
|
||||
annotateFiles()
|
||||
sendCompileMetrics()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function sendCompileMetrics() {
|
||||
const hasCompiled =
|
||||
$scope.pdf.view !== 'errors' && $scope.pdf.view !== 'validation-problems'
|
||||
const sendMetricsForUser =
|
||||
window.user.betaProgram && !window.user.alphaProgram
|
||||
|
||||
if (hasCompiled && sendMetricsForUser) {
|
||||
const metadata = {
|
||||
errors: $scope.pdf.logEntries.errors.length,
|
||||
warnings: $scope.pdf.logEntries.warnings.length,
|
||||
typesetting: $scope.pdf.logEntries.typesetting.length,
|
||||
newLogsUI: window.showNewLogsUI
|
||||
}
|
||||
eventTracking.sendMBSampled(
|
||||
'compile-result',
|
||||
JSON.stringify(metadata),
|
||||
0.05
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ App.factory('eventTracking', function($http, localStorage) {
|
|||
})
|
||||
},
|
||||
|
||||
sendMBSampled(key, segmentation) {
|
||||
if (Math.random() < 0.01) {
|
||||
sendMBSampled(key, segmentation, rate = 0.01) {
|
||||
if (Math.random() < rate) {
|
||||
return this.sendMB(key, segmentation)
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue