> For the complete documentation index, see [llms.txt](https://docs.amply.tools/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.amply.tools/developer-guide/testing-your-integration.md).

# Testing your integration

Before shipping, confirm two things: the SDK is running, and events you fire actually reach the Amply dashboard. This page shows the helpers you use to verify each step locally, and the log controls that surface what the SDK is doing internally.

A PM should read this as: "the SDK has built-in diagnostic helpers — the developer can print the last events, inspect the current state the SDK knows about, and turn on verbose logging during integration."

**Use this when** you're integrating the SDK for the first time, debugging a campaign that won't fire, or tracking down why an event doesn't show up in the dashboard.

**Don't use this when** you're investigating a production-only issue — the debug helpers are meant for local or staging builds, and some signals (like session boundaries on iOS) only reproduce on a real device or simulator. Leave `debug` logging off in release builds.

## Turn on verbose logging

During integration, set the log level to `debug`. Production apps should leave it at `none` (or `error`).

{% tabs %}
{% tab title="iOS (Swift)" %}

```swift
amply.setLogLevel(level: "debug")
// or
amply.setLogLevel(level: .debug)
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
import tools.amply.sdk.logging.LogLevel

amply.setLogLevel(LogLevel.DEBUG)
// or
amply.setLogLevel("debug")
```

{% endtab %}

{% tab title="React Native (TS)" %}

```ts
import Amply from '@amplytools/react-native-amply-sdk';

Amply.setLogLevel('debug');
```

You can also set `debug: true` in the initialization config — it's shorthand for `logLevel: 'debug'` and pipes SDK logs into the Metro console.
{% endtab %}
{% endtabs %}

Log levels, least-to-most verbose: `none`, `error`, `warn`, `info`, `debug`.

## Inspect recent events

The SDK keeps a local list of the events it has seen — both the custom ones you tracked and its own system events. Useful for sanity-checking that your `track` calls actually landed before they've been flushed to the backend.

{% tabs %}
{% tab title="iOS (Swift)" %}

```swift
Task {
    let events = try await amply.getRecentEvents(limit: 30)
    for event in events {
        print("\(event.timestamp) \(event.name) \(event.type) \(event.properties)")
    }
}
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
lifecycleScope.launch {
    val events = amply.getRecentEvents(limit = 30)
    events.forEach { e ->
        Log.d("Amply", "${e.timestamp} ${e.name} ${e.type} ${e.properties}")
    }
}
```

{% endtab %}

{% tab title="React Native (TS)" %}

```ts
const events = await Amply.getRecentEvents(30);
console.table(events.map(e => ({
  name: e.name,
  type: e.type,
  ts: new Date(e.timestamp).toISOString(),
})));
```

{% endtab %}
{% endtabs %}

`limit` defaults to 30. Events are returned newest-first.

## Inspect what the SDK knows about the user

`getDataSetSnapshot` returns the current state of a named dataset — device info, user attributes, current session, recent events, or triggered event counts. Use it to verify that `setUserId`, `setCustomProperties`, and your `track` calls have the effect you expect.

Available datasets:

| Dataset           | What's in it                                                                         |
| ----------------- | ------------------------------------------------------------------------------------ |
| `@device`         | Device and app fields (model, OS version, advertising identifier, app build, locale) |
| `@user`           | The user ID and related user-level data                                              |
| `@custom`         | The custom properties you set via `setCustomProperty` / `setCustomProperties`        |
| `@session`        | Current session (start time, session index, source)                                  |
| `@triggeredEvent` | Counts for a specific triggered event name                                           |
| `@events`         | Counts / aggregates for a set of events                                              |

{% tabs %}
{% tab title="iOS (Swift)" %}

```swift
// Simple form — construct the dataset directly.
Task {
    let snapshot = try await amply.getDataSetSnapshot(type: DataSetType.Device())
    print(snapshot)
}

// Alternative — look up a dataset by its string name.
Task {
    guard let deviceSet = DataSetType.Companion.shared.fromString(value: "@device") else { return }
    let snapshot = try await amply.getDataSetSnapshot(type: deviceSet)
    print(snapshot)
}
```

{% endtab %}

{% tab title="Android (Kotlin)" %}

```kotlin
import tools.amply.sdk.datasets.DataSetType

lifecycleScope.launch {
    val snapshot = amply.getDataSetSnapshot(DataSetType.Device)
    Log.d("Amply", "device snapshot: $snapshot")
}
```

{% endtab %}

{% tab title="React Native (TS)" %}

```ts
const device = await Amply.getDataSetSnapshot({ kind: '@device' });
console.log('device snapshot:', device);

const user = await Amply.getDataSetSnapshot({ kind: '@user' });
console.log('user snapshot:', user);
```

{% endtab %}
{% endtabs %}

## Verifying events reach the dashboard

Once the SDK is running with `debug` logging on:

1. Open the Amply dashboard for your application.
2. Fire a test event from the app (a screen view, a button tap).
3. Watch the device console for `[Amply]` log lines confirming the event was queued and flushed.
4. Open the dashboard's event view and look for the event name.

If the event appears in `getRecentEvents` but not in the dashboard after a minute, check:

* The app has network access.
* The app was initialized with the correct `appId`, `apiKeyPublic`, and `apiKeySecret` for your project.
* The SDK logs don't show authentication or network errors (turn log level up to `debug`).

If the event doesn't appear in `getRecentEvents` at all, the call to `track` didn't reach the SDK — check for typos, make sure the SDK is initialized, and that you're not calling from a build variant with a different configuration.

## Quick diagnostics checklist

* `SdkInitialized` fires (see [Handling callbacks](/developer-guide/handling-callbacks.md))
* `getDataSetSnapshot({ kind: '@device' })` returns a non-empty map
* `getDataSetSnapshot({ kind: '@user' })` reflects the `userId` you set
* `getDataSetSnapshot({ kind: '@custom' })` reflects the custom properties you set
* `getRecentEvents(30)` shows your last few tracked events
* The dashboard shows the same events within \~1 minute

## Related

* [Tracking events](/developer-guide/tracking-events.md) — what you're verifying
* [User attributes](/developer-guide/user-attributes.md) — set user ID and custom properties to inspect
* [Handling callbacks](/developer-guide/handling-callbacks.md) — subscribe to SDK lifecycle for deeper diagnostics
* [iOS SDK reference](/reference/sdk-ios.md) — exact signatures
* [Android SDK reference](/reference/sdk-android.md) — exact signatures
* [React Native SDK reference](/reference/sdk-react-native.md) — exact signatures


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.amply.tools/developer-guide/testing-your-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
