diff --git a/src/display/annotation_storage.js b/src/display/annotation_storage.js index 6b558f8f0..02e327076 100644 --- a/src/display/annotation_storage.js +++ b/src/display/annotation_storage.js @@ -31,6 +31,7 @@ class AnnotationStorage { // can have undesirable effects. this.onSetModified = null; this.onResetModified = null; + this.onAnnotationEditor = null; } /** @@ -100,6 +101,13 @@ class AnnotationStorage { if (modified) { this.#setModified(); } + + if ( + value instanceof AnnotationEditor && + typeof this.onAnnotationEditor === "function" + ) { + this.onAnnotationEditor(value.constructor._type); + } } /** @@ -164,6 +172,15 @@ class AnnotationStorage { return clone; } + get hasAnnotationEditors() { + for (const value of this._storage.values()) { + if (value instanceof AnnotationEditor) { + return true; + } + } + return false; + } + /** * PLEASE NOTE: Only intended for usage within the API itself. * @ignore diff --git a/src/display/editor/freetext.js b/src/display/editor/freetext.js index ea51b9fb9..9d0ec611d 100644 --- a/src/display/editor/freetext.js +++ b/src/display/editor/freetext.js @@ -63,6 +63,8 @@ class FreeTextEditor extends AnnotationEditor { ], ]); + static _type = "freetext"; + constructor(params) { super({ ...params, name: "freeTextEditor" }); this.#color = diff --git a/src/display/editor/ink.js b/src/display/editor/ink.js index dd304b094..f5f74a676 100644 --- a/src/display/editor/ink.js +++ b/src/display/editor/ink.js @@ -67,6 +67,8 @@ class InkEditor extends AnnotationEditor { static _l10nPromise; + static _type = "ink"; + constructor(params) { super({ ...params, name: "inkEditor" }); this.color = params.color || null; diff --git a/web/app.js b/web/app.js index 8b4e6265e..749b829fb 100644 --- a/web/app.js +++ b/web/app.js @@ -1044,6 +1044,15 @@ const PDFViewerApplication = { await this.pdfScriptingManager.dispatchDidSave(); this._saveInProgress = false; } + + if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) { + this.externalServices.reportTelemetry({ + type: "editing", + data: { + type: "save", + }, + }); + } }, downloadOrSave() { @@ -1734,6 +1743,12 @@ const PDFViewerApplication = { delete this._annotationStorageModified; } }; + annotationStorage.onAnnotationEditor = typeStr => { + this.externalServices.reportTelemetry({ + type: "editing", + data: { type: typeStr }, + }); + }; }, setInitialView( @@ -1872,6 +1887,15 @@ const PDFViewerApplication = { this.externalServices.reportTelemetry({ type: "print", }); + + if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) { + this.externalServices.reportTelemetry({ + type: "editing", + data: { + type: "print", + }, + }); + } }, afterPrint() {