Use the new "reporttelemetry" event in more viewer components

By utilizing the recently added "reporttelemetry" event, we can avoid having to manually pass in `externalServices` to a number of viewer components.
This commit is contained in:
Jonas Jenwald 2023-09-20 14:08:28 +02:00
parent f2d75d9221
commit fe60db27b1
3 changed files with 16 additions and 18 deletions

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` },
},
});
}
});