fix(metrics): correct login.complete for passkey sign-ins - #20970
Draft
vpomerleau wants to merge 1 commit into
Draft
fix(metrics): correct login.complete for passkey sign-ins#20970vpomerleau wants to merge 1 commit into
vpomerleau wants to merge 1 commit into
Conversation
Because: - A keys-required passkey sign-in emitted two login.complete events under one flow_id: reason=passkey at the ceremony, then reason=email at the password step, double-counting every Sync passkey login - The !keysRequired deferral in sendPostSigninNotifications was correct, but the Glean call sat outside it and fired unconditionally - The generic flow-complete emitter hardcoded reason=email, with no way to know how the user had authenticated - The password step carried no metrics context of its own, so it fell outside the flow and login.complete lost its relying party This commit: - Adds an authMethod argument to setFlowCompleteSignal, carried on the metrics context alongside flowCompleteSignal and flowType and copied through gather() so the emitter can read it; kept off the payload schema so a client cannot supply one - Reads it in the flow-complete emitter, defaulting to email - Removes the unconditional login.complete from the passkey ceremony; passkey.authentication_verification_success already marks that step - Sets the flow-complete signal before emitting account.login on the keys-optional path, so the machinery recognises the flow as complete - Derives the method from the session token at /session/reauth, so the password step of a passkey sign-in reports passkey rather than email - Stashes the metrics context against the new passkey session token, so the password-creation and key-fetch steps stay on the same flow - Stops stash() overwriting a client-supplied service when the request carries none, so login.complete keeps its relying party - Asserts the emission count, not just the reason, in the route specs Closes #FXA-14302
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/fxa-auth-server/lib/metrics/events.js:146
- The PR description says this makes
metrics/events.jsthe single source of truth forlogin.completereason, but other routes still emitglean.login.completedirectly (e.g.lib/routes/passwordless.ts:319andlib/routes/linked-accounts.ts:598). That meanslogin.completecan still be emitted from multiple places, and those direct emitters can diverge from (or duplicate) the flow-complete reason logic here.
if (metricsContext.flowType === 'login') {
glean.login.complete(request, {
uid: data?.uid ?? '',
reason: metricsContext.authMethod || 'email',
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because
login.completeevents, so passkeyadoption and overall login volume have both been over-counted by roughly
1,700 flows a week since Phase 1 GA.
reason=email, so Sync passkey logins wereattributed to email sign-in and passkey conversion could not be measured from
the backend funnel.
flow_id and no relying party, leaving a hole in the flow between the ceremony
and the login it completes.
This pull request
authMethodargument tosetFlowCompleteSignalinpackages/fxa-auth-server/lib/metrics/context.js, carried on the metricscontext and copied through
gather()so the flow-complete emitter can read it.packages/fxa-auth-server/lib/metrics/events.js, fallingback to
email, making it the single source of thelogin.completereason.login.completefrom the passkey ceremony inpackages/fxa-auth-server/lib/routes/passkeys.ts, and sets the flow-completesignal before emitting
account.loginso the keys-optional path still recordsa completion.
packages/fxa-auth-server/lib/routes/utils/signin.js, so the password step ofa passkey sign-in reports
passkeyrather thanemail.metricsContextonPOST /password/create, forwarding it frompackages/fxa-auth-client/lib/client.tsandpackages/fxa-settings/src/pages/PostVerify/SetPassword/container.tsx.stash()overwriting a client-suppliedmetricsContext.servicewhen therequest carries none, so
login.completekeeps its relying party.Issue that this pull request solves
Closes: FXA-14302
Checklist
Put an
xin the boxes that applyHow to review (Optional)
lib/metrics/context.js,lib/metrics/events.js,lib/routes/passkeys.ts,lib/routes/utils/signin.jscontext.js→events.js→passkeys.ts→signin.js→ specspasskeys.tsis load-bearing —the signal must be set before
emitMetricsEventor the keys-optional pathemits nothing. The
stash()fallback applies to any route that stashes, notonly passkey ones.
Screenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
password.tsedit is a payload-schema addition andsignin.jsonly derives alabel.
reason='email'volume by the duplicate count and shiftsreason='passkey'later in time. Needs a heads-up to data/PM and a dashboardbreakpoint date.