# Troubleshooting

> Why events, errors, flags, traces or replays are missing and what to do - self-checks, debug output per SDK, every status code AppHelm answers, consent, origins, ad blockers, CORS, clocks and stack traces.

Source: https://apphelm.dev/docs/troubleshooting

Start with the self-checks: they answer most questions in a minute. Then find your symptom below. Every refusal from AppHelm has the shape `{ "error": { "code": "…", "message": "…" } }`, and the `code` is what the tables on this page are keyed by.

## Self-checks

### Check connection in Setup
**Check connection** in Setup (`/app/onboarding`) shows the newest event that reached the product. If it shows one, AppHelm is receiving and the problem is further along (a filter, a dashboard, the wrong product). If it shows none, the SDK is not sending, or AppHelm is refusing what it sends.

### Read the setup checks
Setup lists what the product's own data says about the installation: whether events are arriving, whether the browser SDK is sending, whether events carry a person's id, whether customer profiles are on, whether an outcome is approved and recorded. Each check that needs attention links to its fix.

### Turn on debug output
Every SDK except React Native can print why it is not sending, which requests AppHelm refused (with the status), and what a filter or `beforeSend` dropped. It never prints event contents.

| Platform | Turn it on | Where it writes |
| --- | --- | --- |
| Browser and web frameworks | `debug: true` | `console.warn`, prefixed `[AppHelm]` |
| Node.js | `debug: true` | `console.warn`, prefixed `[AppHelm]` |
| React Native | No option; use `onCapture((name, properties) => …)` and the network inspector | |
| iOS | `options.debug = true` | Unified log, subsystem `dev.apphelm`, category `sdk` |
| Android | `debug = true` in `ApphelmConfig` | Logcat, tag `Apphelm` |
| Flutter | `debug: true` | `debugPrint` |
| JVM | `debug = true` | Standard error, or `debugLogger` |
| Python | `debug=True` | Standard error |
| Go | `Debug: true` | `DebugWriter` (standard error) |
| Ruby | `debug: true` | `$stderr`, prefixed `[apphelm]` |
| PHP | `debug: true` | PHP's `error_log`, or `debugOutput` |
| .NET | `Debug = true` | Standard error, or `DiagnosticLogger` |
| Rust | `.debug(true)` | Standard error, prefixed `[apphelm]` |
| Elixir | `debug: true` | `Logger`, at `:info` |

The browser SDK's debug output says one of these first:

| Message | Meaning | What to do |
| --- | --- | --- |
| `waiting for analytics consent` | `setConsent({ analytics: true })` has not been called | Call it from your consent banner, or pass `consent` in the options |
| `this browser sends Global Privacy Control` | The visitor opted out in the browser | Nothing: AppHelm honours it. Test in a browser without GPC. |
| `enabled is false` | The `enabled` option is `false` | Set it to `true` outside tests |
| `POST /api/events was refused: 401` | Wrong key, revoked key, or the page's origin is not on the key | See [Origins](#origins-and-browser-keys) |
| `… could not be sent (network error or blocked)` | The request never reached AppHelm | See [Ad blockers and networks](#ad-blockers-and-networks) |

## No events arriving

**Only for JavaScript (browser), React, Next.js, Vue / Nuxt, Svelte / SvelteKit:**

**Browser**

1. **Consent.** Nothing is recorded or stored until analytics consent is given. Check `apphelm.getConsent()` in the console: `analytics` must be `true`.
2. **Origin.** The page's origin (scheme, host and port) must be one of the browser key's origins exactly. `http://localhost:3000` and `http://localhost:5173` are different origins, and so are `example.com` and `www.example.com`.
3. **The right key.** Browser code needs the `ahl_pub_…` key. A server key in the browser is refused, and must never be shipped anyway: revoke it.
4. **Environment variables at build time.** Framework variables are inlined when you build: `NEXT_PUBLIC_…` for Next.js, `VITE_…` for Vite, `PUBLIC_…` for SvelteKit. A variable added after the build is not in the bundle; rebuild.
5. **Server rendering.** The client only starts in the browser. Code that runs only on the server sends nothing through the browser SDK; use the server SDK there.
6. **Headless browsers.** Requests from headless browsers (`HeadlessChrome`, Playwright, Puppeteer, Selenium, Lighthouse) are answered `202` with `bot_filtered` and not stored. Check from a normal browser.
7. **Your own network.** If the workspace marked your network as internal, its traffic is answered `202` with `internal_traffic` and not stored.
8. **The network panel.** Look for `POST https://apphelm.dev/api/events`. A `202` with `"accepted": true` means it arrived. Other answers are explained under [Status codes](#status-codes).

**Only for Node.js, Python, Java / Kotlin (JVM), Go, Ruby, PHP, .NET (C#), Rust, Elixir, HTTP (curl):**

**Servers**

1. **The process exits first.** SDKs that queue (Go, Ruby, .NET, Rust, Elixir, Python with `init`, JVM) send in the background. A script, job or serverless function that ends without `flush` or `close` loses what was queued. See [Install and configure](https://apphelm.dev/docs/install#flush-and-shut-down).
2. **The key and its scope.** Events need a server key with `events:write`, for this product. `401 unauthorized` is the key; `403 scope_denied` the scope; `403 product_scope_denied` the product.
3. **The ids.** `workspaceId` and `productId` must be the key's: otherwise `403 scope_mismatch`. A missing one is `422 missing_fields`.
4. **Errors you do not see.** Node rejects the call's promise with an `ApphelmError`; the plain Python client raises; Go, Ruby, .NET, Rust and Elixir pass refusals to `OnError`/`on_error`, which discards them unless you set it; PHP returns `false` and calls `onError`. Set the error callback or `debug` while you set up.
5. **`enabled` is false.** A switch meant for tests can be left on in production. Every SDK answers dropped captures without a request when `enabled` is false.
6. **Laravel and Symfony** send nothing when `APPHELM_API_KEY` (or `api_key`) is empty.

**Only for React Native / Expo, iOS (Swift), Android (Kotlin), Flutter:**

**Mobile apps**

1. **The key.** Apps use a server key with `events:write` only. Check it reached the build: `BuildConfig.APPHELM_API_KEY` on Android, `--dart-define=APPHELM_KEY=…` on every `flutter run` and `flutter build`, `EXPO_PUBLIC_APPHELM_KEY` before the bundle is built.
2. **Opted out.** An `optOut()` is remembered across launches, and `defaultOptIn: false` (React Native, Flutter), `defaultOptedOut = true` (iOS) or `optOut = true` (Android) starts opted out. Check `isOptedOut` (a property on iOS, Android and Flutter; `await isOptedOut()` on React Native).
3. **The queue has not been sent yet.** Events are sent every 30 seconds, when 20 are waiting, and when the app goes to the background (React Native needs `appState` for that). Call `flush()` to send now.
4. **Refused events stay queued.** A send refused with `401` or `403` stays in the queue and is tried again, so fixing the key in the next build delivers what was queued (up to 1,000 events; the oldest go first). Only `400`, `413` and `422` are dropped.
5. **`setup` was not called, or called late.** On Android every call before `Apphelm.setup` does nothing. Call it from `Application.onCreate`, and on Flutter before `runApp`.

## Status codes

Answers from the browser collector (`/api/events` and the other browser routes) and from the API (`/api/v1/…`).

| Status | Code | Meaning | What to do |
| --- | --- | --- | --- |
| `202` | `"accepted": true` | Stored. With `duplicate: true`, an event with that id was already stored, so it was not stored again. | Nothing |
| `202` | `"accepted": false` with a `reason` | Received but deliberately not stored or billed (table below). The SDK does not retry. | Depends on the reason |
| `400` | `invalid_request` | The body is not JSON, or larger than 64,000 bytes | Send smaller batches |
| `401` | `invalid_project_key` | Browser routes: missing or unknown browser key, no `Origin` header, or an origin the key does not list | Check the key and the page's exact origin |
| `401` | `unauthorized` | API: missing, unknown or revoked server key | Send `Authorization: Bearer ahl_live_…` with an active key |
| `403` | `scope_denied` (or `insufficient_scope`) | The key lacks the scope the endpoint needs; the message names it | Create a key with that scope |
| `403` | `product_scope_denied` | The key is limited to other products | Use a key for this product |
| `403` | `scope_mismatch` | The body's `workspaceId` or `productId` is not the key's | Use the ids the key belongs to |
| `403` | `server_authority_required` | A customer signal (`apphelm.identify`, `apphelm.group`, `apphelm.goal`, `apphelm.outcome`) was sent with a browser key | Send it from your server with a server key |
| `403` | `origin_not_allowed` | A browser called the server API (`/api/v1`) directly | Call the API from your server; browsers use the browser SDK |
| `409` | `collection_paused` | An owner paused collection for the workspace. Nothing is stored or billed. | Resume collection in Settings; retrying will not help until then |
| `409` | `product_archived` | The product is archived | Restore it in Settings |
| `409` | `demo_product_read_only` | The demo product accepts no data | Send to your own product |
| `409` | `idempotency_conflict`, `idempotency_in_flight` | The `Idempotency-Key` was used with another body, or the first request is still running | Use a new key for a new request; retry the same one in a moment |
| `409` | `session_conflict` | Replay: the recording's session id already belongs to another workspace or product. The SDKs make a fresh random id for every recording, so this means a recorder of your own, or copied code, reused one | Let the SDK create session ids; the browser SDK drops that chunk |
| `409` | `key_limit` | The workspace has 10 active server keys | Revoke an unused key |
| `409` | other codes (`flag_changed`, `insight_changed` …) | A write lost a race or conflicts with the resource's state; the message says which | Read the resource again and resend |
| `413` | `payload_too_large`, `profile_too_large`, `chunk_too_large` | Logs, profiles, crash files or replay chunks over their size limit | Send smaller batches; the [API reference](https://apphelm.dev/docs/api) lists each limit |
| `422` | `missing_fields` | `workspaceId`, `productId` or `eventName` is missing | Send all three |
| `422` | `batch_too_large`, `invalid_batch` | More than 50 events in a batch, or none with a name | Split the batch |
| `422` | `invalid_replay_chunk` | Replay: a chunk failed validation. Most often its entry page or a navigation is on a path replay never records: one with `auth`, `sign-in`, `sign-up`, `login`, `logout`, `billing`, `checkout`, `payment`, `admin` or `account/security` as a segment, such as `/settings/billing`. Otherwise a field (session id, sequence, viewport, masking or consent version) or an event is malformed | Browser SDK 0.8.0 and earlier record nested paths like `/settings/billing`: add them to `replay.blockedPaths`. The SDK drops the refused chunk |
| `422` | `invalid_start_time` | Replay: the recording's start time is more than 5 minutes ahead of AppHelm's clock, or older than 26 hours (24 hours for schematic recordings). Usually a device clock that is far off | Fix the device's clock; chunks refused this way are dropped |
| `422` | `invalid_customer_signal` and other validation codes | The body failed validation; the message says what | Fix the field named |
| `429` | `rate_limited` | Browser: over 240 requests a minute from one address or 2,400 for one key, per Cloudflare location (`Retry-After: 60`). Logs and traces: over 2,400 requests a minute for one server key (`Retry-After: 10`). | Wait for `Retry-After`; send more per request |
| `429` | `event_limit` | The monthly event allowance is used up | Change the cap behaviour or plan in billing settings |
| `429` | `replay_limit` | The month's replay sessions are used up. Recordings already started keep uploading; new ones are refused | Wait for the next month, lower `replay.sampleRate`, or raise the plan |
| `429` | `flag_evaluation_limit` | The monthly flag evaluation allowance is used up; browser flags read as off | Evaluate locally on servers, or raise the plan |
| `429` | `deploy_rate_limited`, `rate_limit_exceeded`, `sql_busy`, `sql_rate_limited`, `log_limit`, `profile_limit` | A per-feature limit | Wait for `Retry-After` |
| `503` | `ingest_protection_unavailable` | Collection is briefly unavailable (`Retry-After: 60`) | Retry after the delay; SDKs that queue do this for you |

`202` answers with `"accepted": false`:

| `reason` | Meaning | What to do |
| --- | --- | --- |
| `bot_filtered` | A crawler, headless browser or plain HTTP client user agent, or none, on a browser route | Test from a normal browser; send server events with a server key |
| `internal_traffic` | From a network the workspace marked as internal, or an event with `apphelm_internal: true` | Expected for your own team |
| `collection_paused`, `product_archived`, `product_demo` | As the `409` codes above, for browser keys | As above |
| `inbound_filter` | A filter in the product's settings dropped it | Review inbound filters |
| `autocapture_paced`, `autocapture_dropped`, `event_limit_sampled_out` | Autocapture was paced near the event cap, turned off or sampled in capture settings | Review capture settings and the cap behaviour |

Each API answer carries an `X-Request-Id` header. Include it when you contact support.

## Origins and browser keys

- **Compare origins exactly.** Open the browser console on the page and run `location.origin`. That string must be in the browser key's list in Setup, character for character.
- **One origin, one key.** A browser key created in Setup allows the origin you typed. For a new domain, a preview deployment or local development, create another browser key for that origin.
- **Preview deployments** with a new hostname per branch need a key per hostname, since wildcards are not supported. Point previews at a staging product with its own key, or leave them unmeasured.
- **Revoked keys** answer `401` straight away. Create a new key and redeploy.

## Ad blockers and networks

Some ad and tracking blockers block requests to analytics services, including `apphelm.dev`. The browser SDK's debug output then says the request "could not be sent". AppHelm cannot see these visitors.

- Send events that you must count (sign-ups, payments, outcomes) from your server as well, with the same user id, so they arrive whatever the browser does.
- A proxy on your own domain is possible with the base URL option, but it must pass on `Origin` and `User-Agent`, and all its traffic counts as one address against the 240-requests-a-minute browser limit, so it only suits low traffic.
- Corporate networks and firewalls can block `apphelm.dev` too. Allow `https://apphelm.dev` for outgoing requests from servers.

## CORS

- **Browser SDK requests** need no setup. The collector answers the preflight for whichever origin calls it, then checks the origin against the key on the real request. A CORS error in the console for `/api/events` usually means the request was blocked before it reached AppHelm (an extension or a proxy).
- **Your own API** must allow the trace headers once browser tracing is on: requests to `tracePropagationTargets` carry `traceparent` and `baggage`. Add both to `Access-Control-Allow-Headers`, or narrow `tracePropagationTargets`.
- **The server API** (`/api/v1`) does not allow browser origins (`403 origin_not_allowed`). Server keys belong on servers.

## Times and clocks

- **Charts place an event at the time AppHelm received it**, not at the device's clock, so a phone with the wrong time cannot move data around. The event's own time is kept with it.
- **Offline events arrive late.** Events an app queued while offline appear when they are finally sent, on that day's charts.
- **Imported history** (`apphelm_import: true` on server-key events) is charted at its own time, when that is in the past and at most 400 days old.
- **Time zones.** Cron monitor schedules are in UTC.

## Missing or unreadable stack traces

| Platform | Likely cause | What to do |
| --- | --- | --- |
| Browser | No source maps for this build, or the release differs | Upload maps with the Vite, webpack or esbuild plugin, or `withApphelmConfig` for Next.js, for the release the SDK sends |
| Browser, "Script error." with no stack | The script was loaded from another origin without CORS | Serve it with `Access-Control-Allow-Origin` and load it with `crossorigin="anonymous"` |
| React Native | No Hermes source maps for the release | Upload the bundle's maps for the same `release` and `dist` |
| iOS | No dSYMs | Upload dSYMs for each build |
| Android | R8 obfuscated the classes | Upload the mapping file for the build |
| Native code | No Breakpad symbols | Upload `.sym` files before the build's crashes arrive |
| Rust | No debug info in release builds | `debug = "line-tables-only"` in the release profile |
| Go | Local paths in stacks | Build with `-trimpath` |
| .NET | Release build without PDBs | Ship the PDBs; filters match `Namespace.Type.Method` without them |

See [Source maps and debug symbols](https://apphelm.dev/docs/source-maps).

## Flags always off

Flags fail closed: anything that stops an evaluation reads as off. To see why, evaluate it through the API; each row has a `reason`:

```bash
curl -X POST https://apphelm.dev/api/v1/flags/evaluate \
  -H "Authorization: Bearer $APPHELM_API_KEY" -H "Content-Type: application/json" \
  --data '{"productId":"prd_…","distinctId":"user-123","flagKey":"new-checkout","environment":"production"}'
```

| Cause | What to do |
| --- | --- |
| The flag is a draft or disabled | Turn it on in **Flags** |
| The flag has environment rollouts and the request named no environment, or another one (`environment_excluded`) | Pass `environment` (browser option, `flagsEnvironment` on Android and Flutter, per call on servers) |
| The person is not in the rollout or the targeting (`rollout`, `targeting`) | Check the conditions; a server must pass `personProperties` and `context` it knows |
| Browser: the browser key or origin is wrong, so flags never loaded | Check with `debug: true`; fix the key or origin |
| Browser: a headless browser or bot user agent | Flags answer `failClosed` for bots; test in a normal browser |
| Browser: the flag is server-only (`server_evaluation_required`) | Evaluate it on your server and pass the result as `bootstrap` |
| Browser, server rendering: no bootstrap | Flags read `false` until they load; use `getBootstrap`, `apphelmHandle` or the Nuxt server plugin |
| Android or Flutter: read before the first load | `getFeatureFlag` is `null` before flags load; `reloadFeatureFlags` waits for them |
| Local evaluation: every flag off | The key lacks `products:read`; give the server its own key with it |
| The monthly flag evaluation cap is reached (`429 flag_evaluation_limit`) | Evaluate locally on servers, or raise the plan |

Flags load and read without analytics consent; only their exposure events wait for consent. See [Feature flags](https://apphelm.dev/docs/feature-flags).

## Replay not recording

| Cause | What to do |
| --- | --- |
| No replay consent | Call `setConsent({ analytics: true, replay: true })`; on mobile, `setReplayConsent(true)` |
| The page is on a blocked path | Sign-in, sign-up, login, logout, billing, checkout, payment, admin and account security paths are never recorded; so are paths in `blockedPaths` |
| Sampled out | `replay.sampleRate` decides per session; with `onErrorSampleRate` only, a recording is uploaded only when an error happens |
| Shorter than `minimumDurationMs` | Short sessions are never sent when it is set |
| `linkedFlag` or `urlTriggers` not met | Recording waits for the flag to be on, or for a matching URL |
| Mobile: no browser key for uploads | Replay uploads with a browser key and one of its origins: set `surveyKey` and `surveyOrigin` (or the replay's own `projectKey` and `origin`) |
| React Native: no native module | Install `@sansavision/apphelm-react-native-replay` and rebuild the app |
| Collection paused, or the product archived | Resume collection or restore the product |

See [Session replay](https://apphelm.dev/docs/session-replay).

## No traces or transactions

- **No sample rate.** Automatic tracing (page loads, requests, screen loads, app starts) sends nothing until you set `tracesSampleRate` or a `tracesSampler`. Transactions you start yourself are kept.
- **No trace across services.** `traceparent` goes only to `tracePropagationTargets` (browser, React Native) or `tracePropagationHosts` (other SDKs). Add your own API hosts.
- **Middleware not installed** or installed in the wrong place: see your platform's notes in [Install and configure](https://apphelm.dev/docs/install#framework-notes).

See [Tracing and performance](https://apphelm.dev/docs/tracing).

## Errors not captured

| Platform | Uncaught errors are reported when |
| --- | --- |
| Browser | Analytics consent exists and `errorCapture` is not `false` |
| Node.js | You call `apphelm.captureUnhandled()`, or a framework integration catches them |
| React Native | By default (`captureUnhandled`) |
| iOS | After `installCrashReporting()`; crashes are sent on the next launch by `sendPendingCrashReports()` |
| Android | By default (`captureCrashes`, `captureAnrs`); sent on the next launch |
| Flutter | With `captureFlutterErrors: true` or `Apphelm.init`; native crashes need `apphelm_flutter_native` |
| JVM | After `installCrashReporting(store)`, or inside `withRequest` |
| Python | With `apphelm.init` (`capture_unhandled=True`), and the framework integrations |
| Go | Inside `client.Middleware`, or with `defer client.Recover()` |
| Ruby | Through the Rack middleware, the Rails error reporter or Sidekiq |
| PHP | After `registerErrorHandlers()`, or with the Laravel or Symfony integration |
| .NET | After `CaptureUnhandledExceptions()`, or `UseApphelm()` in ASP.NET Core |
| Rust | After `install_panic_hook()` |
| Elixir | With `Apphelm.Plug` and the `Apphelm.LoggerHandler` logger handler |

Errors can also be dropped on purpose by `sampleRate`, `ignoreErrors`, `denyUrls`, `allowUrls` or `beforeSend`; `debug` names which one did it. Mobile crashes are sent on the next launch, so open the app again after a test crash. See [Errors and issues](https://apphelm.dev/docs/errors).

## Still stuck

- Read your platform's page in [Install and configure](https://apphelm.dev/docs/install) again, and compare your setup with the code there.
- Ask an AI assistant with the docs MCP server connected ([Set up with AI](https://apphelm.dev/docs/ai-setup)): it can search every page.
- Contact support with the `X-Request-Id` of a refused request, the SDK and version, and the debug output.
