Skip to content

feat(fxa-settings): add reason extra_key to OTP password metrics#20414

Open
vbudhram wants to merge 1 commit intomainfrom
fxa-13429
Open

feat(fxa-settings): add reason extra_key to OTP password metrics#20414
vbudhram wants to merge 1 commit intomainfrom
fxa-13429

Conversation

@vbudhram
Copy link
Copy Markdown
Contributor

Because

  • OTP/passwordless users going through the set-password flow were indistinguishable from third-party-auth users in Glean telemetry, making OTP adoption impossible to measure.
  • change_password_submit did not distinguish between changing an existing password and creating one for the first time.

This pull request

  • Adds a reason extra_key ('change' vs 'create') to change_password_submit and wires it through Security/index.tsx.
  • Adds a reason extra_key ('otp' vs 'third_party_auth') to all four third_party_auth_set_password events and passes it from PostVerify/SetPassword/container.tsx and index.tsx.
  • Updates fxa-shared/metrics/glean/fxa-ui-metrics.yaml and regenerates accountPref.ts, event.ts, and thirdPartyAuthSetPassword.ts bindings.

Issue that this pull request solves

Closes: https://mozilla-hub.atlassian.net/browse/FXA-13429

Checklist

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

Other information

How to test:

  1. Sign in to Sync with an OTP (passwordless) account.
  2. When prompted to set a password, complete the flow.
  3. In the browser devtools network tab, verify the third_party_auth_set_password Glean events include reason: "otp".

Copilot AI review requested due to automatic review settings April 21, 2026 00:51
@vbudhram vbudhram requested a review from a team as a code owner April 21, 2026 00:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines FxA Settings Glean telemetry so set-password and change/create-password flows can be segmented by a new reason extra key, enabling accurate measurement of OTP/passwordless adoption and distinguishing password creation vs change in account settings.

Changes:

  • Add reason extra_keys to third_party_auth_set_password.* events (otp vs third_party_auth) and emit them from the post-verify set-password flow.
  • Add reason extra_key to account_pref.change_password_submit (create vs change) and emit it from Settings → Security.
  • Update the Glean YAML schema and regenerate TypeScript metric bindings; wire the new extra keys through the fxa-settings Glean event bridge.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/fxa-shared/metrics/glean/web/thirdPartyAuthSetPassword.ts Regenerated event metric bindings to accept reason extra key for view/engage/submit/success.
packages/fxa-shared/metrics/glean/web/event.ts Regenerated file with an import reordering.
packages/fxa-shared/metrics/glean/web/accountPref.ts Regenerated binding for changePasswordSubmit to accept reason extra key.
packages/fxa-shared/metrics/glean/fxa-ui-metrics.yaml Adds reason extra_keys for relevant events and updates metric descriptions/bugs list.
packages/fxa-settings/src/pages/PostVerify/SetPassword/index.tsx Emits third_party_auth_set_password view/engage/submit events with reason.
packages/fxa-settings/src/pages/PostVerify/SetPassword/container.tsx Emits third_party_auth_set_password success event with reason.
packages/fxa-settings/src/lib/glean/index.ts Bridges new reason extra keys into recorded Glean event metrics; adds missing third_party_auth_set_password cases.
packages/fxa-settings/src/components/Settings/Security/index.tsx Emits account_pref.change_password_submit with reason (create/change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- interaction
extra_keys:
reason:
description: Whether the user is creating a password for an OTP/passwordless account ('create') or changing an existing password ('change').
Comment on lines 535 to +538
case 'account_pref_change_password_submit':
accountPref.changePasswordSubmit.record();
accountPref.changePasswordSubmit.record({
reason: gleanPingMetrics?.event?.['reason'] || '',
});
Comment on lines +727 to +745
case 'third_party_auth_set_password_view':
thirdPartyAuthSetPassword.view.record({
reason: gleanPingMetrics?.event?.['reason'] || '',
});
break;
case 'third_party_auth_set_password_engage':
thirdPartyAuthSetPassword.engage.record({
reason: gleanPingMetrics?.event?.['reason'] || '',
});
break;
case 'third_party_auth_set_password_submit':
thirdPartyAuthSetPassword.submit.record({
reason: gleanPingMetrics?.event?.['reason'] || '',
});
break;
case 'third_party_auth_set_password_success':
thirdPartyAuthSetPassword.success.record();
thirdPartyAuthSetPassword.success.record({
reason: gleanPingMetrics?.event?.['reason'] || '',
});
type: event
description: |
Click on "Change" on account settings page to change password for account
Click on "Change" or "Create" on account settings page to change or create password for account
/**
* Click on "Change" on account settings page to change password for account
* Click on "Change" or "Create" on account settings page to change or create
* password for account
Comment on lines +48 to +49
* User successfully set password after authenticating with third party auth or
* OTP
Copy link
Copy Markdown
Contributor

@StaberindeZA StaberindeZA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Wasn't able to test it, but code looks good.

Because:
- OTP/passwordless users going through the set-password flow were
  indistinguishable from third-party-auth users in Glean telemetry,
  making OTP adoption impossible to measure.
- change_password_submit did not distinguish between changing an
  existing password and creating one for the first time.
- The third_party_auth_set_password view and engage events were
  declared in the schema but never fired from code.

This commit:
- Adds reason extra_key to all four third_party_auth_set_password
  events ('otp' vs 'third_party_auth'), wires view/engage/submit
  in SetPassword/index.tsx, and success in container.tsx. Engage
  fires on the first keystroke (not focus) to match the pattern
  used by SigninPasswordlessCode.
- Adds reason extra_key to change_password_submit ('change' vs
  'create') and emits it from Settings/Security CTA.
- Regenerates the Glean bindings for accountPref.ts,
  thirdPartyAuthSetPassword.ts, and event.ts.
- Bridges the new reason extras in fxa-settings/src/lib/glean/index.ts
  and adds unit-test coverage for both reason values on all five
  affected events in glean/index.test.ts.
- Extends signinPasswordless.spec.ts to assert reason='otp' on all
  four set-password events during the Sync OTP flow (attaches a
  fresh GleanEventsHelper to the Sync browser page).
- Extends settings/changePassword.spec.ts to assert reason='change'
  on account_pref_change_password_submit.

Fixes FXA-13429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants