Bug 1829216 - Add some specific telemetry for pdf.js in GeckoView r=pdfjs-reviewers,marco

Differential Revision: https://phabricator.services.mozilla.com/D178669
This commit is contained in:
Calixte 2023-05-22 17:56:21 +00:00
parent 54485fbb62
commit 2b66fdd01c
4 changed files with 40 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParen
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
PdfJsTelemetry: "resource://pdf.js/PdfJsTelemetry.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});
@ -186,6 +187,8 @@ class FileSaver {
return;
}
lazy.PdfJsTelemetry.onGeckoview("save_as_pdf_tapped");
this.#callback = aCallback;
this.#browser.sendMessageToActor(
"PDFJS:Child:handleEvent",
@ -230,8 +233,10 @@ class FileSaver {
requestExternalApp: !!openInExternalApp,
});
}
lazy.PdfJsTelemetry.onGeckoview("download_succeeded");
debug`Save a PDF: ${bytes.length} bytes sent.`;
} catch (e) {
lazy.PdfJsTelemetry.onGeckoview("download_failed");
if (this.#callback) {
this.#callback?.onError(`Cannot save the pdf: ${e}.`);
} else {

View File

@ -14,7 +14,7 @@
*/
/* eslint max-len: ["error", 100] */
export var PdfJsTelemetry = {
export const PdfJsTelemetry = {
onViewerIsUsed() {
Glean.pdfjs.used.add(1);
},
@ -29,4 +29,7 @@ export var PdfJsTelemetry = {
onButtons(id) {
Glean.pdfjs.buttons[id].add(1);
},
onGeckoview(id) {
Glean.pdfjs.geckoview[id].add(1);
},
};

View File

@ -397,8 +397,9 @@ class ChromeActions {
}
reportTelemetry(data) {
var probeInfo = JSON.parse(data);
switch (probeInfo.type) {
const probeInfo = JSON.parse(data);
const { type } = probeInfo;
switch (type) {
case "pageInfo":
lazy.PdfJsTelemetry.onTimeToView(probeInfo.timestamp);
break;
@ -406,11 +407,16 @@ class ChromeActions {
lazy.PdfJsTelemetry.onEditing(probeInfo.data.type);
break;
case "buttons":
case "gv-buttons":
const id = probeInfo.data.id.replace(
/([A-Z])/g,
c => `_${c.toLowerCase()}`
);
lazy.PdfJsTelemetry.onButtons(id);
if (type === "buttons") {
lazy.PdfJsTelemetry.onButtons(id);
} else {
lazy.PdfJsTelemetry.onGeckoview(id);
}
break;
}
}

View File

@ -63,6 +63,28 @@ pdfjs:
- cdenizet@mozilla.com
- mcastelluccio@mozilla.com
expires: never
geckoview:
type: labeled_counter
labels:
- download_tapped
- open_in_app_tapped
- open_in_app_just_once
- open_in_app_always
- download_failed
- download_succeeded
- save_as_pdf_tapped
description: >
Counts the number of times some actions are executed in the PDF viewer.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1829216
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1829216#2
data_sensitivity:
- interaction
notification_emails:
- cdenizet@mozilla.com
- mcastelluccio@mozilla.com
expires: never
used:
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1566882