Closed Bug 2084605 Opened 1 month ago Closed 1 month ago

intl.ui.browser_language.add_dialog (intlUiBrowserLanguage.addDialog) never recorded in telemetry by ensureLangPackInstalled(

Categories

(Firefox :: Settings UI, defect)

defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: robwu, Assigned: kzar)

References

Details

(Whiteboard: [addons-jira])

Attachments

(1 obsolete file)

about:preferences implementation calls ensureLangpackInstalled with three parameters, with the third being a callback that likely expects to be called upon completion or something: https://searchfox.org/firefox-main/rev/06fa2674be3db4f3b623bad938282310509cc54b/browser/components/preferences/config/languages.mjs#183-189 (originally added by this diff in bug 1972086):

  async ensureLangPackInstalled(langpack) {
    try {
      await LangPackMatcher.ensureLangPackInstalled(
        langpack,
        "about:preferences",
        /** @param {any} installId */
        installId => this.recordTelemetry("add", installId)
      );

... but that function never takes a third callback parameter: https://searchfox.org/firefox-main/rev/06fa2674be3db4f3b623bad938282310509cc54b/intl/locale/LangPackMatcher.sys.mjs#108-115
and it neither did so when the original code was introduced (together with the code I quoted before): https://searchfox.org/firefox-main/diff/c7d5bf49247904ebcc2b7785332c7df5e7a20376/intl/locale/LangPackMatcher.sys.mjs#114

P.S. I spotted the pre-existing flaw in the code while reviewing https://phabricator.services.mozilla.com/D333215 which fixed another pre-existing issue, where telemetryInfo: { source } was passed (source) while the receiver expects a plain source)

The redesigned Language section calls LangPackMatcher.ensureLangPackInstalled(langpack, "about:preferences", installId => this.recordTelemetry("add", installId)) in languages.mjs. But ensureLangPackInstalled(langPack, source) in LangPackMatcher.sys.mjs takes only two arguments, so the callback is silently dropped. The callback was added in bug 1972086 Part 2 (6781af604256) without the matching parameter. The legacy dialog used to do this itself: its installFromUrl(url, hash, callback) called callback(install.installId.toString()) right after AddonManager.getInstallForURL(). Bug 2076961 removed that telemetry, so nothing records addDialog any more. No test checks it either: the assertTelemetryRecorded calls in browser_browser_languages_subdialog.js only expect manage, search and reorder.

Suggested fix:

  • Add an optional third parameter (e.g. onInstall) to ensureLangPackInstalled and pass it through _ensureLangPackInstalledImpl → mockable.installLangPack → mockable._installAddon. Call it with install.installId once getInstallForURL resolves, the same way the old installFromUrl did.
  • Coordinate with D333215, which edits the same installLangPack → _installAddon call (telemetryInfo: { source } vs source).
  • Two side notes:
    • The early return for an already-installed langpack (LangPackMatcher.sys.mjs) still records nothing. Meanwhile setPreferred skips reorder for remote locales on the assumption that add gets recorded during install.
    • Multilingual.ensureLangPackInstalled ignores the boolean result, and _installAddon returns false on failure instead of throwing. So a failed install is treated as success and the installError UI never appears outside the stubbed test. This is worth fixing here or in a follow-up: return the awaited value.
  • The only other caller, AboutWelcomeParent.sys.mjs, passes one argument and is unaffected.

Tests: in browser_browser_languages_preferred_remote.js (run via browser-srd.toml), assert Glean.intlUiBrowserLanguage.addDialog.testGetValue(). Those tests stub mockable.installLangPack, so the stub has to call the passed callback, or the test should stub lower down. In test_langPackMatcher.js, check that the callback fires once with an installId.

Suggested severity: S4. Users see no difference; the only effect is a gap in the langpack-install telemetry from the Settings language picker.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Assignee: nobody → kzar
See Also: → 2076961

I have drafted a quick patch for this, since I was looking at the code for my recent changes for bug 2076009 anyway. I can't actually share the patch, since Phabricator's down this evening, but I will hopefully be able to share it tomorrow!

Note: I added a see also for bug 2076961 as it happened that we removed a very similar callback with an old preference today as well. Relatedly, I checked and I don't think intlUiBrowserLanguage.addDialog is due to expire until version 185.

Whiteboard: [addons-jira]

It turns out that the intlUiBrowserLanguage.addDialog event wasn't firing when a
language was added, since the callback provided wasn't ever being called.

Severity: -- → S3
Attachment #9666738 - Attachment is obsolete: true

After a discussion on the code review, I think we can close this out. Apparently the plan is to remove a lot of this old code imminently, after some tests and things are cleaned up.

As noted on the review, with the cleanup we should be careful to consider the callsites for recordTelemetry, including the broken installId => this.recordTelemetry("add", installId) call mentioned in this bug, and for the search/manage probes.

@mstriemer do you have a link for the cleanup bug? It would be nice to add it as a reference for folks.

Status: NEW → RESOLVED
Closed: 1 month ago
Flags: needinfo?(mstriemer)
Resolution: --- → WONTFIX
See Also: → 2086617

I filed bug 2086617 to make sure it isn't missed

Eemeli, looking at the dialog telemetry removal the "add" telemetry was recorded whether the locale was installed already installed or not installed, although it would only have an installId if it was just installed. Currently there's a bug in the new browser languages section where it's trying to record telemetry when a langpack is installed but the telemetry isn't recording

Should we record the "add" telemetry when a user tries to install a new langpack? Currently we fire "reorder" when the languages change to an already installed langpack. Looks like we could fire "add" in an else there

Flags: needinfo?(mstriemer) → needinfo?(earo)

I think that the new settings UI for this is different enough that we should probably rethink what telemetry we actually need and want for UI language changes, and then implement that directly, rather than hacking the old telemetry to support that.

I'll comment more on the follow-up bug.

Flags: needinfo?(earo)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: