Add telemetry for tagged pdfs (bug 1997134)

This commit is contained in:
Calixte Denizet 2025-10-29 16:06:01 +01:00
parent 603e3a8f3e
commit 50c48cf11b
4 changed files with 17 additions and 2 deletions

View File

@ -267,6 +267,10 @@ class Catalog {
return markInfo;
}
get hasStructTree() {
return this.#catDict.has("StructTreeRoot");
}
get structTreeRoot() {
let structTree = null;
try {

View File

@ -515,6 +515,7 @@ class WorkerMessageHandler {
return Promise.all([
pdfManager.ensureDoc("documentInfo"),
pdfManager.ensureCatalog("metadata"),
pdfManager.ensureCatalog("hasStructTree"),
]);
});

View File

@ -3077,6 +3077,7 @@ class WorkerTransport {
metadata: results[1] ? new Metadata(results[1]) : null,
contentDispositionFilename: this._fullReader?.filename ?? null,
contentLength: this._fullReader?.contentLength ?? null,
hasStructTree: results[2],
}));
this.#methodPromises.set(name, promise);
return promise;

View File

@ -1719,12 +1719,21 @@ const PDFViewerApplication = {
* @private
*/
async _initializeMetadata(pdfDocument) {
const { info, metadata, contentDispositionFilename, contentLength } =
await pdfDocument.getMetadata();
const {
info,
metadata,
contentDispositionFilename,
contentLength,
hasStructTree,
} = await pdfDocument.getMetadata();
if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the metadata resolved.
}
this.externalServices.reportTelemetry({
type: "taggedPDF",
data: hasStructTree,
});
this.documentInfo = info;
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;