Merge pull request #4107 from overleaf/jpa-compile-time-client-e2e

[frontend] PdfController: track the e2e compile time seen by the client

GitOrigin-RevId: 1d7c8b815735fd3c0ad9a32284c37c621798fbd3
This commit is contained in:
Jakob Ackermann 2021-06-01 15:52:38 +02:00 committed by Copybot
parent 13b7cc8bcb
commit 0015002e53
2 changed files with 8 additions and 4 deletions

View file

@ -341,7 +341,7 @@ App.controller(
function noop() {}
function parseCompileResponse(response) {
function parseCompileResponse(response, compileTimeClientE2E) {
// keep last url
const lastPdfUrl = $scope.pdf.url
const { pdfDownloadDomain } = response
@ -413,7 +413,8 @@ App.controller(
if (getMeta('ol-trackPdfDownload')) {
const { firstRenderDone, updateConsumedBandwidth } = trackPdfDownload(
response
response,
compileTimeClientE2E
)
$scope.pdf.firstRenderDone = firstRenderDone
$scope.pdf.updateConsumedBandwidth = updateConsumedBandwidth
@ -817,12 +818,14 @@ App.controller(
options.rootDocOverride_id = getRootDocOverrideId()
const t0 = performance.now()
sendCompileRequest(options)
.then(function (response) {
const { data } = response
const compileTimeClientE2E = performance.now() - t0
$scope.pdf.view = 'pdf'
$scope.pdf.compiling = false
parseCompileResponse(data)
parseCompileResponse(data, compileTimeClientE2E)
})
.catch(function (response) {
const { status } = response

View file

@ -9,7 +9,7 @@ const pdfJsMetrics = {
const SAMPLING_RATE = 0.01
export function trackPdfDownload(response) {
export function trackPdfDownload(response, compileTimeClientE2E) {
const { serviceWorkerMetrics, stats, timings } = response
const t0 = performance.now()
@ -36,6 +36,7 @@ export function trackPdfDownload(response) {
submitCompileMetrics({
latencyFetch,
latencyRender,
compileTimeClientE2E,
stats,
timings,
})