# Setup Session Replay

Session Replay records user sessions for replay in the Luciq dashboard. You can enable/disable it, control what is captured (network logs, Luciq logs, user steps), set capturing mode and screenshot quality, and control when replays are uploaded.

* [Support Tools Integration](https://docs.luciq.ai/kmp/setup-luciq-for-kmp/setup-session-replay/support-tools-integration) – Using session replay with support tools

### Enable/disable

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setEnabled(true)
```

{% endcode %}

### What is captured

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setNetworkLogsEnabled(true)
SessionReplayKmp.setLuciqLogsEnabled(true)
SessionReplayKmp.setUserStepsEnabled(true)
```

{% endcode %}

### Session replay link

Get the link to the current session replay (e.g. to share with support):

{% code title="Kotlin" %}

```kotlin
scope.launch {
    SessionReplayKmp.getSessionReplayLink().collect { url ->
        url?.let { println(it) }
    }
}
```

{% endcode %}

### When to upload (sync predicate)

Upload only sessions that meet your criteria. The predicate receives `SessionMetadata` with fields such as: `appVersion`, `os`, `device`, `sessionDurationInSeconds`, `networkLogs`, `launchType`, `launchDuration`, `bugsCount`, `fatalCrashCount`, `oomCrashCount`, `hasLinkToAppReview`. Use them to decide whether to upload (e.g. only when there was a crash or bugs):

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setSyncPredicate { metadata ->
    (metadata.fatalCrashCount ?: 0) > 0 || (metadata.bugsCount ?: 0) > 0
}
```

{% endcode %}

### Capturing mode

| Mode                         | Description                                                            |
| ---------------------------- | ---------------------------------------------------------------------- |
| `CapturingMode.Navigation`   | Screenshots when navigating between screens (default, lowest overhead) |
| `CapturingMode.Interactions` | Screenshots on navigation and user interactions                        |
| `CapturingMode.Frequency`    | Screenshots at a fixed interval (video-like) plus navigation           |

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setCapturingMode(CapturingMode.Interactions)
```

{% endcode %}

Call before SDK init when possible.

### Screenshot quality

| Quality                       | Description                          |
| ----------------------------- | ------------------------------------ |
| `ScreenshotQuality.High`      | 50% WebP, best quality               |
| `ScreenshotQuality.Normal`    | 25% WebP, default                    |
| `ScreenshotQuality.Greyscale` | Grayscale + 25% WebP, most efficient |

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setScreenshotQuality(ScreenshotQuality.Normal)
```

{% endcode %}

### Capture interval (frequency mode)

When using `CapturingMode.Frequency`, set the interval in milliseconds (min 500, default 1000):

{% code title="Kotlin" %}

```kotlin
SessionReplayKmp.setScreenshotCaptureInterval(intervalMs = 1000)
```

{% endcode %}
