Skip to content

Commit 50c48cf

Browse files
committed
Add telemetry for tagged pdfs (bug 1997134)
1 parent 603e3a8 commit 50c48cf

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/core/catalog.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ class Catalog {
267267
return markInfo;
268268
}
269269

270+
get hasStructTree() {
271+
return this.#catDict.has("StructTreeRoot");
272+
}
273+
270274
get structTreeRoot() {
271275
let structTree = null;
272276
try {

src/core/worker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ class WorkerMessageHandler {
515515
return Promise.all([
516516
pdfManager.ensureDoc("documentInfo"),
517517
pdfManager.ensureCatalog("metadata"),
518+
pdfManager.ensureCatalog("hasStructTree"),
518519
]);
519520
});
520521

src/display/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,6 +3077,7 @@ class WorkerTransport {
30773077
metadata: results[1] ? new Metadata(results[1]) : null,
30783078
contentDispositionFilename: this._fullReader?.filename ?? null,
30793079
contentLength: this._fullReader?.contentLength ?? null,
3080+
hasStructTree: results[2],
30803081
}));
30813082
this.#methodPromises.set(name, promise);
30823083
return promise;

web/app.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,12 +1719,21 @@ const PDFViewerApplication = {
17191719
* @private
17201720
*/
17211721
async _initializeMetadata(pdfDocument) {
1722-
const { info, metadata, contentDispositionFilename, contentLength } =
1723-
await pdfDocument.getMetadata();
1722+
const {
1723+
info,
1724+
metadata,
1725+
contentDispositionFilename,
1726+
contentLength,
1727+
hasStructTree,
1728+
} = await pdfDocument.getMetadata();
17241729

17251730
if (pdfDocument !== this.pdfDocument) {
17261731
return; // The document was closed while the metadata resolved.
17271732
}
1733+
this.externalServices.reportTelemetry({
1734+
type: "taggedPDF",
1735+
data: hasStructTree,
1736+
});
17281737
this.documentInfo = info;
17291738
this.metadata = metadata;
17301739
this._contentDispositionFilename ??= contentDispositionFilename;

0 commit comments

Comments
 (0)