Collect telemetry in the viewer on whether a PDF is tagged.
This commit is contained in:
parent
f5c821e9c3
commit
8a8b4f9697
32
web/app.js
32
web/app.js
@ -242,6 +242,7 @@ const PDFViewerApplication = {
|
|||||||
triggerDelayedFallback: null,
|
triggerDelayedFallback: null,
|
||||||
_saveInProgress: false,
|
_saveInProgress: false,
|
||||||
_wheelUnusedTicks: 0,
|
_wheelUnusedTicks: 0,
|
||||||
|
_idleCallbacks: new Set(),
|
||||||
|
|
||||||
// Called once when the document is loaded.
|
// Called once when the document is loaded.
|
||||||
async initialize(appConfig) {
|
async initialize(appConfig) {
|
||||||
@ -738,6 +739,10 @@ const PDFViewerApplication = {
|
|||||||
this.contentDispositionFilename = null;
|
this.contentDispositionFilename = null;
|
||||||
this.triggerDelayedFallback = null;
|
this.triggerDelayedFallback = null;
|
||||||
this._saveInProgress = false;
|
this._saveInProgress = false;
|
||||||
|
for (const callback of this._idleCallbacks) {
|
||||||
|
window.cancelIdleCallback(callback);
|
||||||
|
}
|
||||||
|
this._idleCallbacks.clear();
|
||||||
|
|
||||||
this.pdfSidebar.reset();
|
this.pdfSidebar.reset();
|
||||||
this.pdfOutlineViewer.reset();
|
this.pdfOutlineViewer.reset();
|
||||||
@ -1329,12 +1334,39 @@ const PDFViewerApplication = {
|
|||||||
pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
|
pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => {
|
||||||
this.pdfLayerViewer.render({ optionalContentConfig, pdfDocument });
|
this.pdfLayerViewer.render({ optionalContentConfig, pdfDocument });
|
||||||
});
|
});
|
||||||
|
if ("requestIdleCallback" in window) {
|
||||||
|
const callback = window.requestIdleCallback(
|
||||||
|
() => {
|
||||||
|
this._collectTelemetry(pdfDocument);
|
||||||
|
this._idleCallbacks.delete(callback);
|
||||||
|
},
|
||||||
|
{ timeout: 1000 }
|
||||||
|
);
|
||||||
|
this._idleCallbacks.add(callback);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this._initializePageLabels(pdfDocument);
|
this._initializePageLabels(pdfDocument);
|
||||||
this._initializeMetadata(pdfDocument);
|
this._initializeMetadata(pdfDocument);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A place to fetch data for telemetry after one page is rendered and the
|
||||||
|
* viewer is idle.
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _collectTelemetry(pdfDocument) {
|
||||||
|
const markInfo = await this.pdfDocument.getMarkInfo();
|
||||||
|
if (pdfDocument !== this.pdfDocument) {
|
||||||
|
return; // Document was closed while waiting for mark info.
|
||||||
|
}
|
||||||
|
const tagged = markInfo?.Marked || false;
|
||||||
|
this.externalServices.reportTelemetry({
|
||||||
|
type: "tagged",
|
||||||
|
tagged,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user