diff --git a/web/app.js b/web/app.js index 043cad8176937f..4379edafc7db78 100644 --- a/web/app.js +++ b/web/app.js @@ -1329,12 +1329,33 @@ const PDFViewerApplication = { pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => { this.pdfLayerViewer.render({ optionalContentConfig, pdfDocument }); }); + if ("requestIdleCallback" in window) { + window.requestIdleCallback(() => { + this._collectTelemetry(); + }); + } }); this._initializePageLabels(pdfDocument); this._initializeMetadata(pdfDocument); }, + /** + * A place to fetch data for telemetry after one page is rendered and the + * viewer is idle. + */ + async _collectTelemetry() { + if (!this.pdfDocument) { + return; + } + const markInfo = await this.pdfDocument.getMarkInfo(); + const tagged = markInfo ? markInfo.Marked : false; + this.externalServices.reportTelemetry({ + type: "tagged", + tagged, + }); + }, + /** * @private */