Storybooks for commit 8f1ee27690a1046a2140734bf7e20c4c98031931

Date
10/14/2026, 2:17:56 AM UTC
Summary
fix(auth): decouple login.complete from flow events, fix Sync and reset
Description
## Because

- `login.complete` fired only when `emitFlowEvent` ran. If the Amplitude flow emitters are removed, it would stop.
- A Google or Apple sign-in for an existing link sent `login.complete` twice. A new link was labelled `email`.
- A Sync login with a Google or Apple account had no stash on the session token, so `/oauth/token` could not complete it.
- The metrics stash keeps the first write. The `/session/reauth` after SetPassword was dropped, so a passkey Sync sign-in never completed. A passwordless Sync sign-in completed twice.
- A password reset signs the user in, but no reset flow emitted `login.complete`. The signal in `send_otp` was never stashed.

## This pull request

- Sets `isFlowCompleteSignal` in `events.js` from `metricsContext.flowCompleteSignal`, and adds the missing `await` on `gatherMetricsContext`.
- Passes `provider` as `authMethod` on the Google and Apple signals in `linked-accounts.ts`.
- Signals `account.signed` for Sync on the new-link branch, as the existing-link branch does.
- Removes the direct `glean.login.complete` call from `linked-accounts.ts`. It double-counted.
- Stashes the metrics context on the new session token in `linked-accounts.ts`.
- Sets `account.signed`/`passkey` before the stash in `passkeys.ts` for a Sync sign-in with `keysRequired`.
- Makes a passwordless Sync sign-in in `passwordless.ts` signal `account.signed`/`otp` and stash on the session token. A non-Sync sign-in still calls `login.complete` directly.
- Moves the reset signal in `password.ts` from `send_otp` to `verify_otp`, with reason `reset`, stashed on the `passwordForgotToken`. It is `account.signed` for Sync and `account.reset` otherwise.
- Adds an optional `service` to `verify_otp`. The settings `ConfirmResetPassword` container sends `sync`, and the `fxa-auth-client` type has the new field.
- Adds `reset` to the `login.complete` reason description in `fxa-backend-metrics.yaml` and `server_events.ts`.
- Adds `lib/metrics/README.md` in the auth server. It explains how `login.complete` is emitted.
- Adds unit tests for each route and for the settings container.
- Leaves `flow.complete` unchanged.

## Issue that this pull request solves

Closes: