Skip to content

Commit

Permalink
Collect telemetry in the viewer on whether a PDF is tagged.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Dahl committed Oct 29, 2020
1 parent 938ab8e commit 8ea121d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 8ea121d

Please sign in to comment.