Merge pull request #16989 from Snuffleupagus/more-reporttelemetry-event

Use the new "reporttelemetry" event in more viewer components
This commit is contained in:
Jonas Jenwald 2023-09-20 22:06:14 +02:00 committed by GitHub
commit 34506f8874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 18 deletions

View File

@ -615,8 +615,7 @@ const PDFViewerApplication = {
appConfig.toolbar,
eventBus,
l10n,
await this._nimbusDataPromise,
externalServices
await this._nimbusDataPromise
);
} else {
this.toolbar = new Toolbar(appConfig.toolbar, eventBus, l10n);
@ -626,8 +625,7 @@ const PDFViewerApplication = {
if (appConfig.secondaryToolbar) {
this.secondaryToolbar = new SecondaryToolbar(
appConfig.secondaryToolbar,
eventBus,
externalServices
eventBus
);
}
@ -2141,7 +2139,6 @@ const PDFViewerApplication = {
eventBus._off("fileinputchange", webViewerFileInputChange);
eventBus._off("openfile", webViewerOpenFile);
}
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
eventBus._off("reporttelemetry", webViewerReportTelemetry);
}

View File

@ -56,7 +56,7 @@ class SecondaryToolbar {
* @param {SecondaryToolbarOptions} options
* @param {EventBus} eventBus
*/
constructor(options, eventBus, externalServices) {
constructor(options, eventBus) {
this.toolbar = options.toolbar;
this.toggleButton = options.toggleButton;
this.buttons = [
@ -155,7 +155,6 @@ class SecondaryToolbar {
};
this.eventBus = eventBus;
this.externalServices = externalServices;
this.opened = false;
// Bind the event listeners for click, cursor tool, and scroll/spread mode
@ -214,9 +213,12 @@ class SecondaryToolbar {
if (close) {
this.close();
}
this.externalServices.reportTelemetry({
type: "buttons",
data: { id: element.id },
this.eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "buttons",
data: { id: element.id },
},
});
});
}

View File

@ -25,18 +25,14 @@ class Toolbar {
#eventBus;
#externalServices;
/**
* @param {ToolbarOptions} options
* @param {EventBus} eventBus
* @param {IL10n} _l10n - Localization service.
* @param {Object} nimbusData - Nimbus configuration.
* @param {Object} externalServices - Interface for external services.
*/
constructor(options, eventBus, _l10n, nimbusData, externalServices) {
constructor(options, eventBus, _l10n, nimbusData) {
this.#eventBus = eventBus;
this.#externalServices = externalServices;
const buttons = [
{
element: options.download,
@ -88,9 +84,12 @@ class Toolbar {
element.addEventListener("click", evt => {
if (eventName !== null) {
this.#eventBus.dispatch(eventName, { source: this, ...eventDetails });
this.#externalServices.reportTelemetry({
type: "gv-buttons",
data: { id: `${element.id}_tapped` },
this.#eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "gv-buttons",
data: { id: `${element.id}_tapped` },
},
});
}
});