# Debugging (/docs/sdk/debugging)



## Debug logging [#debug-logging]

Enable verbose logging when initializing:

```ts
await layers.init({
  appId: 'app_xxx',
  apiKey: 'unused',
  environment: 'development',
  enableDebug: true,
});
```

Each `track()` then prints the payload and the HTTP response from the
ingest endpoint.

## Event Inspector [#event-inspector]

Open the [Events page](/docs/events/feed) on the app dashboard. Events
appear within a few seconds of firing. Filter by `app_id`, event name,
or user.

See [Event inspector](/docs/sdk/event-inspector).

## CAPI delivery status [#capi-delivery-status]

Each ad layer's overview tab in the dashboard surfaces CAPI delivery
health (success rate, last-delivered timestamp). Watch this after
wiring a new layer.

If the layer shows "degraded":

* Re-check the CAPI config (pixel\_id / dataset\_id set, vault-backed
  access token still valid).
* Regenerate the CAPI access token if it has expired or been revoked
  (tokens don't auto-refresh).
* Check Meta / TikTok platform status.

## Meta Test Events [#meta-test-events]

In Meta Events Manager → your Dataset (Pixel) → **Test Events** tab,
you can:

* See live CAPI events as they arrive.
* Get a Test Event Code to scope the view to one device.

There is no first-class Layers-side flag to set a test-event-code
today. If you need one, pass it as a property on your events and plumb
it through a per-app `event_map` override; otherwise rely on
Layers Events page filtering by `install_id`.

## TikTok Events Debugger [#tiktok-events-debugger]

Same concept on the TikTok side — Business Center → Events Manager →
your Pixel → **Debugger**.

## Common issues [#common-issues]

### Events not arriving at the Events page [#events-not-arriving-at-the-events-page]

1. Confirm the device is hitting `in.layers.com` (network inspector,
   Charles, mitmproxy).
2. Confirm `app_id` matches the Layers project.
3. If on web, confirm an ad-blocker isn't blocking `in.layers.com` —
   set up a [custom domain](/docs/sdk/custom-domain) to work around it.
4. If `setConsent({ analytics: false })` was called, events are NOT
   enqueued.

### Events in Layers but not in Meta / TikTok [#events-in-layers-but-not-in-meta--tiktok]

1. The event name isn't in the
   [mapping table](/docs/sdk/architecture#event-name-mapping) and
   there's no per-app `event_map` override — the relay drops it
   silently.
2. CAPI isn't enabled on the ad layer (check `capi.enabled`,
   `pixel_id`, vault-backed access token).
3. Vault-encrypted CAPI token was rotated or revoked.
4. Pixel ID mismatch between the ad layer config and what's installed
   client-side.

### Duplicate conversions [#duplicate-conversions]

If you also run the Meta Pixel or TikTok Pixel client-side, share the
`event_id`. The SDK generates one automatically; pass it through to
your client-side Pixel.

### 401 / 403 responses [#401--403-responses]

`X-App-Id` header missing, invalid, or revoked. The response body is
intentionally opaque (`{ error: "unauthenticated" }`) for security —
server logs have the structured reason. Check that `appId` in your SDK
config matches the Layers project.

## Local echo endpoint [#local-echo-endpoint]

For offline CI tests, point `baseUrl` at a local HTTP server:

```ts
new LayersClient({
  apiKey: 'unused',
  appId: 'app_xxx',
  environment: 'development',
  baseUrl: 'http://localhost:8080',
});
```

The server won't run the CAPI relay, but you can assert on the request
shape.
