Merge pull request #17012 from Snuffleupagus/altText-telemetry-on-close

[Editor] Report telemetry when closing the altText dialog with `Esc` (PR 16987 follow-up)
This commit is contained in:
Jonas Jenwald 2023-09-22 22:45:13 +02:00 committed by GitHub
commit 85568bd6cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,8 @@ class AltTextManager {
#container;
#telemetryData = null;
constructor(
{
dialog,
@ -76,7 +78,7 @@ class AltTextManager {
this.#container = container;
dialog.addEventListener("close", this.#close.bind(this));
cancelButton.addEventListener("click", this.#cancel.bind(this));
cancelButton.addEventListener("click", this.#finish.bind(this));
saveButton.addEventListener("click", this.#save.bind(this));
optionDescription.addEventListener("change", this.#boundUpdateUIState);
optionDecorative.addEventListener("change", this.#boundUpdateUIState);
@ -240,22 +242,20 @@ class AltTextManager {
}
}
#cancel() {
#close() {
this.#eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "editing",
subtype: this.#currentEditor.editorType,
data: {
data: this.#telemetryData || {
action: "alt_text_cancel",
alt_text_keyboard: !this.#hasUsedPointer,
},
},
});
this.#finish();
}
this.#telemetryData = null;
#close() {
this.#removeOnClickListeners();
this.#uiManager?.addEditListeners();
this.#eventBus._off("resize", this.#boundSetPosition);
@ -274,21 +274,14 @@ class AltTextManager {
altText,
decorative,
};
this.#eventBus.dispatch("reporttelemetry", {
source: this,
details: {
type: "editing",
subtype: this.#currentEditor.editorType,
data: {
action: "alt_text_save",
alt_text_description: !!altText,
alt_text_edit:
!!this.#previousAltText && this.#previousAltText !== altText,
alt_text_decorative: decorative,
alt_text_keyboard: !this.#hasUsedPointer,
},
},
});
this.#telemetryData = {
action: "alt_text_save",
alt_text_description: !!altText,
alt_text_edit:
!!this.#previousAltText && this.#previousAltText !== altText,
alt_text_decorative: decorative,
alt_text_keyboard: !this.#hasUsedPointer,
};
this.#finish();
}