Skip to content

OPE-157: Capture API errors in product Analytics #463

Open

Description

@ivanfenenko

Capture consented, redacted HTTP/API failures in product Analytics so v1/v2 protocol issues are visible in Firebase without USB logs or Diagnostic Logs export.

Today Crashlytics is fatals only. Product Analytics (product_user_action) has a few outcome=failure events (connect, rename, fork) and no method/path/status. Handled 4xx/5xx, transport, and decode errors never leave the device.

Triggered by live validation of OPE-146 (#172): wrong v2 routes and projector/stream failures will not show in Crashlytics. (The v2 archive 404 is now produced on the device and is excluded below.)

What to build

One new consented product event, fired from the HTTP/repository seam (not Screen Models), on iOS and Android:

Event Purpose
product_api_error A product-used API call failed (HTTP 4xx/5xx, transport, or decode)

Required params (enums / bounded strings only):

  • protocol — v1 | v2
  • method — GET | POST | PUT | PATCH | DELETE
  • route — normalized template, never a live URL. Example: /api/session/{id}/prompt, /session/{id}/prompt_async. Strip host, query (directory, location), and ids.
  • status_code — numeric string (404, 500) or 0 for transport/decode with no HTTP status
  • error_class — http | transport | decoding

Optional:

  • duration_bucket — coarse enum only (lt_1s, lt_5s, lt_30s, gte_30s) if cheap; skip if not

Wire through existing OpenCodeReleaseObservability.logProductEvent (consent + Debug no-op). Feature UI still must not import Firebase.

Instrument at the shared HTTP clients / domain error adapters so every product-used remote is covered (session, message, event subscribe open, permission, question, command, agent, model, project, filesystem, vcs). Do not wait for a user tap.

Privacy (hard bans)

Same contract as OPE-124 / OPE-125:

  • No host, server URL, worktree, query string, request/response body, prompt text, session/message ids, credentials
  • route is a static template map (or path-id scrubber with tests). If a path cannot be mapped, send route=unknown — do not send the raw path
  • No Crashlytics recordException for these (noise + easier to leak). Analytics only
  • Respect product-Analytics consent (OPE-129)

Do not fire

Expected client-side skips: V2SessionRemote (iOS and Android) throws a synthetic 404 without a network call for these v2 operations. Skip them by error origin, not by status code, so a real 404 from the server still emits:

  • session todos (event-only seed)
  • session message diff (last-turn capability gate)
  • session archive
  • session init
  • session share / unshare

Also skip: HTTP 2xx, SSE idle disconnects that reconnect cleanly, probe failures already covered by connection-setup outcome=failure (optional: include probe HTTP failures if they are not already distinct).

Throttle: at most one event per {protocol, method, route, status_code} per process minute so a reconnect loop cannot flood Firebase.

Out of scope

  • Logging successes / latency histograms
  • Expanding Diagnostic Logs retention
  • Crashlytics non-fatals for API errors
  • Store privacy form rewrite (operator follow-up only if Firebase event volume/disclosure needs a second pass)

Acceptance criteria

  • Shared product_api_error name + params on iOS and Android via the observability seam
  • Product-used remotes emit on real HTTP/transport/decode failure
  • Route templates never include host, ids, or query; unit tests cover scrubbing
  • v2 synthetic 404s (todos, message diff, archive, init, share/unshare) do not emit; a real server 404 on the same route still does
  • Debug builds never send; Release requires Analytics consent
  • Throttle documented and tested
  • Event name, params, and privacy rules recorded on this issue and in code comments next to the ProductAnalytics constants (docs/features/release-observability/ no longer exists)

Related: OPE-124 taxonomy, OPE-146 server API v2.


Imported from Linear OPE-157. Linear status: Backlog. Priority: Medium. Created 2026-08-13.
Related: OPE-124, OPE-125, OPE-129, OPE-146.

Activity

  1. self-assigned this
    on Oct 11, 2026
  2. added
    ios
    android
    shared
    improvement
    backlog
    priority: medium
    on Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

androidbacklogimprovementiospriority: mediumshared

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions