Merge pull request #20405 from calixteman/add_telemetry_tagged_pdf

Add telemetry for tagged pdfs (bug 1997134)
This commit is contained in:
calixteman 2025-11-17 20:09:40 +01:00 committed by GitHub
commit b20bd9061e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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