Repository navigation
FE-3118 feat(billing-web): report the payment form phases, the submission and the linked operation - #19821
Conversation
…the issued operation
…the issued operation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
📦 Bundle Size
🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since f34408a7ff7c693433353f4e5df495f0db6e2b1b
Full docs: ADR-DEVEX-LINT-0015 🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight This candidate changes nothing the matrix measures, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## jaewon/fe-3118-billing-web-checkout-journey-and-choice-events #19821 +/- ##
==============================================================================================
Coverage 85.59% 85.60%
==============================================================================================
Files 2486 2486
Lines 139620 139634 +14
Branches 35943 35946 +3
==============================================================================================
+ Hits 119513 119527 +14
Misses 19605 19605
Partials 502 502
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
christian-byrne
left a comment
There was a problem hiding this comment.
The payment-form phase slice is sound at this head. It is exactly based on its current checkout-journey parent, remains thread-free and mergeable, and all checks have settled successfully or skipped. The added lifecycle events carry the existing journey correlation without exposing payment details or changing workspace selection behavior.
c7b8dd2
into
jaewon/fe-3118-billing-web-checkout-journey-and-choice-events
…failed sign-in carries (#19806) ## Summary Billing web reports the session journey: `billing.web_session.signin_required`, `.established` and `.failed` (E7 to E9), once per tab entry. A failed sign-in now carries its `SessionErrorCode`, as `error_code`, on both sign-in modes. This is the second of three PRs for FE-3120. It builds on the entry events PR. ## Why The shared web session (`unified_web_session`) exists to remove the second sign-in a customer meets on billing web after signing in to the cloud app. Nothing counts that screen, so the rollout cannot show whether it works, and a session that fails to establish is invisible. Today the failure code is also lost on the shared-session path: the sign-in port answers with a boolean. ## Root cause `SignInPort.establish` resolved a boolean. The session client knew the refusal's code and the shared session knew the workspace error, but both were dropped at the port, and a failure to create the shared session never produced a code at all. ## How - **Contract.** `webSessionEvent.ts` defines the three events as one `WebSessionBillingEvent` with one line in the `BillingTelemetryEvent` union. The payload allowlist gains `mode` and `origin` (`reason` was added in the entry PR). `failed` sends the existing `SessionErrorCode` as `error_code`, the same field the entry PR's `rejected` uses, so there is one error field on both web events. - **Carry the code.** `SignInPort.establish` now resolves `{ status: 'ok' } | { status: 'error', code }`. The session client port returns the code of the failed mint. The shared session returns the workspace error code, or, when creating the session fails, `INVALID_FIREBASE_TOKEN` for a 401 and `TOKEN_EXCHANGE_FAILED` for anything else. The controller only reads the status, so the sign-in page behaves as before. - **Report from the one place that knows.** `billingWebSignInPort()` in `billingWebAuth.ts` knows the decided mode, the live phase, whether the customer authenticated on this page, and each attempt's result. Opening the port reports `signin_required` from the live phase (`signed-out` is `no_session`, `error` is `refused`, a phase still resolving reports nothing). Each `establish` reports `established` (`origin` is `interactive` once the customer signed in on this page, else `restored`) or `failed` with `error_code`. - **Once per tab.** All three go through `trackOncePerTab`. `failed` is reported once per code, so a reload or a retry that fails the same way adds nothing and a different failure still does. - **User-visible behavior.** None. This is telemetry only. ## Review Focus - Stacked on #19798 (FE-3140): the base is its branch until it merges, then the base moves to main. Part 1 of this stack (#19804, the entry events) is already merged into that branch. Review only part 2's own change, 15 files against the base. Next in this stack: the return click (E27, #19807). - `outcome` is `pending` on all three, for the same reason as the entry events: client journey events never claim an operation outcome. A failed session is `stage: failed` with `error_code`, not `outcome: failure`. - A customer with a Cloud session reaches the sign-in page for a moment and leaves like a restore, because the first route guard runs before the mode is decided. That restore is what reports `established` with `origin: restored`. `signin_required` waits for a settled `signed-out` or `error` phase, so a restore that is still resolving is not counted as a second sign-in. - `signin_required` is once per tab, whichever reason comes first. A refusal that follows an interactive sign-in is not a new sign-in screen, so it is covered by `failed` and not by a second `signin_required`. - `refused` and `failed` can describe one incident: a restored session whose workspace is refused reports `signin_required` with `refused`, then `failed` with `ACCESS_DENIED`. They answer different questions (who was sent to sign-in, and why the session failed), so I kept both. - The mapping for a session that cannot be created is deliberately coarse. It mirrors the token exchange: a refused credential has its own code and every other failure is one bucket. It feeds telemetry only. The sign-in page still reads its failure copy from the port's `failureCode` ref, which this PR does not change. - `SignInPort.establish` changing from a boolean to a result touches `unifiedBillingSession.test.ts` expectations (three assertions). There are no other callers. - Known gap: the second sign-in KPI only means something as `unified_web_session` rolls out. With the flag off, every signed-out visit is a sign-in on the session client, so the two modes are compared through `mode` on `established`, not through `signin_required` alone. - Existing behavior this PR makes visible: in shared-session mode, after creating the shared session fails (for example a 503), the page's Try again calls `establish()` with no user, which answers `NOT_AUTHENTICATED` without any request. The telemetry therefore reports a second `failed` with `error_code: NOT_AUTHENTICATED` for that retry, once per code. The retry cannot succeed today; signing in again does recreate the session. Not changed here; tracked in [FE-3158](https://linear.app/comfyorg/issue/FE-3158). ## AS IS / TO BE AS IS:  TO BE:  The evidence is the sequence of billing web telemetry events for a Cloud session found on arrival, a signed-out visitor who signs in on billing web, a refused workspace, and a session the shared endpoint refuses to create (503 and 401), on both sign-in modes, before (no events, boolean result) and after. ## Where this sits in the plan Linear: [FE-3120](https://linear.app/comfyorg/issue/FE-3120), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](#19815), [PR 19816](#19816), [PR 19817](#19817), [PR 19818](#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | this PR | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T10 stroke-width:3px ```
…d failed (#19818) ## Summary Report the cancel flow on the cloud app as `billing.cancel.intent`, `billing.cancel.abandoned` and `billing.cancel.failed`, through one surface-free contract that billing web can reuse. Part 4 of 4 for FE-3115. ## Why The cancel flow stages reach PostHog and the desktop sink only. Datadog cannot show how many customers open the cancel flow, how many leave it, or where it breaks. The cancel request itself is already reported as `billing.operation.*` with `operation_type: cancel`. ## Root cause The legacy `trackSubscriptionCancellation` stages (`flow_opened`, `abandoned`, `failed`) have no typed counterpart, and the stage `abandoned` was not part of the billing vocabulary. ## How - **Contract.** `cancelEvent.ts` defines operation `cancel` with stages `intent` and `failed` (the shared stage types) and the new `abandoned` (outcome `pending`: the customer left, no operation outcome is claimed). It carries only `current_tier` and `cycle`, both plan facts that exist on any surface, and no surface-specific field. One union line and three names. No new allowlist field. - **Plan facts.** `toCurrentTier` moved from `useSubscriptionDialog` to `billingPlanTelemetry.ts` and gained `toBillingCycle`, with a table test. `createCancelFlowReporter` in `subscriptionCancellationTelemetry.ts` builds the events for both flows, so the ownership rule below lives in one place. - **Ownership.** The reporter emits `intent` where the legacy `flow_opened` fires. It emits `abandoned` where the legacy `abandoned` fires, unless the customer already confirmed. When the confirmed cancel becomes an operation (the workspace rail), its `billing.operation.*` events own the end of the attempt, so the reporter emits no `failed` either. `failed` is reported only for a flow that ends with no operation: the legacy-rail dialog when its cancel fails, and a provider failure whose native dialog cannot open (category `rendering`). `useWorkspaceBilling.cancelSubscription` is unchanged. - **Flows covered.** The provider (Churnkey) flow in `launchCancellationFlow` and the native `CancelSubscriptionDialogContent`, which also carries the attempt on after a provider failure (`flowAlreadyOpened`). - **Tests.** Table-driven through the real flows with the telemetry sink recording: each row's expected cancel events are literal, and a Datadog row shows the billing actions with `billing_surface: cloud_app`. ## Review Focus - Stacked on #19817 (FE-3115 part 3), #19816 (part 2) and #19815 (part 1), on top of #19798 (FE-3140). The base is the part 3 branch until it merges. Review only the commits after part 3's head `5e5c09685c`. FE-3117 later reuses this cancel contract for billing web. - The Notion catalog lists `source` and `failure_category` as E14 key fields. `source` is not in the event: the cloud app only ever sends `cancel_plan_menu`, billing web has its own entry, and neither value belongs to the one source list. Add it when billing web needs it. The legacy `current_tier`, `cycle` and `end_date` are replaced by the bounded `current_tier` and `cycle`; the end date and the error message are not sent. - `outcome` for `abandoned` is `pending`, so a dashboard that counts `outcome: success` and `outcome: failure` is not moved by customers who leave. - A provider failure that falls back to the native dialog reports no `failed`: the attempt continues in the dialog and ends there. Reporting both would give one attempt two endings. - A discount accepted in the provider flow ends with `intent` and no end event. The customer kept the plan, which is neither an abandonment nor a cancel, and the legacy event does not report it either. Say if you want a stage for it. - On the legacy billing rail the cancel completes in the Stripe portal, so a flow ends in `intent` and nothing else unless the request fails. There is no operation to wait for. - No user-visible change: the diff adds telemetry calls, a plan helper and a moved function. No dialog, copy or code path changes. - FE-3117 can emit the billing web side with `CancelBillingEvent` as it stands. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too (local Node 24 against engine 26). This diff does not touch it. ## AS IS / TO BE AS IS: placeholder, to be attached by editing this description. TO BE: placeholder, to be attached by editing this description. The evidence is the cancel events recorded while the cancel flow is opened, abandoned, confirmed and failed, before (none) and after (`billing.cancel.intent`, `.abandoned`, `.failed`), next to the unchanged `billing.operation.*` events for a confirmed cancel. ## Where this sits in the plan Linear: [FE-3115](https://linear.app/comfyorg/issue/FE-3115), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | this PR | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T5 stroke-width:3px ```
….topup.started (#19817) ## Summary Report the amount and the preset a customer chose on `billing.topup.started`: `amount_cents` as an integer and `amount_preset` as one of `10`, `25`, `50`, `100` or `custom`. Part 3 of 4 for FE-3115. ## Why Datadog receives top-up starts but not what was bought. PostHog, Mixpanel and GTM get the amount from the legacy purchase-click event only. Funnels by amount and by preset need the amount on the canonical start. ## Root cause `billing.topup.started` carried only the entry source. The dialogs know the amount and which preset button was picked, but neither field had a place in the billing event contract. ## How - **Contract.** `topupEvent.ts` gains `TOPUP_AMOUNT_PRESETS_USD` (10, 25, 50, 100), the `TopupAmountPreset` type (the four values as strings, or `custom`) and `getTopupAmountPreset`. The started stage gains optional `amount_cents` and `amount_preset`. Both are allowlist fields, bounded: an integer and a fixed enum, nothing free-form. - **Emitters.** The workspace dialog and the legacy dialog report both fields on the start event. The preset is the button the customer picked. Any typed amount is `custom`, including a typed amount that equals a preset. The workspace dialog computes the cents once and uses the same value for the API call. - **One list of presets.** Both dialogs now read the preset amounts from `TOPUP_AMOUNT_PRESETS_USD` instead of each keeping its own `[10, 25, 50, 100]`, so the telemetry enum and the buttons cannot drift. - **Datadog.** A test drives the real dialog through the real registry and the Datadog provider and checks the `billing.topup.started` action with the amount, the preset, the source and `billing_surface: cloud_app`. ## Review Focus - Stacked on #19816 (FE-3115 part 2, source fidelity) and #19815 (part 1), on top of #19798 (FE-3140). The base is the part 2 branch until it merges. Review only the commits after part 2's head `3cfb584720`. Next: the cancel flow (part 4). - `amount_preset` is a string enum (`'10'`, `'25'`, `'50'`, `'100'`, `'custom'`), not a number, so a Datadog facet has one type. The ticket says 'the existing preset enum'; there was no enum, only the dialogs' local arrays, so this adds the type and takes the values from the same list the buttons use. - A typed amount that equals a preset reports `custom`. The field says which control the customer used, not what the amount happens to be. `amount_cents` carries the amount either way. - Both new fields are optional on the stage, not required, so a surface that cannot supply them (billing web later) is not forced to invent them. The legacy rail is covered: the legacy dialog reports them too. - The recovered legacy top-up success (credits tile, usage table) has no start event in that tab and still carries no amount. - The legacy PostHog, Mixpanel and GTM purchase-click event is untouched. - No user-visible change: the diff adds telemetry fields and replaces two local constants with the shared list. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too (local Node 24 against engine 26). This diff does not touch it. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the `billing.topup.started` payload for the preselected amount, a clicked preset and a typed amount, before (no amount) and after (`amount_cents` and `amount_preset`). ## Where this sits in the plan Linear: [FE-3115](https://linear.app/comfyorg/issue/FE-3115), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | this PR | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T5 stroke-width:3px ```
…de and recovered operations (#19816) ## Summary Source fidelity for the cloud entries. The popover, the credits tile, the settings panel and the deep link pass a source into the top-up dialog. The source rides on the downgrade events, on the legacy top-up events and on the terminals of an operation recovered after a reload. Each source vocabulary maps into the one list, `PaymentIntentSource`. Part 2 of 4 for FE-3115. ## Why Five add-credits entries opened the top-up dialog with no source, so `billing.entry.add_credits_clicked` and `billing.topup.started` could not say where the customer came from. The downgrade events carried no source at all. After a reload the poller and the SDK lifecycle report a terminal for an operation they did not start, and the checkout journey keeps only a collapsed `entry_source`, so those terminals lost the source. ## Root cause `showTopUpCreditsDialog()` was called without options from the popover, the tile, the settings panel and the deep link. `useDowngradeToPersonal` had no source parameter. The checkout journey record stored `entry_source` (`pricing`, `settings_billing` or `agent_paywall`) and nothing finer, and no emitter read it back for a recovered operation. ## How - **Mapping.** `src/platform/telemetry/utils/paymentIntentSource.ts` holds two tables. The click-time source maps to the list: `credits_panel` and `settings_billing_panel` to `settings_billing_panel`, `avatar_menu` to `avatar_menu_plans`, `deep_link` and `agent_paywall` to themselves. The journey `entry_source` maps to the list where it names a control: `deep_link`, `settings_billing` (to `settings_billing_panel`) and `agent_paywall`. `pricing`, `recovery`, `other` and `unknown` name no source. `payment_intent_source` is the list itself. An `it.for` table covers all three. - **Entries.** The two popovers pass `avatar_menu_plans`, the credits tile and the settings panel pass `settings_billing_panel`, the deep link passes `deep_link`. The legacy `trackAddApiCreditButtonClicked` calls are untouched. `dialogService` now forwards the options to both rails. The legacy top-up dialog declares `source` and reports it on `billing.topup.started` and `failed`. - **Downgrade.** `DowngradeToPersonalBillingEvent` gains `payment_intent_source`. The subscription checkout passes its source to `showDowngradeToPersonalDialog`, which hands it to `useDowngradeToPersonal`. All nine events of an attempt carry it (the downgrade, the nested subscription checkout and the nested operation), and so does the metadata the poller adopts for a payment that settles later. - **Recovered terminals.** The checkout journey record keeps `payment_intent_source` next to `entry_source` (stored only; the emitted journey events and `entry_source` do not change). `getCheckoutJourneyPaymentIntentSource(opId)` returns it for the journey bound to that operation, and falls back to the mapped `entry_source` for a record written before this change. The poller reads it when it adopts an operation with no metadata, and the SDK store attaches it to the lifecycle events of an operation bound to a journey. ## Review Focus - Stacked on #19815 (FE-3115 part 1, entry events), which sits on #19798 (FE-3140). The base is the part 1 branch until it merges. Review only the commits after part 1's head `91a0b8118f`. Next: top-up amount (part 3), cancel flow (part 4). - No new source value. `recovery` is not produced: no entry creates a recovery journey, a recovered operation is already marked `resumed: true`, and it now carries the source of the journey it is bound to. The journey `entry_source` is unchanged, so `deep_link` and `recovery` stay unproduced there. An existing test pins that `deep_link` leaves the rail default, and the decision says existing payloads do not change. - The avatar menu's add-credits control maps to `avatar_menu_plans`, so one value covers the whole avatar menu. `credits_panel` and `settings_billing_panel` collapse into `settings_billing_panel`. Say if either should keep its own value; that needs a new list entry. - No user-visible change is intended, but one code path moves. A customer who cannot top up but can subscribe lands on the pricing dialog. Its `reason` was `top_up_blocked` and is now the entry's source. Only `out_of_credits` changes the dialog copy and none of these entries uses it. The legacy `modal_opened` event's `reason` and the `source` on the hosted billing link change the same way for those customers. - The out-of-credits banner is not changed. Its natural source is `out_of_credits`, and passing that would switch on the out-of-credits copy in the pricing fallback, a visible change. It still reports `add_credits_clicked` with no source. - A resumed journey keeps the source of the entry that created it. The journey intent key does not include the source, so two entries into the same journey report the first one on a recovered terminal. - Known gaps: a legacy-rail hosted top-up whose success is inferred on return (credits tile and usage table) still reports no source, because the pending top-up marker is a bare timestamp. The SDK lifecycle's own `started` event fires before the journey binds to the operation, so only its terminals carry the source. - The existing test 'withholds the surface from the legacy rail content' is replaced: the legacy dialog now takes the source, so withholding it is no longer the rule. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too (local Node 24 against engine 26). This diff does not touch it. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the `billing.entry.add_credits_clicked` and `billing.topup.started` payloads from each entry, the nine downgrade events with their source, and the terminal of an operation recovered after a reload, before (no source) and after (the source of the entry). ## Where this sits in the plan Linear: [FE-3115](https://linear.app/comfyorg/issue/FE-3115), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | this PR | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T5 stroke-width:3px ```
…usals before an operation included (#19810) ## Summary Billing web reports the business lifecycle of a checkout attempt on both checkouts (embedded and full page): `billing.subscription_checkout.intent` and `.started` at the pay press, then one `.succeeded` or `.failed`, including refusals before an operation exists. This is the second of three stacked branches for FE-3117 and delivers E10 and E11. It is stacked on the branch that delivers E12. ## Why The SDK stream only reports what happens after the server issued an operation. A pay that is refused first (validation, a 4xx or 5xx, no connection, an operation already pending, a stale quote) left no event anywhere on billing web, so its attempt count, success rate and failure mix were blank. The SSOT gives the host the business lifecycle for exactly these attempts. ## Root cause Billing web had no emitter on its pay path and no mapping from the SDK's coded command results to the bounded failure vocabulary the cloud app already uses. ## How - **Tracker.** `createAttemptTelemetry` (`apps/billing-web/src/telemetry/attemptTelemetry.ts`) wraps one command call. It reports the start immediately before the command, at most one terminal after it, and nothing for an attempt this tab did not start. A press while an attempt is open joins it. A result that continues the attempt leaves it open. Only the attempt that is still open can end, so a second resolve of a joined press cannot add a second terminal. - **Result mapping.** `outcomeOfCommandResult` reads an SDK `SubscriptionCommandResult` into succeeded, failed or continued. A settled operation uses its phase: succeeded, a decline (`provider_decline` with its `decline_reason`), `poll_timeout`, `reconciliation_needed`, `stale_operation`, each with the operation's `billing_op_id`. A refusal before an operation exists maps through one total table keyed by the SDK code, so a new SDK code fails to compile until it is mapped. Server messages and server codes are never forwarded. - **Checkout events.** `subscriptionCheckoutTelemetry.ts` builds the events. `checkoutAttemptOf(quote, entry)` reads tier, cycle and checkout type from the quote the customer paid against, and the source from the entry. Every event carries `billing_client: 'sdk'` and `checkout_ui`. - **Wiring.** `CheckoutView.vue` (embedded) and `useFullPageCheckout.ts` (full page) wrap their one `checkout.subscribe` call in `attempts.run(...)`. Nothing else in either flow changed. - **Contract.** `SubscriptionCheckoutBillingEvent` gains `checkout_ui` (`embedded` or `full_page`) and `decline_reason` on its failed variant. `BillingTelemetryErrorCode` gains `conflicting_payment_method`, `invalid_request`, `operation_already_pending` and `quote_stale`. `checkout_ui` is added to the allowlist. `SubscriptionCheckoutUi` is exported. - **README.** A short paragraph in the Telemetry section. ## Review Focus - Stacked on #19809 (FE-3117 part 1, the shared mapper and E12), which sits on #19798 (FE-3140). The base is the part 1 branch until it merges. Review only the commits after part 1's head `63120db378`. Next in this stack: the resubscribe lifecycle (E13, #19811). - Both `intent` and `started` fire at the pay press, as the catalog says for E10. The cloud app fires `intent` at plan select, so `intent` marks a different step on each surface. Billing web's earlier steps (entered, preview, method choice) belong to FE-3118. - `REACTIVATION_CONFIRMATION_REQUIRED` keeps the attempt open and emits no `failed`. The SSOT says it is a continuation state and must not produce a phantom failure. The catalog's E11 list names "reactivation not confirmed" among the refusals. I followed the SSOT, which is the canonical page, and the cloud checkout behaves the same way. The customer's next Pay continues the same attempt, with its duration measured from the first press. - A retry after a terminal starts a new attempt with its own intent and start. A Pay pressed while an attempt is still open joins it. This matches the SSOT rule that a retry starts a new lifecycle only after a real terminal. - No terminal is emitted for an attempt this tab did not start. A page that reloads or returns from a provider page recovers the operation and reports only the SDK stream (`billing.operation.*` with `resumed: true`). There is no specialized terminal on a recovered poll. - `billing_client: 'sdk'` is stamped on every billing web lifecycle event, not left absent. Billing web has no legacy path, so the emitter knows it. The brief says to leave it absent where the emitter does not know its path. - Category choices reuse the cloud's. A request with no HTTP status reads as `network`, as the cloud does for a `WorkspaceApiError` without a status, so `REQUEST_FAILED` and `NOT_AUTHENTICATED` without a status are `network`. Any HTTP status, 5xx included, is `api_rejected`. A missing payment method URL is `redirect` with `missing_payment_method_url`, as in the cloud's downgrade. A malformed response is `unknown` with `missing_checkout_response`, which is the nearest allowlisted code. - The new error codes and `checkout_ui` touch shared files (`stages.ts`, `payload.ts`, `subscriptionCheckoutEvent.ts`, `telemetry/index.ts`). Each addition is a separate line placed alphabetically, so a conflict with a sibling branch should be a trivial merge. - Known gaps. A re-quote that fails after the reactivation prompt leaves the started attempt without a terminal. A hosted redirect, a closed tab or a back press also leave a start without a terminal, which is the abandoned event of FE-3119. Billing web rebuilds its return links without `source`, so the entry source is not carried across a provider redirect, which FE-3120 covers. - E14 (billing web cancel intent, abandoned and failed) is not built. It follows FE-3115, which defines the cancel event contract first. The SDK stream already reports a cancel operation. - Size is about 340 non-test lines, a little over the 300 target. Most of it is the closed result-to-category table and the two event builders. - The first fallow run flagged `failureOfRefusal` (a switch, cyclomatic 15) and `pay` in `CheckoutView.vue` (an added optional chain) as introduced complexity. I replaced the switch with a total lookup table and passed the entry to `checkoutAttemptOf` so `pay` gained no branch. The audit now passes with `complexity_introduced` 0. - No user-visible change. Billing web sends new RUM actions and PostHog events and nothing else changes. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too under Node 24. This diff does not touch it. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the RUM actions billing web sends for one checkout attempt that succeeds, is declined, is refused before an operation exists (validation, a server error, no connection, already pending) and continues through the reactivation consent: before, none of them; after, intent, started and one terminal, with the bounded failure category and no server text. ## Where this sits in the plan Linear: [FE-3117](https://linear.app/comfyorg/issue/FE-3117), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](#19815), [PR 19816](#19816), [PR 19817](#19817), [PR 19818](#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | this PR | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T7 stroke-width:3px ```
…ed-pay choices (#19822) ## Summary Part 3 of 3, on part 2. Billing web reports the choices made on the way: `method_selected` (rail and method kind), `promo` (applied, rejected, removed or expired, with `prefilled`, never the code) and, on the full page, `pay_blocked`. ## Why The funnel could show where customers drop off but not what they chose first. Method, promo and a Pay held back by a guard were visible nowhere, and the embedded checkout dropped the payment method type on the way up from the card form. ## How - **Contract.** `method_selected` carries `rail` (`saved`, `new`, `on_file`) and an optional `method_kind` (`card`, `alipay`, `other`). `promo` carries `result` and `prefilled`. `pay_blocked` carries `reason` (`reactivation_unconfirmed`, `promo_unapplied`). The payload builder is split into context, preview, payment form and choice parts so it stays under the complexity gate. Its output is unchanged. - **Method type.** `CheckoutPaymentForm`, `CheckoutSubscribeActions` and `CheckoutSubscribeConfirm` in `@comfyorg/account-ui` forward the second argument that `StripePaymentForm` already emits, so `confirm` and `confirmPayment` carry `(token, paymentMethodType)`. The cloud app's handler ignores the extra argument. - **method_selected.** Both checkouts report it when a Pay goes ahead, just before `submitted`. A new method reports the type its token was minted for, a saved method reports the type its row lists, and the method on file reports no kind because this page never learns it. Types other than `card` and `alipay` are `other`. - **promo.** The full page reports the promo entry's own moves: `applying` to `applied`, `applying` to `rejected` for a code the server refused, `removing` to `idle`, and `applied` to `idle` when Pay found the code lapsed. The embedded checkout reports from the apply quote: a quote that carries the code back is `applied`, a quote that drops it or a server code of invalid or inapplicable is `rejected`. Only the newest quote call reports, as for the preview. `prefilled` is true when the code equals the entry link's `promo`, ignoring case. The code text is never reported. - **pay_blocked.** The full page reports `reactivation_unconfirmed` when Pay is pressed over an unticked keep-subscription consent, and `promo_unapplied` when Pay is pressed over a code the customer typed and did not apply. ## Review Focus - Stacked on #19819 (FE-3118 parts 1 and 2, E15 to E18), which sits on #19798 (FE-3140). The base is the part 1 branch (which already contains part 2, #19821) until it merges. Review only part 3's own change, 15 files against the base: E19 to E21 and the three account-ui components that now forward the payment method type. - Field name: E19 sends `rail` as the catalog says. It is the customer's payment rail, not the server's `billing_rail`, which the browser never mints. - `element_not_ready` from the catalog is not in the vocabulary. Pay is disabled until the element is ready, so no press reaches the host. The embedded checkout also disables Pay under the consent and unapplied-code guards, so it reports no `pay_blocked`. Both are one union member away if a path appears. - `method_selected` is reported when Pay goes ahead, not when the customer switches tabs or picks a saved row, because a new method's type is only known once its token exists. - A promo apply that judged nothing (a network failure, an unreadable answer) reports no `promo`. Only the server's verdicts count, so a transient failure is not read as a refused code. - The embedded checkout ignores the link's `promo`, so its `prefilled` is false unless the customer types the same code. - Privacy: tests assert that the code text appears in no payload, for every promo result on both checkouts. - Touches `packages/account-ui`: a two-argument emit on three components and one existing test updated to the new signature. No consumer is broken. - Known gaps: the top-up checkout on billing web reports no journey, and the cloud app does not report `method_selected` or `promo` yet. - No user-visible change. Telemetry only. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the `method_selected`, `promo` and `pay_blocked` actions RUM receives for an embedded and a full-page checkout, with the promo code text absent from every payload, before (nothing) and after. ## Where this sits in the plan Linear: [FE-3118](https://linear.app/comfyorg/issue/FE-3118), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](#19815), [PR 19816](#19816), [PR 19817](#19817), [PR 19818](#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | this PR | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T8 stroke-width:3px ```
#19807) ## Summary Billing web reports a click on each way back to the host: `billing.web_return.clicked` with `control` set to `back`, `close`, `success_close` or `host_link` (E27). This is the last of three PRs for FE-3120. It builds on the session events PR. ## Why The entry and session events say how customers arrive. Nothing says how they leave. The rollout needs to see whether customers return to the product from a surface, a checkout step or a finished checkout, and which of those controls they use. ## Root cause The return controls are spread over six components and each calls its own navigation helper. None of them reports anything. ## How - **Contract.** `webReturnEvent.ts` defines `WebReturnBillingEvent` and `WebReturnControl`, with one line in the `BillingTelemetryEvent` union and `control` in the payload allowlist. - **Reporter.** `reportReturnClicked(control)` sends the event through the billing web facade. It is not once per tab: each click is its own action. - **Wiring.** `host_link` is the surface header's "Return to" link and the sign-in page's return link for a refused workspace. `back` is the full-page checkout's and top-up's back arrow, and the embedded checkout's Back and confirm-step back. `close` is the embedded checkout frame's close. `success_close` is the Close button of a finished checkout, on the embedded success step and on the full-page ending. The embedded `leaveForHost` takes the control; the full-page views get a `goBack` handler, so the top-up's "View plans" keeps its own handler and reports nothing. - **Tests.** Each control has a click test next to the component that owns it, plus negative rows: Try again, View plans and Add credits report nothing, and the countdown that closes a finished checkout's tab reports nothing. - **User-visible behavior.** None. This is telemetry only. ## Review Focus - Stacked on #19798 (FE-3140): the base is its branch until it merges, then the base moves to main. Parts 1 and 2 of this stack (#19804, the entry events, and #19806, the session events) are already merged into that branch. Review only part 3's own change, 20 files against the base. The branch carries one merge of the base and one automated formatting commit. - The catalog lists the four `control` values without saying which control is which. The mapping above is my reading of the six components, so please check it. The one judgment call is that `success_close` is the Close button of any finished checkout (success, completed, already completed), and `close` is only the embedded frame's close. - Only clicks are reported. The five second countdown that closes a finished checkout's tab on its own is not a click, so most successful script-opened tabs leave without a `web_return` event. If the rollout wants those, it is a separate event, not `clicked`. - "View plans" and "Add credits" on the endings send the customer to a host page too, but they are not return controls in the catalog, so they report nothing. - On the embedded checkout a click that has no host destination (the link carried no return target) reports nothing, because nothing happens. The failure state's Back button only renders with a destination. - `outcome` is `pending` as on the other web events. Not once per tab: a customer who clicks Back twice, for example because the first click only closed a tab, reports twice. - Known gap: every one of these clicks closes or navigates the page at once. If PostHog is not loaded yet, or RUM has not flushed, the event can be lost with the page. Verifying flush on page exit is part of FE-3119. - `src/test/trackedBillingEvents.ts` is a five line helper that spies the billing web facade for one test. The entry and session tests in the earlier PRs inline the same four lines; I left them alone to keep those PRs unchanged. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the `billing.web_return.clicked` payload for each control, from the surface link, the embedded checkout's Back, Close and success Close, and the full-page back arrow and Close, plus the absence of an event for the countdown close, before (no events) and after. ## Where this sits in the plan Linear: [FE-3120](https://linear.app/comfyorg/issue/FE-3120), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](#19815), [PR 19816](#19816), [PR 19817](#19817), [PR 19818](#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](#19809), [PR 19810](#19810), [PR 19811](#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | this PR | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T10 stroke-width:3px ``` --------- Co-authored-by: GitHub Action <action@github.com>
…rom billing web (#19809) ## Summary Move the SDK-to-event mapper `toBillingTelemetryEvent` into `@comfyorg/account-core/billing` so both hosts use one mapper, keep the cloud app on it, and pass `onTelemetry` from billing web so the SDK operation stream (`billing.operation.*`) reaches RUM and PostHog. This is the first of three stacked branches for FE-3117; it delivers E12. ## Why Billing web builds the same operation lifecycle as the cloud app but passed no `onTelemetry`, so it reported no operation, success or failure at all. The mapper that turns the SDK's lifecycle event into the typed `billing.operation.*` event lived in a cloud-only file that billing web cannot import. ## Root cause `toBillingTelemetryEvent` lived in `src/platform/workspace/billing/sdk/billingSdkTelemetry.ts`, and `composeBillingWebClient` never set `onTelemetry` on `createBillingOperationLifecycle`. ## How - **Mapper.** `toBillingTelemetryEvent` moved with `git mv` to `packages/account-core/src/core/billing/telemetry/operationLifecycleEvent.ts` and its test next to it. The function body is unchanged; only the imports changed. It still stamps `billing_client: 'sdk'` and still maps a timeout to `poll_timeout` and a failure without a category to `provider_decline`. It is exported from the `telemetry/index.ts` barrel, so it is available from `@comfyorg/account-core/billing`. - **Cloud.** `billingSdkStore.ts` and `billingTelemetryEvent.test.ts` import it from the package. The cloud file and its test are deleted and nothing re-exports it. The cloud's forwarding rules in `billingSdkStore.reportTelemetry` are untouched, so cloud payloads are identical. - **Billing web.** `composeBillingWebClient` passes `onTelemetry` that sends `toBillingTelemetryEvent(event)` through `billingWebTelemetry.trackBillingEvent`. Both client constructors (`createBillingWebClient`, `createWebSessionBillingClient`) go through it, so it covers the session-token path and the web-session path. - **Test.** The red commit (`8ed3746e49`) drives a real lifecycle over a stubbed network and expects the RUM actions. It failed with no events sent. The green commit pins the presentation to `hosted` (the first draft guessed `embedded`) and tables a success, a decline with its bank reason, and an operation parked for reconciliation. - **README.** One short subsection under Telemetry. ## Review Focus - Stacked on #19798 (FE-3140): the base is its branch until it merges, then the base moves to main. This PR now carries two parts of FE-3117: its own (the shared mapper and E12) and part 2 (#19810, E10 and E11, the checkout attempt lifecycle), which was merged into this branch. Next in this stack: the resubscribe lifecycle (E13, #19811). It is a sibling of the FE-3120, FE-3115 and FE-3118 stacks, which also sit on FE-3140. - Billing web is the only emitter of `billing.operation.*` on its surface, because no billing web caller emits it. So there is no duplicate-start guard like the cloud's `callerStarted` window. The cloud needs that guard because its callers also announce a start; billing web has none. FE-3117's later branches emit only `billing.subscription_checkout.*` and `billing.resubscribe.*` from the caller, never `billing.operation.*`. - Everything the lifecycle reports is forwarded, top-ups included. The cloud drops a non-resumed top-up because its dialog reports the top-up itself. Billing web has no top-up emitter, so a top-up there is visible only on the operation stream. A `billing.topup.*` business lifecycle for billing web is not in E10 to E14 and is not built here. - A refusal before the server issues an operation (validation, 4xx, 5xx, network, already pending) has no operation, so it is still invisible after this branch. The next branch (E10, E11) covers it. - `billing_client: 'sdk'` and `billing_surface: 'billing_web'` come from the mapper and the facade. No call site sets either. - E14 (billing web cancel intent, abandoned and failed) is not built in this stack. It follows FE-3115, which defines the cancel event contract first. A cancel on billing web already reports its operation on this stream. - The mapper test moved with the code, so the cloud mapper coverage did not shrink. The cloud's `billingTelemetryEvent.test.ts` still builds its fixtures through the shared mapper. - No user-visible change. Billing web sends new RUM actions and PostHog events and nothing else changes. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too under Node 24. This diff does not touch it. `src/stores/executionStore.test.ts` timed out once in a loaded full run and passed alone. - Merged with the FE-3140 branch after FE-3120's return events landed there (`18d7292b56`): two of its tests, one in `CheckoutView.test.ts` and one in `FullPageCheckoutView.test.ts`, asserted that the only event sent was `billing.web_return.clicked`. Those flows now also emit this PR's checkout attempt events, so both assertions look at the `web_return` events only. No production code changed in that commit. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the RUM action and PostHog capture names and payloads billing web sends when the SDK lifecycle issues and settles an operation: before, none; after, `billing.operation.started` and the terminal with `billing_client: 'sdk'` and `billing_surface: 'billing_web'`. ## Where this sits in the plan Linear: [FE-3117](https://linear.app/comfyorg/issue/FE-3117), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](#19798), in review | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](#19815), [PR 19816](#19816), [PR 19817](#19817), [PR 19818](#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | this PR | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](#19819), [PR 19821](#19821), [PR 19822](#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](#19804), [PR 19806](#19806), [PR 19807](#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T7 stroke-width:3px ```
…to a shared package (Comfy-Org#19798) ## Summary Move the typed billing event contract out of the cloud app into `@comfyorg/account-core/billing`, keep the cloud app on it, and make the billing web facade take a typed `BillingTelemetryEvent` instead of an event name plus a raw payload. ## Why Billing web could not import `BillingTelemetryEvent`, the payload allowlist or the payload builders because `src/platform/telemetry/types.ts` imports cloud-only types. Its facade took a name and a payload the caller had to build correctly, so every billing web event (FE-3117, FE-3118, FE-3120, FE-3121) would have skipped the compile-time allowlist and the privacy contract check. ## Root cause The contract lived in a cloud file that imports `TierKey` and `BillingCycle` from cloud subscription modules, so no other host could reach it. ## How - **Commit 1, the move.** The event types, stage building blocks, allowlist `BILLING_PAYLOAD_FIELD_HANDLING`, payload builders and the billing event-name constants moved to `packages/account-core/src/core/billing/telemetry/`, one module per operation plus `stages.ts`, `billingTelemetryEvent.ts` (the one union), `payload.ts` (the one table) and `eventNames.ts`. The code is content-identical to what was in `types.ts` (`git diff --color-moved=dimmed-zebra` shows it as moved). `types.ts` re-exported the names so the cloud app compiled. - **Commit 2, the journey.** The `billing.checkout.*` journey contract moved the same way. It is not in the ticket text. It shares its failure vocabulary with the union and FE-3118 needs it on billing web. It is its own commit so it can be dropped. - **Commit 3, the cloud imports.** 24 cloud files (16 source, 8 tests) now import from `@comfyorg/account-core/billing` and the re-exports are deleted. No re-export is left behind. `TelemetryEvents` spreads the shared `BILLING_TELEMETRY_EVENTS`, so its keys and values are unchanged. - **Commit 4, the builder and the guards.** `getBillingWebTelemetryEventPayload` builds the allowlisted payload and stamps `billing_surface: 'billing_web'`, mirroring `getCloudAppBillingTelemetryEventPayload`. The table is checked against the exported `BillingPayloadFieldHandling` type, and a test proves a table that misses an event field does not compile. - **Commit 5, the facade.** `trackBillingEvent(event: BillingTelemetryEvent)` derives the name with `getBillingTelemetryEventName`, builds the payload with the billing web builder and sends it to RUM and PostHog as before. The whole call stays inside `attempt`, so it never throws, and telemetry-off still drops events. - **Commit 6, one line.** `TelemetryEventName` now includes `BillingTelemetryEventName`. Without it, every new member of the union failed the cloud typecheck at `PostHogTelemetryProvider` and `HostTelemetrySink` until someone added a `TelemetryEvents` constant (FE-3116 had to). I checked this with a throwaway `web_entry` event: it failed before and compiled after. - **Cloud-only types.** The contract imported `TierKey`, `BillingCycle`, `BillingSource`, `BillingIntent`, `BillingDeclineReason`, `BillingPresentation`, `SubscribeResponse` and `CreateTopupResponse`. `AgentRunMode` and `AppMode` are not used by it. `BillingDeclineReason`, `BillingPresentation` and the two response types are already in the shared packages. `TierKey` and `BillingCycle` had no shared source, so account-core now owns `BillingTierKey` and `BillingCycle` and the cloud `TierKey` and `BillingCycle` are aliases of them. Nothing was widened and every payload type is identical. - **Mirrored vocabulary.** `PaymentIntentSource` (15 values) and `HostedBillingIntent` (7 values) in account-core mirror `BillingSource` and `BillingIntent` in `@comfyorg/billing-contract`. account-core cannot depend on billing-contract: its publish-boundary test forbids unpublished workspace dependencies and billing-contract already dev-depends on account-core. `packages/billing-contract/src/eventVocabulary.test.ts` fails typecheck when the two lists drift. I confirmed it by adding a value. - **Renames forced by the move.** The shared barrel already exports `BillingFailure` and `BillingErrorCode` for the transport, so the telemetry ones are `BillingTelemetryFailure`, `BillingTelemetryFailureCategory` and `BillingTelemetryErrorCode`. `ResubscribeClickMetadata['source']` became `ResubscribeSource`. - **Adding an operation (for FE-3117, FE-3118, FE-3120, FE-3115).** Add `<operation>Event.ts` next to the others, add one line to the `BillingTelemetryEvent` union in `billingTelemetryEvent.ts`, and add any new payload field to `BILLING_PAYLOAD_FIELD_HANDLING` in `payload.ts` (it fails to compile until you do). Billing web calls `billingWebTelemetry.trackBillingEvent(event)`. The cloud sinks need no change. ## Review Focus - The diff is large because about 500 lines are moved code. New code is the per-module import headers, `vocabulary.ts`, the barrel `index.ts`, one 10-line builder, the facade and the tests. The moved blocks differ from the originals only in the renames above and the allowlist guard type. - Package placement. D4 names `@comfyorg/account-core/billing`, and the SDK-to-event mapper FE-3117 moves there needs the contract in the same package. The cost is the mirrored `PaymentIntentSource` and `HostedBillingIntent` lists, guarded by a type test in billing-contract. The alternative, putting the contract in billing-contract, would make billing-contract depend on account-core at runtime and put the mapper in the wrong package. - The checkout journey is in this PR although the ticket does not list it. Drop commit `be72e3ef80` and the matching part of commit 3 if you want it separate. FE-3118 would then have to move it. - `PaymentIntentSource = BillingSource` stays in `src/platform/telemetry/types.ts` for its 20 cloud call sites. The `toBillingTelemetryEvent` mapper stays in `billingSdkTelemetry.ts` for FE-3117 to move. - No user-visible change. Cloud payloads are byte-identical (the existing provider and contract suites pass with import-path edits only). Billing web has no caller of `trackBillingEvent` yet, so nothing new is sent from it. - The facade now drops any field outside the allowlist, so a billing web caller that passed an extra field before would lose it. There is no such caller today. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too (`INTERNAL ASSERTION FAILED: Expected a class definition`, local Node 24 against engine 26). I re-ran it against `main`'s versions of every file this PR touches and it fails the same way. This diff does not touch it. - Known gap: `subscriptionCheckoutTracker.ts` still keeps its own copy of the source list, as noted in FE-3116. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the RUM action and PostHog capture payload billing web sends for a typed event that also carries an email, a client secret and a return URL: before, whatever the caller passed plus `billing_surface`; after, only the allowlisted fields plus `billing_surface: 'billing_web'`. ## Where this sits in the plan Linear: [FE-3140](https://linear.app/comfyorg/issue/FE-3140), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](Comfy-Org#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](Comfy-Org#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](Comfy-Org#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](Comfy-Org#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](Comfy-Org#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](Comfy-Org#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](Comfy-Org#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](Comfy-Org#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](Comfy-Org#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | this PR | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](Comfy-Org#19815), [PR 19816](Comfy-Org#19816), [PR 19817](Comfy-Org#19817), [PR 19818](Comfy-Org#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](Comfy-Org#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | [PR 19809](Comfy-Org#19809), [PR 19810](Comfy-Org#19810), [PR 19811](Comfy-Org#19811), in review | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](Comfy-Org#19819), [PR 19821](Comfy-Org#19821), [PR 19822](Comfy-Org#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](Comfy-Org#19804), [PR 19806](Comfy-Org#19806), [PR 19807](Comfy-Org#19807), in review | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style C140 stroke-width:3px ``` --------- Co-authored-by: GitHub Action <action@github.com>
…w in the cloud journey phases (Comfy-Org#19819) ## Summary Part 1 of 3. Both billing web checkouts report the first two steps of the checkout journey in the cloud app's phases: `billing.checkout.entered`, then `preview_ready` or `preview_failed`. Every event carries `billing_surface: 'billing_web'` and a `ui_mode` of `embedded` or `full_page`. ## Why Billing web sends no checkout funnel today. The cloud app and billing web cannot be compared per surface, and the rollout cannot see how many customers open the billing web checkout or how many get a quote. This part adds the same entry and quote steps on both billing web checkouts, including the quotes and capability reads that refuse a customer. ## Root cause The `billing.checkout.<phase>` journey exists only in the cloud app's emitters. The shared contract has no `full_page` UI mode and no bounded way to say that a capability, a plan or a quote was refused. The billing web facade only accepts `BillingTelemetryEvent`. ## How - **Contract.** In `@comfyorg/account-core/billing`, `CheckoutUiMode` gains `full_page`. `entered` carries an optional `payment_intent_source`. `preview_failed` gains a bounded `denial_reason` (the capability denial) and two checkout codes for `error_code`, `quote_not_allowed` and `plan_unavailable`. The payload builder forwards them. The cloud app's persisted-journey allowlist accepts `full_page` (one line). - **Facade.** `billingWebTelemetry.trackCheckoutJourneyEvent` sends a journey phase to RUM and PostHog under its wire name, stamped `billing_surface: 'billing_web'`. `trackBillingEvent` now shares the same send path and behaves as before. The journey payload comes from the contract's explicit builder, so no other field can pass. - **Journey.** `useCheckoutJourney(uiMode)` owns the identity. The journey id is the entry link's `correlation_id` and a fresh id only for a link that carries none. `payment_intent_source` on `entered` is the link's `source`. `entry_source` maps the link's source into the cloud's coarse enum. `entry_flow` is the first quote's transition (`initial_subscription` or `paid_upgrade`) and reads `unknown` on `entered`. `assignment_status` is `unavailable`. - **Embedded checkout.** `entered` fires at setup. Each plain quote reports through `quotePlan`: an allowed quote is `preview_ready`, a refused quote is `preview_failed` with `quote_not_allowed`, a failed read is `preview_failed` with a category. Only the newest quote call reports, so an answer the quote composable abandoned for a newer one reports nothing. - **Full-page checkout.** Every page event passes through one observer. `quoted` is `preview_ready`. A refused capability, an unreadable capability read, an unreadable quote, a refused quote and an unavailable plan are `preview_failed`. `unavailable` and `capabilitiesFailed` events now carry the HTTP status when the server answered. - **Categories.** `REQUEST_FAILED` is `network` without an HTTP status and `api_rejected` with one. `NOT_AUTHENTICATED`, `ACCESS_DENIED`, `NOT_FOUND`, `CONFLICT`, `OPERATION_ALREADY_PENDING` and `NO_ACTIVE_SUBSCRIPTION` are `api_rejected`. `INVALID_REQUEST` is `validation`. Anything else is `unknown`. - **Once per revision.** `preview_ready` fires once per accepted quote revision (`quote_id:quote_version`), as in the cloud app. ## Review Focus - FE-3140 (Comfy-Org#19798) is merged into main (`a8337f39a4`); the base of this PR is main. This PR carries all three parts of FE-3118: its own (E15 and E16, the entry and the quote preview), part 2 (Comfy-Org#19821, E17 and E18) and part 3 (Comfy-Org#19822, E19 to E21 and the three account-ui components that forward the payment method type), which were merged into this branch. It is a sibling of the FE-3117 part 3 (Comfy-Org#19811) and FE-3115 (Comfy-Org#19815) PRs. - `entry_source` vocabulary: billing web maps the link's 15 sources into the cloud's coarse 7-value `entry_source` enum. `agent_paywall`, `deep_link` and `settings_billing_panel` (as `settings_billing`) keep a name, any other source is `other`, no source is `unknown`. `payment_intent_source` on `entered` carries the full source, and it is the field to split by. The cloud reports `pricing` for most pricing-dialog entries, so cloud and billing web `entry_source` do not match for the same journey until FE-3115 unifies the source vocabularies. Widening `CheckoutEntrySource` here instead would break the cloud's `satisfies Record` allowlist and collide with FE-3115. - `entry_flow` is `unknown` on `entered`, because the flow is the quote's and nothing is quoted yet. Join on `checkout_journey_id` to read the flow of an entry. - Journey identity is fixed when the view sets up. A reload sends `entered` again under the same journey id, so count distinct journey ids. A link change inside a reused checkout view keeps the first id. A journey id minted for a link without `correlation_id` uses `crypto.randomUUID()`, which the SDK already requires for its idempotency keys. - Likely overlap: the one-line `UI_MODES` change in `src/platform/workspace/utils/checkoutJourney.ts` sits near the entry-source work in FE-3115. A code-to-category mapper like `failureCategoryOf` may also appear in FE-3117 for subscribe failures. - `checkoutPage.ts` changes only two event types, which gain an optional `httpStatus`. The reducer is untouched. - The facade change is small but touches `trackBillingEvent`: its body now calls the shared `send`. Its existing tests pass unchanged. - Known gaps: the top-up checkout on billing web reports no journey. Quotes the promo field requests are left to part 3. - No user-visible change. Telemetry only. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too under Node 24. The timing-based tests in `router.planless.test.ts`, `billingWebAuth.*` and `operationLifecycle.test.ts` can time out on a loaded machine and pass alone. - Merged with the FE-3140 branch after FE-3117 landed there (`0de5cf4218`). One conflict, in `CheckoutView.vue` `pay()`: the journey hooks (`method_selected`, `submitted`) now run first and FE-3117's attempt tracker wraps the `checkout.subscribe` call unchanged. `CheckoutView.streams.test.ts` runs the embedded checkout over the real SDK client with only the network and the RUM sink mocked and pins the order of a successful Pay across the three families: `entered`, `preview_ready`, `method_selected`, `submitted`, then `subscription_checkout.intent` and `.started`, `billing.operation.started`, `operation_linked`, `billing.operation.succeeded` and `subscription_checkout.succeeded`, with the four events after the issue sharing one `billing_op_id`. - Review fixes after CodeRabbit (`192c751f28`, red tests first): a Pay refused with `OPERATION_ALREADY_PENDING` or `CONFLICT`, or whose command rejects, no longer lets a later recovered operation be reported as `operation_linked` (the journey's wait is cleared per press when its command settles, in both Pay handlers); `preview_failed` takes its `failure_category` from the attempt's mapper, so one refusal has one category in the journey and the attempt funnels (`NOT_AUTHENTICATED` without a status is `network` in both); and the negative tests wait on positive signals instead of a timer. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the `billing.checkout.*` actions RUM receives for an embedded and a full-page checkout (a quote that loads, a refused quote and a denied capability), which are absent before and present after. ## Where this sits in the plan Linear: [FE-3118](https://linear.app/comfyorg/issue/FE-3118), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](Comfy-Org#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](Comfy-Org#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](Comfy-Org#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](Comfy-Org#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](Comfy-Org#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](Comfy-Org#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](Comfy-Org#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](Comfy-Org#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](Comfy-Org#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](Comfy-Org#19798), merged | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](Comfy-Org#19815), [PR 19816](Comfy-Org#19816), [PR 19817](Comfy-Org#19817), [PR 19818](Comfy-Org#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](Comfy-Org#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | parts 1 and 2 merged ([PR 19809](Comfy-Org#19809), [PR 19810](Comfy-Org#19810), in [PR 19798](Comfy-Org#19798)), [PR 19811](Comfy-Org#19811) in review | | T8 | FE-3118 | Billing web journey and choices | this PR | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](Comfy-Org#19804), [PR 19806](Comfy-Org#19806) and [PR 19807](Comfy-Org#19807), merged in [PR 19798](Comfy-Org#19798) | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T8 stroke-width:3px ``` --------- Co-authored-by: GitHub Action <action@github.com>
…g#19811) ## Summary Billing web reports the resubscribe lifecycle from the subscription screen: `billing.resubscribe.started` before the request and one `billing.resubscribe.succeeded` or `.failed`, with `source: 'billing_web_subscription'`. This is the third of three stacked branches for FE-3117 and delivers E13. It reuses the attempt tracker from the branch that delivers E10 and E11. ## Why The SDK reports a resubscribe as a plain `subscription` operation, so the operation stream cannot tell a resubscribe from a new subscription or a plan change. The cloud app reports `billing.resubscribe.*` from its callers. Billing web reported nothing, so a resubscribe, a plan that was already active and a refusal before any operation were all invisible. ## Root cause The resubscribe button on billing web called `checkout.resubscribe()` with no emitter, and the `resubscribe` event type had no operation id, no duration and no billing web source. ## How - **Events.** `resubscribeTelemetry.ts` builds the events on the same `createAttemptTelemetry` and result mapping as the checkout. The start is reported immediately before `checkout.resubscribe()`. The terminal carries `billing_op_id` once one exists, `duration_ms`, and for a decline its `decline_reason`. A plan that was already active (the SDK's already-held answer, which issues nothing) counts as succeeded and has no operation id. `payment_intent_source` is the entry source when the customer arrived with one. - **Wiring.** `SubscriptionActions.vue` wraps its one `checkout.resubscribe()` call. Cancel is unchanged. - **Contract.** `ResubscribeBillingEvent` gains `billing_op_id`, `duration_ms` and `decline_reason` on its failed variant, all optional, so the cloud's events are unchanged. `ResubscribeSource` gains `billing_web_subscription`. - **README.** A short paragraph in the Telemetry section. ## Review Focus - FE-3140 (Comfy-Org#19798) is merged into main (`a8337f39a4`), and with it FE-3120's three parts (Comfy-Org#19804, Comfy-Org#19806, Comfy-Org#19807) and FE-3117's parts 1 and 2 (Comfy-Org#19809, Comfy-Org#19810). The base of this PR is main. Review only part 3's own change (E13, the resubscribe lifecycle, 9 files against main). This branch also carries one automated formatting commit. - The new `source` value is `billing_web_subscription`. The catalog says only "billing web value". The cloud names its two values after its own screens (`pricing_dialog`, `settings_billing_panel`), so I named this one after billing web's subscription screen. It is a one-line change in `vocabulary.ts` if you prefer another name. - `billing_client: 'sdk'` is stamped, as on the checkout events, because billing web has no legacy path. - A resubscribe that needs a hosted payment step redirects this tab, so the page unloads and no terminal is sent. That start is the abandoned case of FE-3119. A recovered operation after the return reports only the SDK stream, never `billing.resubscribe.*`, as the SSOT requires. - There is no continuation state for resubscribe: the SDK never asks for the reactivation consent on this command. - The SDK stream still reports the same resubscribe as `billing.operation.*` with `operation_type: 'subscription'`. Join the two by `billing_op_id`. They are two signals of one attempt, not two attempts. - E14 (billing web cancel intent, abandoned and failed) is not built. FE-3115 defines the cancel event contract first, so E14 follows it. Billing web's cancel today reports only the SDK stream. A test pins that a cancel emits no `billing.resubscribe.*` event. - Known gap: billing web rebuilds its return links without `source`, so a resubscribe that returns from a provider page cannot carry the entry source. It reports no business event there anyway. - No user-visible change. Billing web sends new RUM actions and PostHog events and nothing else changes. - `UnifiedPricingTable.test.ts` ("prompts free-tier users to subscribe") fails locally on `origin/main` too under Node 24. This diff does not touch it. ## AS IS / TO BE AS IS:  TO BE:  The evidence is the RUM actions billing web sends when a customer resubscribes from the subscription screen and the request settles, is a plan that was already active, is declined, or is refused before an operation exists: before, none; after, `billing.resubscribe.started` and one terminal with `billing_client: 'sdk'` and the billing web source. ## Where this sits in the plan Linear: [FE-3117](https://linear.app/comfyorg/issue/FE-3117), part of [FE-3105](https://linear.app/comfyorg/issue/FE-3105/billing-web-and-sdk-rollout-telemetry-events-fixes-and-dashboards). Plan, event catalog and dependency graph: [action items](https://app.notion.com/p/3ea6d73d3650814ba248d4d1431b8a89). | Task | Ticket | What | Status | | --- | --- | --- | --- | | T1 | FE-3107 | Decide vocabulary and dimensions | done, in the SSOT | | T2 | FE-3108 | Decide RUM application and env mapping | decided | | T3 | FE-3109 | Billing web telemetry bootstrap (RUM and PostHog) | [PR 19688](Comfy-Org#19688), merged | | T3+ | FE-3156 | Opaque RUM user id on billing web | [PR 19794](Comfy-Org#19794), merged | | T4, F1 | FE-3106 | SDK-rail ownership | [PR 19620](Comfy-Org#19620), merged | | T4, F2 | FE-3110 | Keep operation id and fields in the mapper | [PR 19623](Comfy-Org#19623), merged | | T4, F3 | FE-3111 | Stamp billing_surface and billing_client | [PR 19685](Comfy-Org#19685), merged | | T4, F5 | FE-3112 | SDK top-up terminals | [PR 19628](Comfy-Org#19628), merged | | T4, F6 | FE-3113 | Downgrade reconciliation terminal | [PR 19622](Comfy-Org#19622), merged | | T4, F7 | FE-3114 | Legacy personal-rail events, first slice | [PR 19627](Comfy-Org#19627), merged | | T4, F7+ | FE-3131 | Legacy personal-rail events, remaining slices | [PR 19686](Comfy-Org#19686), merged | | T4+ | FE-3140 | Move the billing event contract to a shared package | [PR 19798](Comfy-Org#19798), merged | | T5 | FE-3115 | Cloud entry fidelity and Datadog parity | [PR 19815](Comfy-Org#19815), [PR 19816](Comfy-Org#19816), [PR 19817](Comfy-Org#19817), [PR 19818](Comfy-Org#19818), in review | | T6 | FE-3116 | Handoff contract and event | [PR 19687](Comfy-Org#19687), merged | | T7 | FE-3117 | Billing web attempt lifecycle | this PR | | T8 | FE-3118 | Billing web journey and choices | [PR 19819](Comfy-Org#19819), [PR 19821](Comfy-Org#19821), [PR 19822](Comfy-Org#19822), in review | | T9 | FE-3119 | Payment friction events | todo | | T10 | FE-3120 | Billing web entry, session and return | [PR 19804](Comfy-Org#19804), [PR 19806](Comfy-Org#19806) and [PR 19807](Comfy-Org#19807), merged in [PR 19798](Comfy-Org#19798) | | T11 | FE-3121 | Portal events | todo | | T12 | FE-3122 | Flag coverage check | todo | | T13 | FE-3123 | PostHog rollout dashboard | todo | | T14 | FE-3124 | Datadog tiles in the Frontend RUM dashboard | todo | | T15 | FE-3125 | Verification per flow | todo | | T16 | FE-3126 | Rollout plan | todo | ```mermaid flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T7 stroke-width:3px ``` --------- Co-authored-by: GitHub Action <action@github.com>
Summary
Part 2 of 3, on part 1. Both billing web checkouts pass the payment form's phases through (
payment_element_ready,payment_element_failed,payment_submit_attempted,payment_submit_failed), reportsubmittedon each Pay that goes ahead, and reportoperation_linkedwith the operation that Pay issued.Why
The embedded checkout had no listener for the form's phases, and the full page read only the element phases for its own state. The billing web funnel stopped at the quote. The cloud app reports these steps, so the two surfaces could not be compared past the preview.
How
@payment-phaseon the confirm. The full page forwards all four phases fromonPaymentPhase, including the submit phases it used to ignore. The shape is the cloud app's, so the same queries read both.payreportssubmittedright before the subscribe call. The full page reports it from the page's ownpaySubmittedevent. Both fire after the checkout's own guards, so a Pay that sends nothing is notsubmitted.submittedis linked, once, and its id rides on the later events asbilling_op_id. A newsubmittedclears it. An operation the checkout recovered on arrival, or one a sibling tab started, is never linked because nosubmittedpreceded it.Review Focus
f34408a7ff. Next: the choices (E19 to E21).entered,preview_ready,payment_element_ready,payment_submit_attempted,submitted,operation_linked. Part 3 addsmethod_selectedbeforesubmitted.submittedalso fires for a Pay the server refuses before issuing any operation. Those attempts have nooperation_linked. Their business terminal is FE-3117's (E10 and E11), not this ticket's.error_codeonpayment_element_failedandpayment_submit_failedis the provider's own error code, passed through exactly as the cloud app does. The type isstring, not an allowlist, and it is the one field in this set whose values the contract does not bound.payment_element_readyagain. That matches what the cloud app reports for the same form.AS IS / TO BE
AS IS:
TO BE:
The evidence is the ordered
billing.checkout.*actions RUM receives for an embedded and a full-page card payment, with the operation id onoperation_linked, before (nothing past the quote) and after.Where this sits in the plan
Linear: FE-3118, part of FE-3105. Plan, event catalog and dependency graph: action items.
flowchart LR subgraph DEC["Decided"] T1["FE-3107 T1 vocabulary"] T2["FE-3108 T2 RUM app and env"] end subgraph FIX["Existing events (T4)"] F1["FE-3106 F1 SDK-rail ownership"] F2["FE-3110 F2 mapper fields"] F3["FE-3111 F3 surface and client"] F5["FE-3112 F5 top-up terminals"] F6["FE-3113 F6 downgrade terminal"] F7["FE-3114 F7 legacy personal, first slice"] F7B["FE-3131 F7 remaining slices"] C140["FE-3140 event contract to shared package"] end subgraph EMIT["New events"] T3["FE-3109 T3 billing web bootstrap"] T3b["FE-3156 T3+ opaque RUM user id"] T5["FE-3115 T5 cloud entry and parity"] T6["FE-3116 T6 handoff contract"] T7["FE-3117 T7 attempt lifecycle"] T8["FE-3118 T8 journey and choices"] T9["FE-3119 T9 friction"] T10["FE-3120 T10 entry, session, return"] T11["FE-3121 T11 portal"] T12["FE-3122 T12 flag coverage"] end subgraph DASH["Dashboards"] T13["FE-3123 T13 PostHog rollout"] T14["FE-3124 T14 Frontend RUM tiles"] end T15["FE-3125 T15 verification"] T16["FE-3126 T16 rollout plan"] T2 --> T3 T3 --> T3b F3 --> C140 T3 --> C140 C140 --> T7 C140 --> T8 C140 --> T10 C140 --> T11 T1 --> F3 T1 --> T5 T1 --> T6 T1 --> T13 T1 --> T14 T2 --> T14 F2 --> T7 T3 --> T7 T3 --> T8 T3 --> T10 T3 --> T11 T3 --> T12 T5 --> T11 T6 --> T8 T6 --> T10 T7 --> T9 T8 --> T9 F1 --> T13 F3 --> T13 FIX --> T15 T5 --> T15 T9 --> T15 T10 --> T15 T11 --> T15 T12 --> T15 T13 --> T15 T14 --> T15 T13 --> T16 T15 --> T16 style T8 stroke-width:3px