> For the complete documentation index, see [llms.txt](https://docs.tiun.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tiun.io/guides/testing/debugging.md).

# Debugging

When something does not behave as expected, start with SDK logging and a short checklist of common causes before escalating.

## Debug mode

Pass **`debug: true`** in the `tiun.init` configuration to turn on **console logging** from the SDK. That helps you see initialization, event flow, and errors during development.

```javascript
tiun.init({
  snippetId: 'YOUR_SNIPPET_ID',
  language: 'en', // 'en' | 'de' | 'fr'
  debug: true,
});
```

Disable or omit `debug` in your live builds if you prefer minimal client noise.

## Common issues

| Issue                                             | Likely cause                                        | What to try                                                                                                                                                                                 |
| ------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Events not firing                                 | SDK not initialized                                 | Call `tiun.init()` before subscribing to events.                                                                                                                                            |
| Checkout not opening                              | Wrong or stale product ID                           | Live and sandbox have separate catalogs — compare the ID to the dashboard view for the same environment your SDK uses (`sandbox: true` → sandbox toggle on).                                |
| Connect overlay not opening                       | SDK not initialized or wrong environment            | Ensure `tiun.init()` has been called and the snippet is configured for a time-based product.                                                                                                |
| Sandbox payments not working                      | App and dashboard on different environments         | Use sandbox snippet ID and `p-test-...` IDs with `sandbox: true`; confirm the dashboard **Sandbox** toggle is on while configuring test data.                                               |
| User state not updating                           | Relying only on snapshot properties                 | Listen for **`userChange`** and update UI from the event payload.                                                                                                                           |
| `productAccess` missing a purchase after checkout | Reading `tiun.user` too early, or wrong environment | Listen for **`userChange`** with `event: 'checkout'` — the payload already contains the updated `productAccess`. Confirm you're checking a `p-test-...` ID against the sandbox environment. |
| Can't re-test a first purchase                    | The test customer already has access                | Log out and check out with a fresh email — each email is a separate test customer. See [resetting sandbox state](/guides/testing/simulate-payments.md#resetting-sandbox-state).             |
| Session not restoring                             | Different browser or cleared storage                | Sessions are per browser; clearing cookies or site data clears the session.                                                                                                                 |

## Event reference

For the full list of events and payloads, see [SDK events](/sdk/web-sdk/events.md).

## Support

If logs and the table above do not resolve the issue, contact <support@tiun.io> with steps to reproduce and, when possible, snippet ID and environment (sandbox or live).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tiun.io/guides/testing/debugging.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
