From 05e4aed787db7f9a92dc803ea69cf78faa100e1e Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 8 Sep 2022 19:23:41 +0200 Subject: [PATCH] Add some telemetry to know how often the buttons in the secondary toolbar are used (bug 1789883) --- web/app.js | 7 ++++++- web/secondary_toolbar.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/web/app.js b/web/app.js index 63eb8a9ce..b6cd53991 100644 --- a/web/app.js +++ b/web/app.js @@ -613,7 +613,8 @@ const PDFViewerApplication = { this.secondaryToolbar = new SecondaryToolbar( appConfig.secondaryToolbar, - eventBus + eventBus, + this.externalServices ); if (this.supportsFullscreen) { @@ -2910,6 +2911,10 @@ function webViewerKeyDown(evt) { case 80: // p PDFViewerApplication.requestPresentationMode(); handled = true; + PDFViewerApplication.externalServices.reportTelemetry({ + type: "buttons", + data: { id: "presentationModeKeyboard" }, + }); break; case 71: // g // focuses input#pageNumber field diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js index 10383830c..6faefc0d8 100644 --- a/web/secondary_toolbar.js +++ b/web/secondary_toolbar.js @@ -51,7 +51,7 @@ class SecondaryToolbar { * @param {SecondaryToolbarOptions} options * @param {EventBus} eventBus */ - constructor(options, eventBus) { + constructor(options, eventBus, externalServices) { this.toolbar = options.toolbar; this.toggleButton = options.toggleButton; this.buttons = [ @@ -150,6 +150,7 @@ class SecondaryToolbar { }; this.eventBus = eventBus; + this.externalServices = externalServices; this.opened = false; // Bind the event listeners for click, cursor tool, and scroll/spread mode @@ -212,6 +213,10 @@ class SecondaryToolbar { if (close) { this.close(); } + this.externalServices.reportTelemetry({ + type: "buttons", + data: { id: element.id }, + }); }); } }