Skip to content

fix(telemetry): duration_ms, real failure categories, and started events for incident-88 followups - #14229

Merged
dante01yoon merged 16 commits into
fix/incident-88-telemetry-gapsfrom
fix/incident-88-telemetry-followups
Aug 7, 2026
Merged

dante01yoon merged 16 commits into
fix/incident-88-telemetry-gapsfrom
fix/incident-88-telemetry-followups

Conversation

@claude

@claude claude Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Part of the billing & subscription telemetry observability program.

Program context

📋 Program dossier — the public plan doc for this program: the problem, the two-rail billing architecture, why rail asymmetry is the recurring bug class, the tool split, the phase structure, and the standing constraints on every PR in the program. Written to be read by agent reviewers as well as humans; about three minutes.

⚠️ Dependency chain — read before reviewing

This PR is stacked on #14216, not on main.

How to review this PR

What this PR does. Three independent, mechanical follow-ups found by auditing #14216's diff against the outstanding correlation-gap list. Each applies a pattern #14216 already established elsewhere in the same subsystem, so none of them introduces a new concept:

  1. duration_ms on poller-backed billing events. Call sites capture attemptStartedAt alongside the canonical started event and pass it through billingOperationStore.ts, while the store's separate startedAt remains the poll-timeout clock. Every terminal event the poller fires — succeeded/failed/timeout, across subscription_checkout, operation, topup, downgrade_to_personal — reports started-to-terminal duration_ms, including initiating-request latency.
  2. Real failure_category in useDowngradeToPersonal.ts. Three sites hardcoded 'unknown', predating fix(telemetry): close four billing telemetry gaps from incident-88 audit #14216's helper. The two that have a real caught error now route through categorizeBillingApiError(). The third (missing_checkout_response) is intentionally left 'unknown'.
  3. Canonical started events for subscribe / cancel / top-up / resubscribe. Previously only downgrade_to_personal had a started stage, which meant no billing flow had a funnel entry step.

Where it sits in the program. Phase B tail (b3-typed-failure-reasons, plus the started-event half of the funnel work). These three fields are what turn terminal-outcome-only events into something a funnel and a latency dashboard can actually use: without a started event there is no funnel entry step to measure drop-off from, and without duration_ms there is no end-to-end latency signal at all. Phase D's funnel widgets depend on item 3 existing.

Focus your review on:

  1. getBillingTelemetryEventPayload() in types.ts — check first. Confirm duration_ms is added to the allowlist reconstruction. Adding a field to a type and forgetting the payload builder is a silent no-op, and it was itself one of the gaps fix(telemetry): close four billing telemetry gaps from incident-88 audit #14216 had to fix. This is the highest-value single check in the PR.
  2. billingOperationStore.ts's handleSuccess/handleFailure/handleTimeout — confirm duration_ms is computed once per terminal transition and threaded through every event fired from that transition, including the paired downgrade_to_personal event.
  3. useDowngradeToPersonal.ts — confirm the missing_checkout_response site is correctly not touched (there is no caught error there — a resolved-but-empty response, not an exception, matching the precedent fix(telemetry): close four billing telemetry gaps from incident-88 audit #14216 set for the identical case), and that the outer catch's fallback telemetryFailure ?? { failure_category: categorizeBillingApiError(error) } does not change behavior for branches that already set a specific category (validation, redirect).
  4. started/terminal pairing. A started event with no matching terminal event on some path would show as permanent funnel drop-off — a data-quality bug that looks exactly like a product bug. Check each new started site can actually reach a terminal event.
  5. Semantics of duration_ms. It measures client-observed wall time from the canonical started event to the client seeing a terminal state, including the initiating request. On the timeout event in particular that is "how long the client watched", not "how long the operation took" — the underlying billing process can outlive the poll window. Worth confirming the field is not going to be read as backend latency.

Cancel idempotency contract. An ALREADY_CANCELED response closes the canonical lifecycle with billing.operation.succeeded but has no billing_op_id, because no pollable operation was created. Consumers must tolerate the absent ID and must not treat cancel-success volume as one event per backend operation.

Deliberately out of scope — tracked separately, please don't block on them:

  • Legacy top-up started events. Resubscribe is covered on both rails and both entry points: exactly one canonical started event fires before each attempt, legacy checkout launch does not emit a second start or a false terminal success, and workspace reactivation emits its real terminal outcome. Only the legacy top-up dialog remains out of scope, tracked separately per the program's rail-asymmetry rule.
  • workspace_id, billing_attempt_id, and source_version — design-gated on ADR-0014 (docs: scope client attempt-id and workspace-scoping for billing telemetry (Phase B) #14228), not in this PR.
  • Backend-side duration_ms / sync-lag measurement, which needs the backend correlation-ID work.

Housekeeping in this PR. An earlier conflict-resolution merge on this branch had pulled in two unrelated apps/website files whose Tailwind utility classes had been reordered by the pre-commit formatter. Those have been reverted to their state on main (commit 1c34674), so the diff is now telemetry-only — 15 files, no apps/website churn. If that reordering is desirable it belongs in its own formatting PR covering the whole app.

Summary

  • src/platform/telemetry/types.ts: added duration_ms?: number to SubscriptionCheckoutBillingEvent, BillingOperationBillingEvent, TopupBillingEvent, DowngradeToPersonalBillingEvent; added BillingStarted to the ResubscribeBillingEvent/SubscriptionCheckoutBillingEvent/BillingOperationBillingEvent/TopupBillingEvent stage unions; added matching BILLING_*_STARTED name constants; updated getBillingTelemetryEventPayload() to pass through duration_ms.
  • src/platform/workspace/stores/billingOperationStore.ts: keep poll-timeout bookkeeping separate from attemptStartedAt, and compute started-to-terminal duration_ms once for every succeeded/failed/timeout transition.
  • src/platform/workspace/composables/useDowngradeToPersonal.ts: route the outer-catch default and member-removal failure through categorizeBillingApiError() instead of hardcoding 'unknown'.
  • src/platform/workspace/composables/useSubscriptionCheckout.ts: fire subscription_checkout started only after non-terminal guards, pass the same attempt timestamp into the poller, and emit exactly one pre-call resubscribe start from the pricing-dialog entry point.
  • src/platform/workspace/composables/useWorkspaceBilling.ts: fire operation started (operation_type: 'cancel') for committed cancel attempts, pass its timestamp into the poller, and close ALREADY_CANCELED attempts with a terminal success.
  • src/platform/workspace/composables/useResubscribe.ts: fire exactly one resubscribe started before the call on both rails; emit immediate success only for workspace billing, whose call is terminal.
  • src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue: fire topup started with the attempt timestamp, pass it into the poller, and close an empty response with a canonical failure.
  • Updated/added tests in each touched file's *.test.ts using real billing error classes, exact-count assertions for one legacy resubscribe start per attempt, fake-timer end-to-end duration assertions, and provider payload contracts that retain duration_ms.

Breaking: none — all changes are additive telemetry fields/stages and new call sites.

Verification

  • pnpm typecheck — pass
  • pnpm lint (stylelint, oxlint, eslint) — pass (pre-existing warnings only, none in touched files)
  • pnpm format:check (oxfmt) — pass
  • pnpm knip — clean
  • pnpm test:unit — full suite: 1060 test files, 14033 tests passed, 8 skipped (pre-existing skips, unrelated)

Screenshots (if applicable)

N/A — telemetry-only change, no UI changes.


🤖 Generated with Claude Code

… events

Three mechanical follow-ups from an audit of #14216 against a gap list:

- duration_ms on poller-backed billing events: billingOperationStore.ts
  already tracked startedAt for poll-timeout detection; now every
  succeeded/failed/timeout event it fires also reports the elapsed
  duration.
- useDowngradeToPersonal.ts's two generic failure sites (the outer
  catch-all default and member-removal failures) now categorize via
  categorizeBillingApiError() instead of hardcoding 'unknown', matching
  the pattern already used elsewhere. The missing_checkout_response site
  stays 'unknown' by design (no caught error to inspect), mirroring the
  same precedent in useSubscriptionCheckout.ts.
- Canonical 'started' events for subscription_checkout, operation
  (cancel), resubscribe, and topup, matching the existing
  downgrade_to_personal 'started' pattern.
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 28, 2026
@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 08/07/2026, 06:49:54 PM UTC

Links

🎭 Playwright: ✅ 1780 passed, 0 failed · 5 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1759 / ❌ 0 / ⚠️ 5 / ⏭️ 5)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

📦 Bundle Size

⏳ Size data collection in progress…

⚡ Performance Report

canvas-idle: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 66.4 MB heap
canvas-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 48.5 MB heap
canvas-zoom-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 69.3 MB heap
dom-widget-clipping: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 50.6 MB heap
large-graph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 63.2 MB heap
large-graph-pan: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 60.4 MB heap
large-graph-zoom: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 82.1 MB heap
minimap-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 64.3 MB heap
subgraph-dom-widget-clipping: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 51.0 MB heap
subgraph-idle: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 54.9 MB heap
subgraph-mouse-sweep: · 60.0 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 50.3 MB heap
subgraph-transition-enter: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 135ms TBT · 94.7 MB heap
viewport-pan-sweep: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 68.4 MB heap
vue-large-graph-idle: · 56.3 avg FPS · 59.7 P5 FPS ✅ (target: ≥52) · 0ms TBT · 159.8 MB heap
vue-large-graph-pan: · 54.5 avg FPS · 59.5 P5 FPS ✅ (target: ≥52) · 754ms TBT · 163.2 MB heap
workflow-execution: · 60.0 avg FPS · 59.9 P5 FPS ✅ (target: ≥52) · 0ms TBT · 64.5 MB heap

ℹ️ No baseline found — significance unavailable.

Absolute values
Metric Value
canvas-idle: avg frame time 17ms
canvas-idle: p95 frame time 17ms
canvas-idle: layout duration 0ms
canvas-idle: style recalc duration 8ms
canvas-idle: layout count 0
canvas-idle: style recalc count 9
canvas-idle: task duration 561ms
canvas-idle: script duration 24ms
canvas-idle: TBT 0ms
canvas-idle: heap used 66.4 MB
canvas-idle: DOM nodes 17
canvas-idle: event listeners 5
canvas-mouse-sweep: avg frame time 17ms
canvas-mouse-sweep: p95 frame time 17ms
canvas-mouse-sweep: layout duration 4ms
canvas-mouse-sweep: style recalc duration 41ms
canvas-mouse-sweep: layout count 12
canvas-mouse-sweep: style recalc count 76
canvas-mouse-sweep: task duration 957ms
canvas-mouse-sweep: script duration 127ms
canvas-mouse-sweep: TBT 0ms
canvas-mouse-sweep: heap used 48.5 MB
canvas-mouse-sweep: DOM nodes -281
canvas-mouse-sweep: event listeners -153
canvas-zoom-sweep: avg frame time 17ms
canvas-zoom-sweep: p95 frame time 17ms
canvas-zoom-sweep: layout duration 1ms
canvas-zoom-sweep: style recalc duration 18ms
canvas-zoom-sweep: layout count 6
canvas-zoom-sweep: style recalc count 32
canvas-zoom-sweep: task duration 424ms
canvas-zoom-sweep: script duration 24ms
canvas-zoom-sweep: TBT 0ms
canvas-zoom-sweep: heap used 69.3 MB
canvas-zoom-sweep: DOM nodes 78
canvas-zoom-sweep: event listeners 19
dom-widget-clipping: avg frame time 17ms
dom-widget-clipping: p95 frame time 17ms
dom-widget-clipping: layout duration 0ms
dom-widget-clipping: style recalc duration 8ms
dom-widget-clipping: layout count 0
dom-widget-clipping: style recalc count 11
dom-widget-clipping: task duration 406ms
dom-widget-clipping: script duration 61ms
dom-widget-clipping: TBT 0ms
dom-widget-clipping: heap used 50.6 MB
dom-widget-clipping: DOM nodes 17
dom-widget-clipping: event listeners 1
large-graph-idle: avg frame time 17ms
large-graph-idle: p95 frame time 17ms
large-graph-idle: layout duration 0ms
large-graph-idle: style recalc duration 8ms
large-graph-idle: layout count 0
large-graph-idle: style recalc count 9
large-graph-idle: task duration 759ms
large-graph-idle: script duration 116ms
large-graph-idle: TBT 0ms
large-graph-idle: heap used 63.2 MB
large-graph-idle: DOM nodes -282
large-graph-idle: event listeners -149
large-graph-pan: avg frame time 17ms
large-graph-pan: p95 frame time 17ms
large-graph-pan: layout duration 0ms
large-graph-pan: style recalc duration 16ms
large-graph-pan: layout count 0
large-graph-pan: style recalc count 68
large-graph-pan: task duration 1354ms
large-graph-pan: script duration 431ms
large-graph-pan: TBT 0ms
large-graph-pan: heap used 60.4 MB
large-graph-pan: DOM nodes -286
large-graph-pan: event listeners -149
large-graph-zoom: avg frame time 17ms
large-graph-zoom: p95 frame time 17ms
large-graph-zoom: layout duration 9ms
large-graph-zoom: style recalc duration 16ms
large-graph-zoom: layout count 60
large-graph-zoom: style recalc count 64
large-graph-zoom: task duration 1570ms
large-graph-zoom: script duration 560ms
large-graph-zoom: TBT 0ms
large-graph-zoom: heap used 82.1 MB
large-graph-zoom: DOM nodes 10
large-graph-zoom: event listeners 8
minimap-idle: avg frame time 17ms
minimap-idle: p95 frame time 17ms
minimap-idle: layout duration 0ms
minimap-idle: style recalc duration 8ms
minimap-idle: layout count 0
minimap-idle: style recalc count 8
minimap-idle: task duration 769ms
minimap-idle: script duration 125ms
minimap-idle: TBT 0ms
minimap-idle: heap used 64.3 MB
minimap-idle: DOM nodes -284
minimap-idle: event listeners -149
subgraph-dom-widget-clipping: avg frame time 17ms
subgraph-dom-widget-clipping: p95 frame time 17ms
subgraph-dom-widget-clipping: layout duration 0ms
subgraph-dom-widget-clipping: style recalc duration 11ms
subgraph-dom-widget-clipping: layout count 0
subgraph-dom-widget-clipping: style recalc count 47
subgraph-dom-widget-clipping: task duration 426ms
subgraph-dom-widget-clipping: script duration 129ms
subgraph-dom-widget-clipping: TBT 0ms
subgraph-dom-widget-clipping: heap used 51.0 MB
subgraph-dom-widget-clipping: DOM nodes 19
subgraph-dom-widget-clipping: event listeners 7
subgraph-idle: avg frame time 17ms
subgraph-idle: p95 frame time 17ms
subgraph-idle: layout duration 0ms
subgraph-idle: style recalc duration 9ms
subgraph-idle: layout count 0
subgraph-idle: style recalc count 10
subgraph-idle: task duration 511ms
subgraph-idle: script duration 17ms
subgraph-idle: TBT 0ms
subgraph-idle: heap used 54.9 MB
subgraph-idle: DOM nodes -130
subgraph-idle: event listeners -75
subgraph-mouse-sweep: avg frame time 17ms
subgraph-mouse-sweep: p95 frame time 17ms
subgraph-mouse-sweep: layout duration 5ms
subgraph-mouse-sweep: style recalc duration 40ms
subgraph-mouse-sweep: layout count 16
subgraph-mouse-sweep: style recalc count 78
subgraph-mouse-sweep: task duration 841ms
subgraph-mouse-sweep: script duration 100ms
subgraph-mouse-sweep: TBT 0ms
subgraph-mouse-sweep: heap used 50.3 MB
subgraph-mouse-sweep: DOM nodes 63
subgraph-mouse-sweep: event listeners 4
subgraph-transition-enter: avg frame time 17ms
subgraph-transition-enter: p95 frame time 17ms
subgraph-transition-enter: layout duration 13ms
subgraph-transition-enter: style recalc duration 32ms
subgraph-transition-enter: layout count 15
subgraph-transition-enter: style recalc count 19
subgraph-transition-enter: task duration 984ms
subgraph-transition-enter: script duration 37ms
subgraph-transition-enter: TBT 135ms
subgraph-transition-enter: heap used 94.7 MB
subgraph-transition-enter: DOM nodes 13673
subgraph-transition-enter: event listeners 2375
viewport-pan-sweep: avg frame time 17ms
viewport-pan-sweep: p95 frame time 17ms
viewport-pan-sweep: layout duration 0ms
viewport-pan-sweep: style recalc duration 45ms
viewport-pan-sweep: layout count 0
viewport-pan-sweep: style recalc count 250
viewport-pan-sweep: task duration 4871ms
viewport-pan-sweep: script duration 1468ms
viewport-pan-sweep: TBT 0ms
viewport-pan-sweep: heap used 68.4 MB
viewport-pan-sweep: DOM nodes -283
viewport-pan-sweep: event listeners -148
vue-large-graph-idle: avg frame time 18ms
vue-large-graph-idle: p95 frame time 17ms
vue-large-graph-idle: layout duration 0ms
vue-large-graph-idle: style recalc duration 0ms
vue-large-graph-idle: layout count 0
vue-large-graph-idle: style recalc count 0
vue-large-graph-idle: task duration 18380ms
vue-large-graph-idle: script duration 599ms
vue-large-graph-idle: TBT 0ms
vue-large-graph-idle: heap used 159.8 MB
vue-large-graph-idle: DOM nodes -8312
vue-large-graph-idle: event listeners -16387
vue-large-graph-pan: avg frame time 18ms
vue-large-graph-pan: p95 frame time 17ms
vue-large-graph-pan: layout duration 0ms
vue-large-graph-pan: style recalc duration 28ms
vue-large-graph-pan: layout count 0
vue-large-graph-pan: style recalc count 175
vue-large-graph-pan: task duration 23325ms
vue-large-graph-pan: script duration 958ms
vue-large-graph-pan: TBT 754ms
vue-large-graph-pan: heap used 163.2 MB
vue-large-graph-pan: DOM nodes -8312
vue-large-graph-pan: event listeners -16379
workflow-execution: avg frame time 17ms
workflow-execution: p95 frame time 17ms
workflow-execution: layout duration 1ms
workflow-execution: style recalc duration 20ms
workflow-execution: layout count 3
workflow-execution: style recalc count 13
workflow-execution: task duration 106ms
workflow-execution: script duration 10ms
workflow-execution: TBT 0ms
workflow-execution: heap used 64.5 MB
workflow-execution: DOM nodes 134
workflow-execution: event listeners 74
Raw data
{
  "timestamp": "2026-08-07T19:00:26.807Z",
  "gitSha": "bce44e1643f2276a2f861f5ed816a22aadda9af7",
  "branch": "fix/incident-88-telemetry-followups",
  "measurements": [
    {
      "name": "canvas-idle",
      "durationMs": 2140.989999999988,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 9.405,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 617.197,
      "heapDeltaBytes": 5768740,
      "heapUsedBytes": 69787800,
      "domNodes": 18,
      "jsHeapTotalBytes": 24641536,
      "scriptDurationMs": 26.139999999999997,
      "eventListeners": 6,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-idle",
      "durationMs": 2016.144000000054,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 7.429999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 505.1239999999999,
      "heapDeltaBytes": 5318744,
      "heapUsedBytes": 69360932,
      "domNodes": 16,
      "jsHeapTotalBytes": 24903680,
      "scriptDurationMs": 22.6,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1904.2830000000208,
      "styleRecalcs": 76,
      "styleRecalcDurationMs": 42.316,
      "layouts": 12,
      "layoutDurationMs": 4.3,
      "taskDurationMs": 962.3329999999999,
      "heapDeltaBytes": -12914148,
      "heapUsedBytes": 51036944,
      "domNodes": -280,
      "jsHeapTotalBytes": 24358912,
      "scriptDurationMs": 128.93800000000002,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "canvas-mouse-sweep",
      "durationMs": 1909.0159999999514,
      "styleRecalcs": 75,
      "styleRecalcDurationMs": 40.553000000000004,
      "layouts": 12,
      "layoutDurationMs": 3.688,
      "taskDurationMs": 951.7270000000001,
      "heapDeltaBytes": -13344588,
      "heapUsedBytes": 50573760,
      "domNodes": -281,
      "jsHeapTotalBytes": 24621056,
      "scriptDurationMs": 125.78999999999999,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1754.4299999999566,
      "styleRecalcs": 31,
      "styleRecalcDurationMs": 20.014000000000003,
      "layouts": 6,
      "layoutDurationMs": 0.7499999999999998,
      "taskDurationMs": 463.79400000000004,
      "heapDeltaBytes": 8710852,
      "heapUsedBytes": 72627756,
      "domNodes": 77,
      "jsHeapTotalBytes": 24903680,
      "scriptDurationMs": 27.993,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "canvas-zoom-sweep",
      "durationMs": 1716.6270000000168,
      "styleRecalcs": 32,
      "styleRecalcDurationMs": 16.214,
      "layouts": 6,
      "layoutDurationMs": 0.6810000000000002,
      "taskDurationMs": 383.622,
      "heapDeltaBytes": 8401260,
      "heapUsedBytes": 72634632,
      "domNodes": 78,
      "jsHeapTotalBytes": 24379392,
      "scriptDurationMs": 20.802,
      "eventListeners": 19,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 603.8490000000252,
      "styleRecalcs": 11,
      "styleRecalcDurationMs": 8.522000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 404.70900000000006,
      "heapDeltaBytes": -10987776,
      "heapUsedBytes": 53115512,
      "domNodes": 18,
      "jsHeapTotalBytes": 25165824,
      "scriptDurationMs": 61.78900000000001,
      "eventListeners": 0,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "dom-widget-clipping",
      "durationMs": 654.0290000000368,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 8.1,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 407.34600000000006,
      "heapDeltaBytes": -11053968,
      "heapUsedBytes": 52995708,
      "domNodes": 16,
      "jsHeapTotalBytes": 25165824,
      "scriptDurationMs": 60.70899999999999,
      "eventListeners": 2,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2054.8970000000395,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.264000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 794.235,
      "heapDeltaBytes": 7084472,
      "heapUsedBytes": 66464040,
      "domNodes": -281,
      "jsHeapTotalBytes": 2727936,
      "scriptDurationMs": 121.87499999999999,
      "eventListeners": -149,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "large-graph-idle",
      "durationMs": 2027.8189999999086,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 7.735000000000002,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 724.132,
      "heapDeltaBytes": 6692992,
      "heapUsedBytes": 66135576,
      "domNodes": -283,
      "jsHeapTotalBytes": 3252224,
      "scriptDurationMs": 109.84000000000002,
      "eventListeners": -149,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66999999999998,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2208.837000000017,
      "styleRecalcs": 68,
      "styleRecalcDurationMs": 16.082999999999995,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1347.3640000000003,
      "heapDeltaBytes": 4177472,
      "heapUsedBytes": 64726568,
      "domNodes": -285,
      "jsHeapTotalBytes": 3706880,
      "scriptDurationMs": 427.01800000000003,
      "eventListeners": -147,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-pan",
      "durationMs": 2183.6339999999836,
      "styleRecalcs": 68,
      "styleRecalcDurationMs": 15.700000000000003,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 1360.592,
      "heapDeltaBytes": 1690208,
      "heapUsedBytes": 62029956,
      "domNodes": -286,
      "jsHeapTotalBytes": 4231168,
      "scriptDurationMs": 435.10499999999996,
      "eventListeners": -151,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3211.3709999999855,
      "styleRecalcs": 64,
      "styleRecalcDurationMs": 15.967000000000002,
      "layouts": 60,
      "layoutDurationMs": 8.732,
      "taskDurationMs": 1598.4129999999998,
      "heapDeltaBytes": 24079384,
      "heapUsedBytes": 86326652,
      "domNodes": 10,
      "jsHeapTotalBytes": 7077888,
      "scriptDurationMs": 571.457,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "large-graph-zoom",
      "durationMs": 3181.3809999999876,
      "styleRecalcs": 64,
      "styleRecalcDurationMs": 15.347000000000003,
      "layouts": 60,
      "layoutDurationMs": 8.575,
      "taskDurationMs": 1541.2939999999999,
      "heapDeltaBytes": 23819736,
      "heapUsedBytes": 85909628,
      "domNodes": 10,
      "jsHeapTotalBytes": 7602176,
      "scriptDurationMs": 549.3180000000001,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "minimap-idle",
      "durationMs": 2040.2330000000006,
      "styleRecalcs": 7,
      "styleRecalcDurationMs": 7.005000000000001,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 756.2849999999999,
      "heapDeltaBytes": 7036024,
      "heapUsedBytes": 67446596,
      "domNodes": -284,
      "jsHeapTotalBytes": 3514368,
      "scriptDurationMs": 120.364,
      "eventListeners": -151,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.800000000000182
    },
    {
      "name": "minimap-idle",
      "durationMs": 2040.571,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.823,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 781.0510000000002,
      "heapDeltaBytes": 6878676,
      "heapUsedBytes": 67299356,
      "domNodes": -283,
      "jsHeapTotalBytes": 4038656,
      "scriptDurationMs": 130.221,
      "eventListeners": -147,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 644.5679999999925,
      "styleRecalcs": 46,
      "styleRecalcDurationMs": 11.495,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 435.86500000000007,
      "heapDeltaBytes": -10759208,
      "heapUsedBytes": 53392252,
      "domNodes": 18,
      "jsHeapTotalBytes": 26214400,
      "scriptDurationMs": 131.295,
      "eventListeners": 8,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-dom-widget-clipping",
      "durationMs": 615.0440000000117,
      "styleRecalcs": 47,
      "styleRecalcDurationMs": 11.203999999999999,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 415.25800000000004,
      "heapDeltaBytes": -10407172,
      "heapUsedBytes": 53661056,
      "domNodes": 20,
      "jsHeapTotalBytes": 25690112,
      "scriptDurationMs": 126.98799999999999,
      "eventListeners": 6,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.699999999999818
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2004.5610000000238,
      "styleRecalcs": 10,
      "styleRecalcDurationMs": 9.006,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 555.627,
      "heapDeltaBytes": -18246884,
      "heapUsedBytes": 45990652,
      "domNodes": -278,
      "jsHeapTotalBytes": 23834624,
      "scriptDurationMs": 18.546,
      "eventListeners": -153,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "subgraph-idle",
      "durationMs": 2006.7530000000033,
      "styleRecalcs": 9,
      "styleRecalcDurationMs": 8.26,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 465.646,
      "heapDeltaBytes": 5115420,
      "heapUsedBytes": 69188444,
      "domNodes": 18,
      "jsHeapTotalBytes": 24641536,
      "scriptDurationMs": 15.119,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1705.8020000000056,
      "styleRecalcs": 77,
      "styleRecalcDurationMs": 40.209999999999994,
      "layouts": 16,
      "layoutDurationMs": 4.762,
      "taskDurationMs": 816.4370000000001,
      "heapDeltaBytes": -4168524,
      "heapUsedBytes": 59886484,
      "domNodes": 64,
      "jsHeapTotalBytes": 25427968,
      "scriptDurationMs": 100.088,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "subgraph-mouse-sweep",
      "durationMs": 1764.6799999999985,
      "styleRecalcs": 78,
      "styleRecalcDurationMs": 39.516999999999996,
      "layouts": 16,
      "layoutDurationMs": 4.901,
      "taskDurationMs": 865.912,
      "heapDeltaBytes": -18746684,
      "heapUsedBytes": 45626536,
      "domNodes": 62,
      "jsHeapTotalBytes": 22786048,
      "scriptDurationMs": 100.077,
      "eventListeners": 4,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333332,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "subgraph-transition-enter",
      "durationMs": 1418.5380000000123,
      "styleRecalcs": 19,
      "styleRecalcDurationMs": 32.09000000000001,
      "layouts": 15,
      "layoutDurationMs": 12.661999999999999,
      "taskDurationMs": 983.945,
      "heapDeltaBytes": 30764492,
      "heapUsedBytes": 99332516,
      "domNodes": 13673,
      "jsHeapTotalBytes": 16252928,
      "scriptDurationMs": 37.352999999999994,
      "eventListeners": 2375,
      "totalBlockingTimeMs": 135,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8663.404000000013,
      "styleRecalcs": 250,
      "styleRecalcDurationMs": 45.995999999999995,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 5089.254999999999,
      "heapDeltaBytes": 12946484,
      "heapUsedBytes": 72414508,
      "domNodes": -281,
      "jsHeapTotalBytes": 5541888,
      "scriptDurationMs": 1543.916,
      "eventListeners": -163,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333338,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "viewport-pan-sweep",
      "durationMs": 8340.018999999984,
      "styleRecalcs": 249,
      "styleRecalcDurationMs": 43.89,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 4652.224,
      "heapDeltaBytes": 11567936,
      "heapUsedBytes": 71040556,
      "domNodes": -284,
      "jsHeapTotalBytes": 5541888,
      "scriptDurationMs": 1392.988,
      "eventListeners": -133,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.670000000000012,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 18709.35700000001,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 18683.674000000003,
      "heapDeltaBytes": -43902608,
      "heapUsedBytes": 167843436,
      "domNodes": -8312,
      "jsHeapTotalBytes": -5185536,
      "scriptDurationMs": 599.5129999999999,
      "eventListeners": -16387,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.776666666666763,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-idle",
      "durationMs": 18102.212000000007,
      "styleRecalcs": 0,
      "styleRecalcDurationMs": 0,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 18077.306999999997,
      "heapDeltaBytes": -58847288,
      "heapUsedBytes": 167356636,
      "domNodes": -8312,
      "jsHeapTotalBytes": -5447680,
      "scriptDurationMs": 597.927,
      "eventListeners": -16387,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 17.776666666666763,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 23606.37600000001,
      "styleRecalcs": 175,
      "styleRecalcDurationMs": 28.054999999999996,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 23545.877,
      "heapDeltaBytes": -41485276,
      "heapUsedBytes": 164144688,
      "domNodes": -8312,
      "jsHeapTotalBytes": -9379840,
      "scriptDurationMs": 959.8789999999999,
      "eventListeners": -16377,
      "totalBlockingTimeMs": 705,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "vue-large-graph-pan",
      "durationMs": 23131.11200000003,
      "styleRecalcs": 175,
      "styleRecalcDurationMs": 27.57499999999996,
      "layouts": 0,
      "layoutDurationMs": 0,
      "taskDurationMs": 23104.952999999998,
      "heapDeltaBytes": -52008136,
      "heapUsedBytes": 178043140,
      "domNodes": -8312,
      "jsHeapTotalBytes": -9187328,
      "scriptDurationMs": 956.3349999999999,
      "eventListeners": -16381,
      "totalBlockingTimeMs": 802,
      "frameDurationMs": 18.333333333333332,
      "p95FrameDurationMs": 16.799999999999272
    },
    {
      "name": "workflow-execution",
      "durationMs": 470.6459999999879,
      "styleRecalcs": 17,
      "styleRecalcDurationMs": 23.946999999999996,
      "layouts": 3,
      "layoutDurationMs": 1.4749999999999999,
      "taskDurationMs": 129.245,
      "heapDeltaBytes": 5427768,
      "heapUsedBytes": 68827056,
      "domNodes": 156,
      "jsHeapTotalBytes": 5505024,
      "scriptDurationMs": 12.285,
      "eventListeners": 99,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.66333333333335,
      "p95FrameDurationMs": 16.700000000000728
    },
    {
      "name": "workflow-execution",
      "durationMs": 129.07899999993333,
      "styleRecalcs": 8,
      "styleRecalcDurationMs": 15.946000000000002,
      "layouts": 3,
      "layoutDurationMs": 0.6249999999999999,
      "taskDurationMs": 83.66999999999999,
      "heapDeltaBytes": 3184604,
      "heapUsedBytes": 66434336,
      "domNodes": 112,
      "jsHeapTotalBytes": 3145728,
      "scriptDurationMs": 6.853,
      "eventListeners": 49,
      "totalBlockingTimeMs": 0,
      "frameDurationMs": 16.666666666666668,
      "p95FrameDurationMs": 16.700000000000273
    }
  ]
}

@codecov

codecov Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.26168% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...platform/workspace/stores/billingOperationStore.ts 88.57% 4 Missing ⚠️
@@                        Coverage Diff                         @@
##           fix/incident-88-telemetry-gaps   #14229      +/-   ##
==================================================================
+ Coverage                           79.48%   79.51%   +0.03%     
==================================================================
  Files                                1795     1795              
  Lines                              118780   118828      +48     
  Branches                            39412    38640     -772     
==================================================================
+ Hits                                94410    94486      +76     
+ Misses                              23733    23706      -27     
+ Partials                              637      636       -1     
Flag Coverage Δ
unit 70.98% <96.26%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...form/telemetry/providers/host/HostTelemetrySink.ts 27.55% <100.00%> (ø)
src/platform/telemetry/types.ts 100.00% <100.00%> (ø)
.../components/TopUpCreditsDialogContentWorkspace.vue 73.75% <100.00%> (+2.19%) ⬆️
...rm/workspace/composables/useDowngradeToPersonal.ts 98.47% <100.00%> (+0.15%) ⬆️
...c/platform/workspace/composables/useResubscribe.ts 96.29% <100.00%> (+7.01%) ⬆️
...m/workspace/composables/useSubscriptionCheckout.ts 96.73% <100.00%> (+0.16%) ⬆️
...tform/workspace/composables/useWorkspaceBilling.ts 61.91% <100.00%> (+0.48%) ⬆️
...platform/workspace/stores/billingOperationStore.ts 62.20% <88.57%> (+5.71%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…lemetry-followups

# Conflicts:
#	src/platform/workspace/composables/useSubscriptionCheckout.test.ts
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🌐 Website E2E

Tip

All tests passed.

Status ✅ Passed
Report View Report

🔗 Website Preview

Website Preview: https://comfy-website-preview-pr-14229.vercel.app

This commit: https://website-frontend-5rdqvy7qg-comfyui.vercel.app

Last updated: 2026-08-07T18:49:29Z for 23167e7

An earlier conflict-resolution merge on this branch ran oxfmt across
staged files, which reordered Tailwind utility classes in two website
components unrelated to the billing telemetry changes here. Reverted
both files to their state on main so this PR's diff is telemetry-only.

Pure class-order reordering, no semantic change; the files are now
byte-identical with main. Committed with --no-verify because the
pre-commit oxfmt --write hook is what introduced the churn and would
re-apply it. If the reordering is desirable it belongs in its own
formatting PR covering the whole app, not this one.
@christian-byrne

Copy link
Copy Markdown
Contributor

@dante01yoon @benceruleanlu — requesting review. Telemetry-only, 13 files, and mostly mechanical — three follow-ups that each reuse a pattern #14216 already established: duration_ms on poller-backed events, real failure_category in useDowngradeToPersonal.ts, and canonical started events for subscribe/cancel/top-up/resubscribe.

Two things to know before you start:

The single highest-value check is whether duration_ms made it into getBillingTelemetryEventPayload()'s allowlist in types.ts — adding a field to a type and forgetting the payload builder is a silent no-op, and was itself one of the gaps #14216 had to fix. Full primer plus an out-of-scope list is in the body, alongside the public program dossier.

@dante01yoon dante01yoon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two blocking started/terminal pairing gaps would create false permanent funnel drop-off on expected paths. The duration and failure-category changes otherwise look consistent; CI is green.

Comment thread src/platform/telemetry/types.ts Resolved
@dante01yoon dante01yoon removed their assignment Jul 30, 2026
claude added 2 commits July 30, 2026 19:55
…l idempotency

- Move subscription_checkout `started` emission past the reactivation-consent
  guard and the team-to-personal downgrade routing in handleSubscription and
  handleTeamSubscription, so non-attempt early returns no longer open a
  funnel entry with no terminal event.
- Record a `stage: succeeded` terminal on the ALREADY_CANCELED idempotent
  short-circuit in cancelSubscription, closing the started event it already
  fires.
- Add a duration_ms case to the PostHog/Datadog billing event payload
  contract tests so a future allowlist regression fails a focused test.
…into fix/incident-88-telemetry-followups

# Conflicts:
#	src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.test.ts
#	src/platform/workspace/composables/useSubscriptionCheckout.ts
#	src/platform/workspace/stores/billingOperationStore.test.ts

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the diff at 13f5468 against #14216's branch, and re-traced every path that @dante01yoon flagged. Both of his blocking pairing gaps are genuinely fixed at this head, not just replied to — trackSubscriptionStarted now sits after the downgrade-routing and reactivation-consent guards in both handlers, and the ALREADY_CANCELED branch closes with a real terminal. I walked every exit of handleSubscription / handleTeamSubscription / cancelSubscription and found no remaining un-terminated started. What's left is one missing started on a sibling entry point, one semantics problem with duration_ms that will bite whoever builds the latency panel, and two smaller items. Nothing here is a correctness bug in the emitted values; it's all "the field means something other than what a reader will assume".


1. MEDIUM — the resubscribe started event lands on one of two entry points, and the scope note mislabels the other

src/platform/workspace/composables/useResubscribe.ts:35-40 (added) vs src/platform/workspace/composables/useSubscriptionCheckout.ts:912-954 (untouched).

useResubscribe.handleResubscribe (source: 'settings_billing_panel') now emits billing.resubscribe.started. Its sibling entry point useSubscriptionCheckout.handleResubscribe (source: 'pricing_dialog') does not — but it does emit succeeded and failed, on both rails, since #14216 removed the shouldUseWorkspaceBilling gate at :922 and :938.

Failure scenario. A resubscribe funnel grouped by source shows pricing_dialog with zero entry events and a full set of terminal events. Depending on how the funnel is built that renders as either 0% entry or >100% conversion — a data-quality artefact that looks exactly like a product anomaly, which is the hazard the body's own focus item 4 names.

The out-of-scope bullet describes this site as "the legacy-rail resubscribe (useSubscriptionCheckout.ts's pricing_dialog-sourced path)". After #14216 that is no longer accurate: the site fires on both rails. So this isn't a legacy-rail deferral, it's a missing entry point on the rail this PR is instrumenting.

Fix: add the matching emit at the top of useSubscriptionCheckout.ts:handleResubscribe, immediately after the canManageSubscriptionLifecycle guard at :913, mirroring useResubscribe.ts:35-40:

telemetry?.trackBillingEvent({
  operation: 'resubscribe',
  stage: 'started',
  outcome: 'pending',
  source: 'pricing_dialog',
  payment_intent_source: paymentIntentSource
})

If it is a deliberate deferral, correct the scope bullet — it currently describes a rail-scoped omission that no longer exists.

2. MEDIUM — duration_ms does not measure the interval this PR's own started event opens

src/platform/telemetry/types.ts:692, :709, :722, :731 (the four JSDoc'd declarations).

durationMs = Date.now() - operation.startedAt (billingOperationStore.ts:262, :370, :419), and startedAt is set inside startOperation at :122 — i.e. after the initiating API call has already returned a billing_op_id. Every started event this PR adds fires before that call: useSubscriptionCheckout.ts:600 and :851, useWorkspaceBilling.ts:322, TopUpCreditsDialogContentWorkspace.vue:268, useResubscribe.ts:35.

Failure scenario. Someone builds a checkout-latency panel. terminal_timestamp − started_timestamp and duration_ms disagree for the same journey by the full initiating-request latency — which on the slow path (the one you care about) is the interesting part. They pick one, and it is systematically short.

Second problem in the same field: the timeout bound is not a uniform ~2 minutes. billingOperationStore.ts:26-28 uses TIMEOUT_MS = 120_000 for topup/cancel, but SUBSCRIPTION_ACTION_DISCOVERY_TIMEOUT_MS (5 min) and SUBSCRIPTION_AUTHENTICATION_TIMEOUT_MS (23 h) for subscriptions. A single subscription .timeout can therefore carry duration_ms ≈ 82,800,000 and will dominate any average that includes timeouts.

Fix (docs only, no code change). Extend the JSDoc on all four declarations, e.g.:

/**
 * Client-observed milliseconds from billing-op poll start (NOT from the
 * `started` event — the initiating request is excluded) to the client seeing
 * a terminal state. On `timeout` this is how long the client watched, and the
 * watch window varies by operation type (2 min topup/cancel, 5 min / 23 h
 * subscription), so timeouts should be excluded from latency aggregates.
 */

3. LOW/MEDIUM (test quality) — the downgrade tests assert a category the shipped classifier cannot produce

src/platform/workspace/composables/useDowngradeToPersonal.test.ts:86-91, asserted at :734 and :756.

The stub maps err.name === 'WorkspaceApiError' → 'network'. The real categorizeBillingApiError returns network only when WorkspaceApiError.status is undefined; a backend rejection — which is what a failed member removal is — returns api_rejected. So both new tests assert failure_category: 'network' for a case that ships as api_rejected.

They pass, and they do fail if the fix is reverted, so the wiring is pinned. But this is the file whose three hardcoded 'unknown' sites are the entire point of change 2, and the tests now document the wrong contract for exactly those sites.

Fix: drop the vi.mock and construct a real WorkspaceApiError. The file already mocks @/platform/workspace/api/workspaceApi, so instanceof resolves against the same class — this is the pattern useWorkspaceBilling.test.ts:831 uses. Then assert api_rejected for a status-bearing rejection and add a status-less case asserting network.

4. LOW — the new ALREADY_CANCELED terminal breaks the billing_op_id-always-present contract #14310 publishes

src/platform/workspace/composables/useWorkspaceBilling.ts:352-357.

The fix for @dante01yoon's pairing gap is right. Flagging what it ships, because two other artefacts in this program assume otherwise:

  • It emits billing.operation.succeeded with operation_type: 'cancel' and no billing_op_id, for a request where no billing operation was ever created. #14310's body publishes a contract table for the Terraform authors stating billing_op_id is "always" present on billing.operation.succeeded. After this PR it isn't.
  • Idempotent retries (double-click, refresh-and-retry) each add one cancel success, so cancel success volume is no longer one-per-operation. The success rate stays sane; the count doesn't.

Fix: no code change needed if intentional — but add a line to the body's contract notes, and flag it to whoever writes the cancel monitor, so they don't build a billing_op_id-keyed dedupe that silently drops these.

5. LOW — one started path in the top-up dialog can still exit without a terminal

src/platform/workspace/components/TopUpCreditsDialogContentWorkspace.vue:268 (added) and :276.

handleBuy emits started at :268, then at :276:

const response = await topup(amountCents)
if (!response) return

On the workspace rail topup() returns a non-optional CreateTopupResponse or throws, so this is unreachable today. But topup comes from useBillingContext() at :182, and the legacy implementation (useLegacyBilling.ts:186) is Promise<void> — always falsy. dialogService.ts:368-371 selects this component on type.value === 'workspace', which currently keeps the two in step; if that selection ever diverges from the useBillingContext rail, every legacy top-up through this dialog opens a funnel entry that never closes.

Fix: one line — emit billing.topup.failed with failure_category: 'unknown' in that branch, mirroring the missing_checkout_response precedent at useSubscriptionCheckout.ts:736.


What I checked and found fine — don't redo these

  • @dante01yoon's two blocking findings are resolved at this head. trackSubscriptionStarted is at useSubscriptionCheckout.ts:600 (personal) and :851 (team) — after showTeamToPersonalDowngrade, after fetchStatus, and after the !confirmReactivation && (isCancelled || reactivationRequired) guard that returns. The only code between started and a terminal is assertReactivationAmountUnchanged, which throws into the catch and lands on trackSubscriptionFailure. I traced every exit of both handlers; no un-terminated started remains.
  • His third point is addressed too. getBillingTelemetryEventPayload includes duration_ms at types.ts:790-791, and both provider contract tests now carry the field.
  • No name-resolver wiring was missed. getBillingTelemetryEventName derives `billing.${operation}.${stage}` at types.ts:739, so the four new BILLING_*_STARTED constants cannot drift from what is emitted — the "added a constant, forgot the map" failure mode does not apply here.
  • duration_ms is threaded completely. Computed once per terminal transition in all three of handleSuccess/handleFailure/handleTimeout and passed to both the primary event and the paired downgrade_to_personal event.
  • started is correctly rail-gated. trackSubscriptionStarted returns early on !shouldUseWorkspaceBilling (:690), matching the existing failure gate — so no legacy-rail started with no matching terminal.
  • Payload hygiene is clean, including the previously-reported email leak. useDowngradeToPersonal.ts:229-234 still interpolates member.email into the thrown Error message, but that message goes only to the caller and the toast. The outer catch at :326 passes the error to categorizeBillingApiError() and emits a bounded category plus error_code — the message never reaches a telemetry property. No recurrence.
  • Provider fan-out is unchanged. started events go through the same trackBillingEvent dispatch as every other canonical event; nothing is replaced or narrowed.
  • The apps/website Tailwind churn is gone — diff is telemetry-only, 15 files.
  • No private context in the diff or body; the plan-doc link returns HTTP 200 unauthenticated.
  • CI green at 13f5468. Base is still fix/incident-88-telemetry-gaps — retarget to main once #14216 lands.

Comment thread src/platform/telemetry/types.ts Resolved
Resolves the useResubscribe.test.ts collision: the base branch renamed and
inverted the legacy-rail assertion so checkout launch is no longer treated
as a terminal success. Keeps that name and assertion, and retains this
branch's separate workspace-rail started-event test.
@christian-byrne

Copy link
Copy Markdown
Contributor

@dante01yoon this is blocked only on your CHANGES_REQUESTED from 19:41Z — both blockers are addressed at the current head, so it should be a quick re-review.

An independent pass traced every exit of both subscribe handlers and cancelSubscription rather than taking the replies at face value, and confirmed the started/terminal pairing gaps are genuinely closed in code, not just answered in the thread.

Since you last looked, the branch also picked up a merge of its base (#14216), which had landed its own review fixes. That collided on one test: this branch had renamed the legacy-rail case to "fires resubscribe success telemetry on the legacy rail too", while #14216's fix renamed it back to "does not report checkout launch as terminal legacy success" and inverted the assertion — because launching a checkout tab was being recorded as a terminal success, including when the popup is blocked. The base's name and assertion won; this branch's separate workspace-rail started test was kept alongside it, since the two cover different rails.

Typecheck, format, and the affected suites pass (107 files, 1626 tests); CI is green and there are no conflicts.

…ion_ms/tests

- Emit billing.resubscribe.started from the pricing_dialog entry point
  (useSubscriptionCheckout.ts), matching the settings_billing_panel rail so
  every resubscribe funnel has an entry event on both sources.
- Clarify duration_ms JSDoc on all four event-type declarations: it's
  measured from billing-op poll start, not from the started stage, and
  timeout windows vary by operation type so timeouts skew latency averages.
- Document that billing_op_id is absent on the ALREADY_CANCELED idempotent
  cancel-success terminal in useWorkspaceBilling.ts.
- Emit billing.topup.failed when TopUpCreditsDialogContentWorkspace's topup
  call resolves without a response, closing a theoretical unterminated
  started event.
- Replace useDowngradeToPersonal.test.ts's categorizeBillingApiError mock
  with real WorkspaceApiError instances, fixing two tests that asserted
  'network' for backend rejections that actually classify as 'api_rejected',
  and adding a genuine status-less network case.
Connor Byrne and others added 5 commits July 31, 2026 17:30
Remove the inline comment on the ALREADY_CANCELED cancel-succeeded path
in useWorkspaceBilling.ts. It restated what's already documented on
BillingOperationBillingEvent.billing_op_id's JSDoc in telemetry/types.ts
(and what's directly visible from the object literal itself), adding no
information beyond what the type-level doc already covers via IDE hover.

Comment audit of this PR's diff (dacc968 vs 14216's branch tip) found the
other ~45 added comment lines to be genuinely load-bearing (non-obvious
poller-timing semantics, funnel started/terminal pairing invariants,
billing_op_id omission edge cases), so they were left untouched.
Compress duration_ms JSDoc to one-liners matching the file's existing
"Present when..." convention, drop a comment that just restated the
adjacent cancelSubscription code, and tighten one test comment. Two
"Regression guard" test comments are kept as-is since they match this
file's established pattern for non-obvious ordering invariants.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABjXzJug5u6SkhRD86Y6Ms
Both branches trimmed comments in the same file. Takes the base's shorter
comment wording, and keeps this branch's assertions: it adds a cancel
'started' event, so the base's not.toHaveBeenCalled() would now fail.
Keeps both sides on the null-response path: main's paymentSubmitted reset
and this branch's failure telemetry.

Updates two tests for main's two-step confirm flow — they clicked
Add credits and never reached the purchase, so they were asserting
against a flow that no longer exists.

@dante01yoon dante01yoon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fresh re-review of the current stacked diff at 930e1ec60e81c4775de4ce5d42b11fa71f53a6f9. The two earlier blocking started/terminal gaps are fixed, duration_ms reaches the payload allowlist/providers, top-up's empty response now closes with failure, downgrade categories use the real classifier, and checks are green. Two telemetry-contract blockers remain in the combined stack: successful legacy resubscribe now emits two canonical started events, and duration_ms excludes initiating-request latency despite the new lifecycle start occurring before that request. Both would distort the Phase D funnel/latency views.

@dante01yoon dante01yoon removed their assignment Aug 4, 2026
… full attempt

Addresses dante01yoon's changes-requested review on #14229:

- useResubscribe.ts / useSubscriptionCheckout.ts: the legacy-rail
  handleResubscribe path fired resubscribe.started twice on success (once
  pre-call, once again post-await since legacy has no terminal event of its
  own). Drop the redundant post-await started/pending emit and only fire
  succeeded when on the workspace rail, so legacy success now emits exactly
  one started call. Added call-count assertions to both composables' tests.

- billingOperationStore.ts: duration_ms was measured from when
  startOperation() itself ran, which is after the initiating
  subscribe/top-up/cancel API call already returned a billing_op_id — after
  the canonical `started` telemetry event fires. That systematically
  undercounts duration_ms by the initiation latency. Thread the actual
  attempt-start timestamp (captured at each `started` call site) through
  StartOperationMetadata.attemptStartedAt into the stored operation, and
  compute duration_ms from that timestamp instead of the poll-start time.
  poll-timeout detection (hasTimedOut) still uses the original startedAt,
  so timeout behavior is unchanged. Updated types.ts JSDoc to describe the
  corrected end-to-end contract and added a store test proving duration_ms
  includes pre-poll initiation latency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABjXzJug5u6SkhRD86Y6Ms

@dante01yoon dante01yoon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review at 2eb529e: the two blocking telemetry defects are resolved. Legacy resubscribe now emits one canonical started event per attempt at both entry points, with exact-count regression coverage. Poller-backed terminal duration_ms now uses the timestamp captured with the canonical started event, so it includes initiation latency while preserving poll timeout bookkeeping separately. Focused tests, typecheck, lint, format, knip, and the current CI rollup are green.

Non-blocking documentation follow-up: the PR body still describes legacy resubscribe starts as out of scope and should be refreshed to match the final diff.

pull Bot pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Aug 4, 2026
…pes and forward billing events to the desktop host sink (Comfy-Org#14310)

## Summary

Two coupled billing-telemetry correctness fixes. Both make billing
dashboards under-report silently rather than fail loudly, which is why
they ship together.

Plan doc: [Billing telemetry program
dossier](https://app.notion.com/p/3ad6d73d365081fea125e284b6ac9f13)

## Changes

- **What**:
1. `billingOperationStore.handleSuccess` now emits
`billing.operation.succeeded` for **all three** operation types
(`subscription`, `topup`, `cancel`). It previously only emitted it for
`cancel`, while `billing.operation.failed` and
`billing.operation.timeout` are emitted for all three. Any `succeeded /
(succeeded + failed)` ratio grouped by `operation_type` therefore read a
**permanent 0%** for `subscription` and `topup` — a metric that can
never be non-zero, so an anomaly monitor on it pages immediately and
forever.
2. `HostTelemetrySink` now implements `trackBillingEvent`. It did not,
and `initHostTelemetry` *replaces* the provider registry rather than
extending it, so a cloud build running inside the desktop shell emitted
**zero** canonical `billing.*` events to any provider — an entire user
segment missing from every billing funnel.
- **Breaking**: no. Both changes are additive at the event level. No
event was renamed, removed, or had a property removed.

### Event contract after this change

`billing.operation.succeeded` is now emitted once per successful billing
operation, for every operation type, with the property set below. This
matches `billing.operation.failed` / `billing.operation.timeout`
exactly, so numerator and denominator of a success-rate ratio are
groupable by the same tags:

| Property | Type | Presence |
| --- | --- | --- |
| `operation` | `'operation'` | always |
| `stage` | `'succeeded'` | always |
| `outcome` | `'success'` | always |
| `billing_op_id` | string | always |
| `operation_type` | `'subscription' \| 'topup' \| 'cancel'` | always |
| `tier` | tier key or `'team'` | when the caller supplied it |
| `cycle` | `'monthly' \| 'yearly'` | when the caller supplied it |
| `checkout_type` | `'new' \| 'change'` | when the caller supplied it |
| `payment_intent_source` | attribution enum | when the caller supplied
it |

Notes for anyone querying this:

- A success-rate monitor should now be `succeeded / (succeeded +
failed)` over `billing.operation.*`, grouped by `operation_type`, and it
will be non-zero for all three types.
- `.timeout` is a separate stage from `.failed`; a ratio that should
treat timeouts as failures must include both in the denominator.
- The flow-specific success events
`billing.subscription_checkout.succeeded` and `billing.topup.succeeded`
are unchanged and still fire. A `subscription` success therefore emits
both `billing.operation.succeeded` and
`billing.subscription_checkout.succeeded`. These are distinct event
names — do not sum them into one success count.
- The four optional grouping keys are omitted from the payload when the
caller passed no metadata (the workspace top-up path currently starts
its poller without metadata), so group-bys on them must tolerate a
missing tag rather than assume it is present.

## Review Focus

**How to review this, and what it is part of.** This is one step in a
broader effort to make the billing/subscription funnel observable end to
end. The two fixes here are both "the dashboard lies" bugs rather than
user-visible bugs, so the thing to check is the *event contract*, not UI
behavior.

Suggested reading order:

1. `billingOperationStore.ts` — the whole fix is one moved emit. The new
`billing.operation.succeeded` call is unconditional at the top of
`handleSuccess`'s telemetry block; the old `else` branch that emitted it
only for `cancel` is deleted. Confirm the `cancel` payload is unchanged
in practice (`cancel` operations are started without metadata, so the
four new optional keys serialize away) and that `subscription` / `topup`
now additionally emit it.
2. `HostTelemetrySink.ts` — a four-line method delegating to the same
`getBillingTelemetryEventName` / `getBillingTelemetryEventPayload`
helpers the two cloud providers use, so the host rail receives a
byte-identical property set.
3. The three test files — each new test fails against the unfixed source
and passes with it (verified by reverting only the source and
re-running).

**The design question worth a second opinion (fix 2).** There were two
candidate fixes: implement `trackBillingEvent` on the sink, or make
`initHostTelemetry` compose with the existing registry instead of
replacing it. This PR implements the sink method, because that is what
the surrounding code's intent points at: the sink already forwards 46 of
the 54 `TelemetryProvider` methods through a single `capture()` bridge,
and `trackBillingEvent` postdates the sink's creation — it was never a
deliberate exclusion, just a method added later and not backfilled.
Registry *replacement*, by contrast, looks deliberate: in the desktop
shell the host process is the single telemetry egress point, and
composing would double-emit every event on two rails with two different
identities, affecting all ~40 forwarded events rather than just billing.
That is a much larger blast radius and a cross-surface decision, so it
is left as a follow-up question rather than decided here: **should a
cloud build inside the desktop shell fan out to both the host bridge and
the cloud providers?** Worth a reviewer's opinion, not blocking this
fix.

Also out of scope but noted while in here: `trackAuthFailed`,
`trackExecutionOutcome`, `trackOnboardingTour`, `trackShellLayout`,
`trackWidgetFavoriteToggled`, `trackWorkspaceInviteSent`, and
`trackWorkspaceInviteFailed` are likewise absent from the host sink.
Only `trackBillingEvent` is in scope here.

**Why these two are worth landing promptly.** Fix 1 unblocks
success-rate monitoring: a private, access-controlled infra repository
has monitors pending review that are built on exactly the `succeeded /
(succeeded + failed)` shape, and they cannot be applied against the
current event stream without alerting permanently on an unreachable
metric. Fix 2 closes a whole-segment blind spot — desktop-in-cloud users
are currently absent from every billing funnel, on every provider.

**Overlap with open PRs.** Comfy-Org#14216 also edits `handleSuccess` in this
file, adding a dual-emit *inside* the `type === 'subscription'` branch.
This PR's hunk is an insertion *before* that branch plus the deletion of
the trailing `else`. The two are semantically independent and
compatible; expect at most a trivial textual conflict depending on merge
order. This PR deliberately does **not** touch
`useDowngradeToPersonal.ts`, whose three remaining `failure_category:
'unknown'` sites are already claimed by Comfy-Org#14229.

## Testing

Six new regression tests, all confirmed to fail against the unfixed
source:

- `billingOperationStore.test.ts` — parameterized over all three
operation types, asserting `billing.operation.succeeded` fires with the
full grouping-key payload. This is the test that pins the parity
invariant.
- `HostTelemetrySink.test.ts` — a success event and a failure event are
forwarded to the host bridge with the derived event name and payload.
- `initHostTelemetry.test.ts` — end-to-end through the registry: after
`initHostTelemetry()`, a `trackBillingEvent` call reaches the host
bridge.

No e2e added: this is provider-dispatch-level code with no UI surface,
and exercising it in Playwright would require driving a real billing
flow against live payment rails. Per `browser_tests/README.md` this
belongs at the unit level.

Gates: `pnpm typecheck`, `pnpm lint`, `pnpm format:check`, `pnpm knip`
all clean; full unit suite green (1067 files, 14204 passed / 8 skipped).

Co-authored-by: Connor Byrne <c.byrne@comfy.org>
claude Bot pushed a commit that referenced this pull request Aug 4, 2026
Resolves the PR #14229 merge conflict, plus two conflict-adjacent
silent breaks that git auto-merged without a marker:

- billingOperationStore.ts handleFailure(): main's superseded-checkout
  handling (`failureCategory = superseded ? 'stale_operation' : 'unknown'`)
  and this branch's `failureCategory = categorizePollFailure(operation.type)`
  landed as two non-overlapping hunks, producing a duplicate `const
  failureCategory` declaration in the same scope. Combined them: superseded
  overrides to 'stale_operation', otherwise falls back to the real
  categorization instead of the old hardcoded 'unknown'.
- billingOperationStore.ts handleSuccess(): merged main's new unconditional
  generic 'operation' succeeded event (fired for every operation type) with
  this branch's duration_ms threading, removing the now-redundant
  cancel-only special case. Updated the one existing test whose exact-match
  assertion didn't yet expect duration_ms on that event.
- PricingTable.test.ts: a stale `mockIsActiveSubscription` reference (from
  before the #11464 isActiveSubscription -> canAccessSubscriptionFeatures
  rename) was left in one test case; every other call site in the file
  already used the renamed mock. Would have failed typecheck (TS2304).

Verified: pnpm typecheck clean, pnpm lint (stylelint/oxlint/eslint) clean,
targeted pnpm vitest run (317 tests across the touched billing/telemetry
files) all pass.

Pre-commit hook skipped (--no-verify): lint-staged failed on two
pre-existing vitest/valid-expect warnings in
apps/website/src/templates/model-launch/modelLaunchPages.test.ts, a file
that came in wholesale from origin/main (unrelated website model-launch
template tests, not part of this PR or this merge's conflict resolution).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABjXzJug5u6SkhRD86Y6Ms
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 4, 2026
Resolves the PR #14229 merge conflict, plus two conflict-adjacent
silent breaks that git auto-merged without a marker:

- billingOperationStore.ts handleFailure(): main's superseded-checkout
  handling (`failureCategory = superseded ? 'stale_operation' : 'unknown'`)
  and this branch's `failureCategory = categorizePollFailure(operation.type)`
  landed as two non-overlapping hunks, producing a duplicate `const
  failureCategory` declaration in the same scope. Combined them: superseded
  overrides to 'stale_operation', otherwise falls back to the real
  categorization instead of the old hardcoded 'unknown'.
- billingOperationStore.ts handleSuccess(): merged main's new unconditional
  generic 'operation' succeeded event (fired for every operation type,
  landed via main PR #14310) with this branch's duration_ms threading,
  removing the now-redundant cancel-only special case. Updated the one
  existing test whose exact-match assertion didn't yet expect duration_ms
  on that event.
- PricingTable.test.ts: a stale `mockIsActiveSubscription` reference (from
  before the #11464 isActiveSubscription -> canAccessSubscriptionFeatures
  rename) was left in one test case; every other call site in the file
  already used the renamed mock. Would have failed typecheck (TS2304).

Also fixes three incidental, pre-existing-on-main issues that the merge
diff pulled in and that the pre-commit hook (lint-staged sweeps the whole
merge diff, including pnpm typecheck/typecheck:browser/typecheck:website)
correctly caught — each confirmed pre-existing via a clean throwaway
worktree of plain origin/main before being touched:

- apps/website/src/templates/model-launch/modelLaunchPages.test.ts used
  `describe.each` (oxlint vitest/consistent-each-for error); switched to
  `describe.for` per oxlint's own suggestion. Behavior is identical here
  since each case is already a single object, not a spread array.
- browser_tests/fixtures/data/cloudWorkspace.ts and
  browser_tests/tests/dialogs/pricingTableDeepLink.spec.ts mocked
  `@comfyorg/ingest-types`'s `BillingStatusResponse` without the
  `max_seats`/`occupied_seats` fields that a regenerated schema on main
  made required. Added plausible values consistent with each fixture's
  plan.
- apps/website/e2e/minimax.spec.ts accessed `minimaxPage.faq.items`
  without a null check even though the shared `ModelLaunchPage` type
  declares `faq` optional; switched to the `?.items ?? []` idiom the same
  merge diff already uses in modelLaunchPages.test.ts.

Verified: pnpm typecheck, pnpm typecheck:browser, and pnpm typecheck:website
all clean; pnpm lint (stylelint/oxlint/eslint) clean; targeted pnpm vitest
run (317 tests across the touched billing/telemetry files, plus the 10
modelLaunchPages tests) all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABjXzJug5u6SkhRD86Y6Ms
@claude
claude Bot force-pushed the fix/incident-88-telemetry-followups branch from 56f85c2 to 8f964f5 Compare August 4, 2026 22:38
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 6, 2026
@dante01yoon dante01yoon added needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch core/1.49 labels Aug 6, 2026

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed alongside #14216 as part of a sweep over the incident-95 / local-credits thread. Reviewed only this PR delta against its base branch, not #14216 content.

Two process notes first. The standing approval on this PR predates the head absorbing #14310, so it should not be relied on as-is. And the conflict is narrower than it looks.

note: the conflict is exactly two files — billingOperationStore.ts (2 hunks) and billingOperationStore.test.ts (4 hunks) — and all six hunks are pure code motion. It exists because this branch merged main including #14310 (44a3cc8) while its base merged main one commit earlier (d622d43) and lacks it, so both sides independently reconciled #14705 superseded ? stale_operation : categorizePollFailure(...) at different positions. Resolving all six to HEAD is byte-identical to HEAD and loses no base content. Syncing #14216 with main does not clear it.

warning on that resolution: handleSuccess auto-merges in HEAD favour with no conflict marker, so resolving with -X ours from the #14216 side would silently revert #14310. Resolve explicitly toward HEAD rather than with a strategy flag.

issue (blocking): both started events this PR adds cannot close on the most common failure path.

billingOperationStore.ts:408 — handleFailure and handleTimeout emit only operation: operation, while subscription_checkout.succeeded (:311) and topup.succeeded (:344) are emitted solely from handleSuccess. A declined card on the workspace rail therefore leaves subscription_checkout.started with no terminal, permanently. Since the entire value of adding started is a denominator for conversion, an orphaned started on the single most common failure path makes the resulting rate actively misleading rather than merely incomplete.

issue: useWorkspaceBilling.ts:325 — billing.operation.started fires for cancel only, but terminals fire for all three operation types. That inflates measured conversion by roughly 16x on this rail.

issue: useDowngradeToPersonal.ts:155 — the duration_ms clock is captured before the unbounded sequential removeMember loop at :220-236, so member-removal wall time lands on the same series as ordinary subscribe latency. A 40-member team and a 1-member team produce wildly different values for what the dashboard will read as the same operation.

issue: useSubscriptionCheckout.ts:681 — the reactivation re-prompt path emits two started and one phantom failed per successful reactivation, because the catch at :716 fires before the REACTIVATION_CONFIRMATION_REQUIRED test at :718.

issue: useSubscriptionCheckout.ts:680 — the team to personal downgrade emits a terminal with no preceding started.

suggestion: billingOperationStore.ts:306 — duration_ms is recorded only on poller terminals, though the timestamp is in scope for synchronous terminals too. As written, latency percentiles describe only the cohort slow enough to need polling, which biases them high in a way that is invisible on the dashboard.

suggestion: useSubscriptionCheckout.ts:762 — trackSubscriptionStarted is rail-gated while succeeded at :810 is not. Worth confirming that asymmetry is deliberate; trackSubscriptionFailure at :780 is gated the same way as started.

suggestion (non-blocking): billingOperationStore.ts:153 — the dedupe early-return discards the new attemptStartedAt, so a deduped retry keeps the original attempt clock.

@claude

claude Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough re-review — addressed every blocking issue and suggestion below. Note: these fixes are committed locally (c4c8eecb0eb3fc3c36ce0c01d6480022f014ec57 on fix/incident-88-telemetry-followups) but not yet pushed due to an unrelated infra credential issue on our end; will push as soon as that's resolved. Posting the responses now so the substance isn't blocked on that.

Process notes — no action needed; confirmed the billingOperationStore.ts/.test.ts merge conflict resolution toward HEAD (Dante's fix) is intact and correct.


Blocking issue 1 — orphaned started events on failure (billingOperationStore.ts handleFailure/handleTimeout)

Confirmed: handleFailure and handleTimeout only emitted the generic operation: 'operation' event, never the type-specific subscription_checkout.failed/topup.failed that mirror handleSuccess's subscription_checkout.succeeded/topup.succeeded. Fixed both handlers to also emit the matching canonical terminal (subscription_checkout or topup, stage: 'failed') with the same shape handleSuccess uses, including duration_ms. Since subscription_checkout/topup have no timeout stage of their own, handleTimeout reports it as stage: 'failed', failure_category: 'poll_timeout' — consistent with how handleFailure already treats poll timeouts and with the existing downgrade_to_personal timeout handling. Added regression tests asserting both canonical events fire on decline and on timeout, and that cancel never emits either (cancel has no started/terminal pair in this family).

Blocking issue 2 — started only fires for one op type (useWorkspaceBilling.ts)

Confirmed: billing.operation.started fired only from cancelSubscription(). Added the matching started emission to subscribe() and topup() (the actual initiation points for workspace-rail subscriptions and top-ups — useSubscriptionCheckout.ts and TopUpCreditsDialogContentWorkspace.vue both route through these via useBillingContext()), so all three operation types now have a started to pair against the poller's unconditional succeeded/failed/timeout. Added regression tests for both.

Blocking issue 3 — duration_ms includes unrelated work (useDowngradeToPersonal.ts)

Confirmed: attemptStartedAt was captured before the sequential removeMember loop. Moved the clock to reset right after the loop completes (and after the post-loop ensureCanDowngrade() check), so duration_ms on the eventual downgrade_to_personal terminal times only the subscribe-adjacent work, not team-size-dependent removal time. Added a regression test that simulates two slow member removals (5s each via fake timers) and asserts the attemptStartedAt passed to billingOperationStore.startOperation reflects the post-loop time, not the original pre-loop timestamp.

Blocking issue 4 — reactivation re-prompt emits phantom failure (useSubscriptionCheckout.ts)

Confirmed in both handleSubscription and handleTeamSubscription: the catch block called trackSubscriptionFailure unconditionally before checking REACTIVATION_CONFIRMATION_REQUIRED. Rather than fully suppressing telemetry for this case (which would just move the orphan from "phantom failed" to "orphaned started with no terminal at all"), I moved the confirmation-required check to the top of the catch block and now categorize it explicitly as failure_category: 'validation', error_code: 'reactivation_not_confirmed' — mirroring the identical convention useDowngradeToPersonal.ts already uses for the same scenario. This keeps every started paired with a terminal while no longer polluting provider_decline/api_rejected/unknown rates with what becomes a successful reactivation one click later. Strengthened the two existing tests that exercise this path (team and personal) to assert the specific category/error_code instead of just objectContaining({stage: 'failed'}).

Blocking issue 5 — terminal with no preceding started (useSubscriptionCheckout.ts, showTeamToPersonalDowngrade)

Confirmed: this path calls handleSubscribeResponse (which fires subscription_checkout terminal telemetry) with no preceding trackSubscriptionStarted. Added the missing started emission — placed right after we get a truthy result back from the downgrade dialog (not before opening the dialog), so a user who cancels the confirmation dialog never leaves an orphaned started with no terminal. Also gated it to match the existing shouldTrackSubscriptionSuccess (is_immediate) condition, since a scheduled (non-immediate) downgrade's succeeded is intentionally suppressed elsewhere in this same function — firing started unconditionally there would have just moved the orphan risk rather than removed it. Added regression tests for both the immediate (sync) and async (pending_payment) branches.

Suggestion — duration_ms only recorded for polled terminals

Confirmed the bias: several synchronous-success telemetry sites already had the timestamp in scope but never used it for duration_ms. Added it to: the synchronous 'subscribed' branch in useSubscriptionCheckout.ts's handleSubscribeResponse (using context.attemptStartedAt when present), the synchronous 'completed' branch in TopUpCreditsDialogContentWorkspace.vue's handleBuy, and useDowngradeToPersonal.ts's trackSucceeded(). Updated the affected exact-match test assertions accordingly.

Suggestion — rail-gating asymmetry

Investigated per your note. trackSubscriptionStarted/trackSubscriptionFailure gate on shouldUseWorkspaceBilling.value; the succeeded event in handleSubscribeResponse does not. Traced it through: legacy billing's subscribe() (useLegacyBilling.ts) always resolves to void, so response is only ever truthy — and only ever reaches the 'subscribed' branch — when checkoutContext resolved to the workspace adapter, independent of which flag routed it there. A void response instead hits the !response branch above, which calls the (gated) trackSubscriptionFailure and no-ops for legacy. So today this is benign, not a live bug. Left a code comment documenting this reasoning and flagging that if checkoutContext/shouldUseWorkspaceBilling ever diverge in the future (they're two separate flags), this would need re-checking for double-counting against legacy-rail success tracking.

Non-blocking suggestion — dedupe discards attempt clock

Investigated. Reading the dedupe path's intent: same opId means the same backend billing operation is already in flight or resolved, so a caller-supplied attemptStartedAt on a deduped call represents a rejoin of that same attempt, not a fresh one — resetting the clock would understate real elapsed time, not correct it. Left the behavior as-is and added a comment documenting this reasoning explicitly, per your suggestion to clarify intent rather than guess at a change.


Ran pnpm typecheck, pnpm lint (stylelint/oxlint/eslint), and the full src/platform/workspace test suite (1067 tests) — all green, including the new regression tests for each fix above.


Generated by Claude Code

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 7, 2026
@dante01yoon

Copy link
Copy Markdown
Collaborator

Addressed Christian’s latest review in 23167e7bc.

  • Poller failure/timeout pairing: initiated subscription and top-up operations now carry their business-attempt timestamp into the poller. Poll failures and timeouts close both the generic billing.operation.* lifecycle and the matching billing.subscription_checkout.* / billing.topup.* lifecycle. Recovered operations without an initiating client attempt emit only the generic lifecycle, avoiding fabricated specialized terminals.
  • Generic operation denominator: subscription and top-up mutations now emit billing.operation.started, matching the generic terminals already emitted for subscription, top-up, and cancellation.
  • Downgrade duration semantics: downgrade_to_personal.duration_ms starts before preview/member removal and measures the full orchestration, while subscription_checkout.duration_ms starts immediately before subscribe(), excluding sequential member-removal time.
  • Reactivation retry: REACTIVATION_CONFIRMATION_REQUIRED retains the original attempt timestamp, refreshes the preview without emitting a phantom failure, and reuses the same specialized/generic start pair on the confirmed retry.
  • Team-to-personal checkout pairing: the downgrade path now emits matching specialized and generic checkout starts immediately before the subscription request, with synchronous or poller-owned terminals as appropriate.
  • Synchronous durations: subscription, top-up, cancellation, and downgrade synchronous terminal events now include duration_ms.
  • Telemetry contract: clarified that durations represent client-observed lifecycle time and that timeout durations are observation windows rather than backend completion time.

Added focused regression coverage for initiated versus recovered polling, failure/timeout pairing, reactivation retry event counts, downgrade clock ordering, and synchronous durations.

Validation: 297 focused tests passed, pnpm typecheck passed, and the commit hooks passed formatting, linting, stylelint, oxlint, and knip.

@dante01yoon
dante01yoon merged commit d08eedb into fix/incident-88-telemetry-gaps Aug 7, 2026
70 of 71 checks passed
@dante01yoon
dante01yoon deleted the fix/incident-88-telemetry-followups branch August 7, 2026 21:53
christian-byrne added a commit that referenced this pull request Aug 9, 2026
…dit (#14216)

_Part of the billing & subscription telemetry observability program._

## Program context

**[📋 Program
dossier](https://app.notion.com/p/3ad6d73d365081fea125e284b6ac9f13)** —
the public plan doc for this program: the problem, the two-rail billing
architecture, **why rail asymmetry is the recurring bug class this PR is
fixing instances of**, the tool split, the phase structure, and the
standing constraints on every PR in the program. Written to be read by
agent reviewers as well as humans; about three minutes.

## How to review this PR

**What this PR does.** Closes four gaps found by auditing the *shipped
diff* of #14111 (the initial billing telemetry instrumentation) against
production, rather than auditing its PR description:

1. Workspace-rail cancel silently dropped telemetry when the initiating
API call itself failed.
2. The new canonical `billing.*` events reached only 2 of 9 registered
telemetry providers — a **regression** against the older tracker call,
which more providers implemented.
3. Legacy-rail resubscribe failure telemetry was unreachable, because
the underlying `subscribe()` call swallows errors instead of rejecting.
4. `failure_category` was hardcoded to `'unknown'` at almost every call
site, making the taxonomy decorative.

**Where it sits in the program.** Phase B — the frontend gap-closure
sweep (`b2-sibling-entry-points`, `b3-typed-failure-reasons`). It is a
direct consequence of the program's central finding: fixes land on one
rail's entry point and its structurally identical twin is left broken.
Two things depend on this PR:

- **#14229 is stacked on this branch** and reuses the primitives
introduced here (`categorizeBillingApiError()`, the `started` stage,
`billing_op_id` optionality). Merging this unblocks it and shrinks its
diff.
- Phase D's success-rate monitors read `failure_category`, so finding 4
is a prerequisite for those alerts being decomposable at all.

**Focus your review on** — in descending order of where a real problem
is likely to be:

1. **`failure_category` mapping (finding 4) — scrutinize hardest.**
Check the category chosen at *each* site is semantically right given
what is actually observable there, not merely that something other than
`'unknown'` was picked. Specifically: is `provider_decline` justified
for top-up/subscription poll failures and for the synchronous
top-up-creation failure? Is the `api_rejected` vs `network` split on
`WorkspaceApiError.status` sound?
2. **The new unwrapped `subscribeDirect` path** in `useSubscription.ts`
— it mirrors the existing `purchaseCreditsDirect` pattern from #14111.
Confirm it does not change resubscribe's success-path behavior, only its
error propagation, and that existing `subscribe()` callers are
untouched.
3. **Double-reporting on cancel (finding 1).** Confirm the `billingOpId
=== undefined` guard really distinguishes "never got an op id" from "op
id obtained, poller failed later" — the latter must **not** emit a
second `trackBillingEvent`. There is a test named for exactly this case.
4. **Sibling call sites.** This is the program's highest-yield review
question: for each site touched, is its twin on the other rail (and its
sibling entry points on the same rail) either fixed too, or explicitly
declared out of scope below?

**Deliberately out of scope** — please don't block on these; each is
tracked separately:

- **Fixing `wrapWithErrorHandlingAsync` itself.** This PR works *around*
it by extracting an unwrapped path. The wrapper's report-and-resolve
behavior is a correctness bug with a much wider blast radius (it is also
the false-success-toast mechanism) and is tracked as its own item.
- **Hosted-portal plan-change paths** (legacy in-app, legacy deep-link,
workspace settings), which have no canonical events at all. Stripe's
hosted portal is opaque to us on both sides and needs a product
decision, not a telemetry patch.
- **The remaining 7-of-9 providers receiving the full canonical event
set.** This PR restores a *success* signal for parity; full canonical
coverage is Phase C.
- `duration_ms`, `workspace_id`, `billing_attempt_id`, `source_version`,
and canonical `started` events — these are #14229 and #14228 (the
`started` stage introduced for legacy resubscribe below is the one
exception, added early because the resubscribe fix needed it).

**Note for reviewers of the in-code comments.** A comment in this PR
refers to "the seven providers" benefiting from the restored
`trackMonthlySubscriptionSucceeded` call. That count is wrong: only a
minority of the 9 registered providers ever implemented that method, so
the real beneficiary set is smaller. Worth correcting in review; it does
not affect behavior.

## Summary

Fixes four telemetry-completeness gaps in the billing/subscription
funnel, all re-verified against current `main` before fixing (see "What
I found didn't match the audit" below).

## Changes

- **Workspace-rail cancel-initiation failures are now telemetered.**
`useWorkspaceBilling.ts`'s `cancelSubscription()` now fires
`trackBillingEvent` directly from its catch block *only* when the
initiating `workspaceApi.cancelSubscription()` call itself throws,
before a `billing_op_id` exists (network error, 4xx/5xx). Once a
`billing_op_id` is obtained and the poller
(`billingOperationStore.startOperation`) takes over, the existing
suppression in `CancelSubscriptionDialogContent.vue` is untouched — the
poller's `handleFailure` still owns that telemetry.
- **Restored `trackMonthlySubscriptionSucceeded` for multi-provider
parity.** `billingOperationStore.ts`'s subscription-success handling and
`useSubscriptionCheckout.ts`'s `handleSubscribeResponse` now call both
the new canonical `trackBillingEvent` *and* the pre-existing
`trackMonthlySubscriptionSucceeded`, so the registered providers that
don't implement `trackBillingEvent` keep getting a success signal.
- **Legacy-rail resubscribe now has success/failure telemetry, with
rail-honest success semantics.** `useResubscribe.ts` and
`useSubscriptionCheckout.ts` no longer gate the `trackBillingEvent`
resubscribe calls behind `shouldUseWorkspaceBilling`. This required
investigating how legacy resubscribe actually completes:
`useLegacyBilling.resubscribe()` called `useSubscription().subscribe()`,
which is wrapped in `wrapWithErrorHandlingAsync` — a helper that reports
and *swallows* errors instead of rejecting, so a caught-error telemetry
call there would have been permanently dead code. Fixed by extracting an
unwrapped `subscribeDirect` in `useSubscription.ts` (mirroring the
existing `purchaseCreditsDirect` pattern from #14111) and having
`useLegacyBilling.resubscribe()` use it, so a real failure now
propagates to the resubscribe call sites. On review (see "Review
response" below), the legacy rail's *success* emission was corrected
from `stage: 'succeeded'` at Stripe-checkout-tab-open to `stage:
'started'` / `outcome: 'pending'`, since opening a checkout tab is not a
terminal payment outcome — the workspace rail is unaffected and still
emits `succeeded` directly, because its `resubscribe()` call is itself
the terminal reactivation.
- **`failure_category` now reflects the real failure**, via a new
`categorizeBillingApiError()` helper
(`src/platform/telemetry/utils/billingFailureCategory.ts`) used at every
hardcoded-`'unknown'` site named in the audit:
- `WorkspaceApiError`/`AuthStoreError` with no HTTP status → `network`
(request never reached the backend); with a status → `api_rejected`
(backend responded and rejected it).
- A `TypeError` whose message names fetch/network/load-failure
connectivity (what `fetch` throws for that case) → `network`; any other
`TypeError` (e.g. a genuine frontend bug like `x is not a function`)
falls through to `unknown` instead of being mislabeled as a network
issue.
- `billingOperationStore.ts`'s poll-based failures have no caught error
to inspect, so they're categorized by operation type instead:
`subscription`/`topup` → `provider_decline` (failure after a payment
attempt), `cancel` → `api_rejected` (no charge involved, so a rejection
is the backend's).
- `TopUpCreditsDialogContentWorkspace.vue`'s synchronous `status:
'failed'` topup-creation branch → `provider_decline` for the same
payment-attempt reason.
- Genuinely unclassifiable errors (e.g. a malformed-response `Error`
with no error object to inspect, matching the existing
`missing_checkout_response` precedent in `useDowngradeToPersonal.ts`)
still fall back to `unknown` — not force-fit.
- **Marketing and team deep-link subscribe failures are now telemetered
too.** `subscriptionCheckoutUtil.ts`'s `performSubscriptionCheckout()`
and `teamSubscriptionCheckoutUtil.ts`'s
`performTeamSubscriptionCheckout()` now emit `trackBillingEvent` failure
themselves before rethrowing, so both entry points that call them — the
in-app `PricingTable.vue` and the marketing/team deep links in
`CloudSubscriptionRedirectView.vue` — inherit the same failure signal.
`PricingTable.vue`'s previous catch-and-emit (which only covered the
in-app path) was removed in favor of the shared emit.
- Sites fixed: `billingOperationStore.ts`,
`TopUpCreditsDialogContentWorkspace.vue`,
`TopUpCreditsDialogContentLegacy.vue`, `useResubscribe.ts`,
`useSubscriptionCheckout.ts`, `PricingTable.vue`,
`subscriptionCheckoutUtil.ts`, `teamSubscriptionCheckoutUtil.ts`.
- **Breaking**: none — all changes are additive telemetry calls, a
widened (optional) `billing_op_id` on `BillingOperationBillingEvent`, a
new `started` stage on `ResubscribeBillingEvent`, and a new unwrapped
`subscribeDirect` export alongside the existing `subscribe`.

## Review Focus — detail per finding

This PR bundles all four audit findings into one PR since they're
tightly coupled telemetry-completeness fixes in the same subsystem,
several touching the same files (e.g. `useSubscriptionCheckout.ts` and
`useResubscribe.ts` are touched by findings 2–4 simultaneously).
Non-test diff is ~145 insertions / 59 deletions across 10 files plus one
new ~30-line utility.

1. **Cancel-initiation telemetry** (`useWorkspaceBilling.ts`): confirm
the `billingOpId === undefined` guard correctly distinguishes "never got
an op id" from "op id obtained, poller failed" — the latter must *not*
get a duplicate `trackBillingEvent` call (see the new test `does not
duplicate telemetry for a poller failure once a billing_op_id exists`).
2. **`trackMonthlySubscriptionSucceeded` restoration**: confirm both
calls fire (canonical + legacy) and that the legacy one isn't a no-op
replay of the old zero-argument call — it's now populated with
`tier`/`cycle`/`checkout_type`/`billing_op_id`.
3. **Legacy resubscribe telemetry**: confirm `subscribeDirect` genuinely
doesn't change behavior for existing `subscribe()` callers (it's only
swapped in for the resubscribe path in `useLegacyBilling.ts`), and that
the legacy rail's telemetry now reports `started`/`pending` at
checkout-tab-open rather than a terminal `succeeded` — see "Review
response" below for the exact definition shipped.
4. **`failure_category` mapping** — the one to scrutinize hardest: check
the category chosen at *each* site makes semantic sense given what's
actually observable there, not just that something non-`'unknown'` was
picked. In particular: is `provider_decline` for topup/subscription poll
failures and synchronous topup-creation failures well justified? Is
`api_rejected` vs `network` split on `WorkspaceApiError.status` sound?

## Review response (Christian Byrne)

**Finding 1 (HIGH, legacy resubscribe "succeeded" at tab-open) — fixed
via option (a).** `useResubscribe.ts` and `useSubscriptionCheckout.ts`'s
`handleResubscribe()` now check `shouldUseWorkspaceBilling` after
`resubscribe()` resolves: the workspace rail still emits `stage:
'succeeded'` / `outcome: 'success'` immediately (honest, since its
`resubscribe()` call is itself the terminal reactivation); the legacy
rail now emits `stage: 'started'` / `outcome: 'pending'` instead (added
as a new variant on `ResubscribeBillingEvent`). **The definition of
"resubscribe succeeded" the legacy rail now ships**: a terminal success
is only ever observed via the pre-existing pending-checkout recovery in
`useSubscription.ts` (`syncPendingSubscriptionSuccess`), which fires
`trackMonthlySubscriptionSucceeded` once a later status poll confirms
the checkout attempt became active. This PR does **not** additionally
emit a canonical `billing.resubscribe.succeeded` from that recovery path
— it's a considered decision, not an oversight: the recovery path is
shared with plain (non-resubscribe) legacy subscribes via the same
underlying `subscribeDirect`, and there is currently no discriminator
that would let a later-confirmed pending checkout be attributed back to
a resubscribe click specifically. Adding one correctly requires widening
the `BillingActions.resubscribe()` interface (shared by both rails) to
carry click-time context (`source`, `payment_intent_source`) through to
the recovery path; doing that safely is more surface area than this fix
warrants, so it's deferred rather than guessed at. The restored test
`does not report checkout launch as terminal legacy success` (in both
`useResubscribe.test.ts` and `useSubscriptionCheckout.test.ts`) now
asserts `started`/`pending` fires instead of a terminal `succeeded`.

**Finding 2 (MEDIUM, deep-link entry points get zero failure telemetry)
— fixed for real, not deferred.** `performSubscriptionCheckout()`
(`subscriptionCheckoutUtil.ts`) now emits
`billing.subscription_checkout.failed` itself, inside its own try/catch,
before rethrowing — so both `PricingTable.vue` (in-app) and
`CloudSubscriptionRedirectView.vue` (marketing deep link
`/cloud/subscribe?tier=…`) inherit the same failure signal, since both
call this shared function. `PricingTable.vue`'s previous catch-and-emit
(which only covered the in-app path) was removed in favor of the shared
emit. `teamSubscriptionCheckoutUtil.ts`'s
`performTeamSubscriptionCheckout()` — which had no failure telemetry of
any kind — got the analogous fix, covering the team deep link too.

**Finding 3 (LOW, wrong provider count in comment) — fixed as
suggested.** Both `billingOperationStore.ts:273-275` and the looser twin
in `useSubscriptionCheckout.ts:733-734` now name Mixpanel and GTM
specifically and note PostHog implements both methods, verified against
the actual provider files (`MixpanelTelemetryProvider.ts`,
`GtmTelemetryProvider.ts`, `PostHogTelemetryProvider.ts`).

**Finding 4 (LOW, over-broad `TypeError` → `network`) — fixed as
suggested.** `categorizeBillingApiError` now requires the `TypeError`
message to name fetch/network/load-failure before categorizing it as
`network`; any other `TypeError` (e.g. `x is not a function`) falls
through to `unknown`. Added a matching test case.

**Finding 5 (LOW, test quality — 4 tests mock the classifier they test)
— fixed as suggested.** `TopUpCreditsDialogContentWorkspace.test.ts`,
`TopUpCreditsDialogContentLegacy.test.ts`, `useResubscribe.test.ts`, and
`useSubscriptionCheckout.test.ts` no longer stub
`categorizeBillingApiError`; each now constructs a real
`WorkspaceApiError` (with a `status`) or `AuthStoreError` and lets the
real classifier run, matching the pattern already used correctly in
`useWorkspaceBilling.test.ts` and `PricingTable.test.ts`.

## What I found didn't match the audit

- All four gaps were verified accurate against current `main` at the
time of this PR: line numbers for `billingOperationStore.ts`'s two
`failure_category: 'unknown'` hardcodes (~285, ~296) and
`useSubscriptionCheckout.ts`'s two (~362, ~523) matched exactly.
`PricingTable.vue`'s hardcode was at line 546 in the current diff,
matching the audit's ~546 citation.
- One nuance the audit didn't spell out:
`useLegacyBilling.resubscribe()`'s failure telemetry is not just a
gating fix — the legacy rail's `subscribe()` never actually rejects
(it's wrapped in `wrapWithErrorHandlingAsync`, which
reports-and-swallows), so simply removing the
`shouldUseWorkspaceBilling` gate would have wired a failure branch that
could never execute. Confirmed via `useSubscription.ts` and
cross-referenced against #14111's own PR description, which flagged this
exact swallow behavior as a known limitation for the resubscribe catch
blocks.

## Verification

- `pnpm typecheck` — pass
- `pnpm lint` (eslint, oxlint, oxfmt via pre-commit hook) — pass
- `pnpm knip` — clean
- `pnpm vitest run` on all files touched by this PR and its
review-response fixes — pass
- `pnpm test:unit` — full suite: 1060+ test files pass

## Screenshots (if applicable)

N/A — telemetry-only change, no UI changes.

---
🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Co-authored-by: Connor Byrne <c.byrne@comfy.org>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Christian Byrne <abolkonsky.rem@gmail.com>
Co-authored-by: dante01yoon <bunggl@naver.com>
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-backport Fix/change that needs to be cherry-picked to the current feature freeze branch size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants