Merge pull request #15264 from calixteman/editing_telemetry

[Editor] Add some telemetry to know how often the editing features are used (bug 1782254)
This commit is contained in:
Jonas Jenwald 2022-08-03 11:28:08 +02:00 committed by GitHub
commit 4f6cd05a53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View File

@ -31,6 +31,7 @@ class AnnotationStorage {
// can have undesirable effects. // can have undesirable effects.
this.onSetModified = null; this.onSetModified = null;
this.onResetModified = null; this.onResetModified = null;
this.onAnnotationEditor = null;
} }
/** /**
@ -100,6 +101,13 @@ class AnnotationStorage {
if (modified) { if (modified) {
this.#setModified(); this.#setModified();
} }
if (
value instanceof AnnotationEditor &&
typeof this.onAnnotationEditor === "function"
) {
this.onAnnotationEditor(value.constructor._type);
}
} }
/** /**
@ -164,6 +172,15 @@ class AnnotationStorage {
return clone; 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. * PLEASE NOTE: Only intended for usage within the API itself.
* @ignore * @ignore

View File

@ -63,6 +63,8 @@ class FreeTextEditor extends AnnotationEditor {
], ],
]); ]);
static _type = "freetext";
constructor(params) { constructor(params) {
super({ ...params, name: "freeTextEditor" }); super({ ...params, name: "freeTextEditor" });
this.#color = this.#color =

View File

@ -67,6 +67,8 @@ class InkEditor extends AnnotationEditor {
static _l10nPromise; static _l10nPromise;
static _type = "ink";
constructor(params) { constructor(params) {
super({ ...params, name: "inkEditor" }); super({ ...params, name: "inkEditor" });
this.color = params.color || null; this.color = params.color || null;

View File

@ -1044,6 +1044,15 @@ const PDFViewerApplication = {
await this.pdfScriptingManager.dispatchDidSave(); await this.pdfScriptingManager.dispatchDidSave();
this._saveInProgress = false; this._saveInProgress = false;
} }
if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) {
this.externalServices.reportTelemetry({
type: "editing",
data: {
type: "save",
},
});
}
}, },
downloadOrSave() { downloadOrSave() {
@ -1734,6 +1743,12 @@ const PDFViewerApplication = {
delete this._annotationStorageModified; delete this._annotationStorageModified;
} }
}; };
annotationStorage.onAnnotationEditor = typeStr => {
this.externalServices.reportTelemetry({
type: "editing",
data: { type: typeStr },
});
};
}, },
setInitialView( setInitialView(
@ -1872,6 +1887,15 @@ const PDFViewerApplication = {
this.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
type: "print", type: "print",
}); });
if (this.pdfDocument?.annotationStorage.hasAnnotationEditors) {
this.externalServices.reportTelemetry({
type: "editing",
data: {
type: "print",
},
});
}
}, },
afterPrint() { afterPrint() {