Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Fix few telemetry issues with the new alt text flow (bug 1915434) #18661

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/display/editor/alt_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ class AltText {
this.#altTextButton.disabled = !enabled;
}

shown() {
this.#editor._reportTelemetry({
action: "pdfjs.image.alt_text.image_status_label_displayed",
data: { label: this.#label },
});
}

destroy() {
this.#altTextButton?.remove();
this.#altTextButton = null;
Expand All @@ -235,10 +242,6 @@ class AltText {
const label = this.#label;
// TODO: Update the l10n keys to avoid this.
const type = label === "review" ? "to-review" : label;
this.#editor._reportTelemetry({
action: "pdfjs.image.alt_text.image_status_label_displayed",
data: { label },
});
button.classList.toggle("done", !!this.#altText);
AltText._l10nPromise
.get(`pdfjs-editor-new-alt-text-${type}-button-label`)
Expand Down
2 changes: 1 addition & 1 deletion src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ class AnnotationEditor {
this._editToolbar = new EditorToolbar(this);
this.div.append(this._editToolbar.render());
if (this.#altText) {
this._editToolbar.addAltTextButton(await this.#altText.render());
await this._editToolbar.addAltText(this.#altText);
}

return this._editToolbar;
Expand Down
7 changes: 6 additions & 1 deletion src/display/editor/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class EditorToolbar {

#buttons = null;

#altText = null;

constructor(editor) {
this.#editor = editor;
}
Expand Down Expand Up @@ -99,6 +101,7 @@ class EditorToolbar {

show() {
this.#toolbar.classList.remove("hidden");
this.#altText?.shown();
}

#addDeleteButton() {
Expand Down Expand Up @@ -126,9 +129,11 @@ class EditorToolbar {
return divider;
}

addAltTextButton(button) {
async addAltText(altText) {
const button = await altText.render();
this.#addListenersToElement(button);
this.#buttons.prepend(button, this.#divider);
this.#altText = altText;
}

addColorPicker(colorPicker) {
Expand Down
5 changes: 5 additions & 0 deletions web/new_alt_text_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ class NewAltTextManager {
createAutomaticallyButton.addEventListener("click", async () => {
const checked =
createAutomaticallyButton.getAttribute("aria-pressed") !== "true";
this.#currentEditor._reportTelemetry({
action: "pdfjs.image.alt_text.ai_generation_check",
data: { status: checked },
});

if (this.#uiManager) {
this.#uiManager.setPreference("enableGuessAltText", checked);
await this.#uiManager.mlManager.toggleService("altText", checked);
Expand Down