Skip to main content
Version: 1.1.x

Coryn

Package
ai.coryn.replay.api.core.main
Artifact
ai.coryn.replay.api:core

Coryn is the SDK singleton. Include recorder or recorder-compose to enable recording. The methods on this page accept calls from any thread and execute on the main thread, except getRecordingId(), which reads the currently available ID without dispatching.

init​

Signature
fun init(application: Application, apiKey: String)
fun init(application: Application, apiKey: String, action: CorynInitialisationScope.() -> Unit)
fun init(application: Application, apiKey: String, action: CorynConsumer<CorynInitialisationScope>)
fun init(application: Application, apiKey: String, configuration: CorynConfiguration)

Initialise once per application process lifetime, after super.onCreate() in your custom Application, before calling other SDK APIs. Later calls are ignored and do not replace the first configuration. Initialisation does not itself request recording.

application is the app's Application; apiKey authorises the project. The two-argument overload uses defaults. The configuration overload requires a non-null object. See Configuration for the DSL, Java builders, and defaults.

Kotlin usage
Coryn.init(application, apiKey) {
network { isUploadOnMeteredNetworkAllowed = false }
}

startRecording​

Signature
fun startRecording()
fun startRecording(delayReason: String?)
fun startRecording(action: CorynStartRecordingScope.() -> Unit)
fun startRecording(delayReason: String?, action: CorynStartRecordingScope.() -> Unit)
fun startRecording(configuration: CorynRecordingConfiguration?)
fun startRecording(delayReason: String?, configuration: CorynRecordingConfiguration?)

Request recording after initialisation. The first request supplies the configuration; subsequent requests neither update it nor restart a stopped recording. Recording requires a recorder dependency and enabled project feature flags.

delayReason explains why the app delayed its start request, for example while waiting for consent. If another condition delays the actual start further, the SDK reports that later reason. A null configuration uses defaults. Prefer startRecording() over a bare startRecording(null), which is ambiguous between the reason and configuration overloads.

Kotlin usage
Coryn.startRecording(delayReason = "Waiting for user consent") {
isUiCapturingEnabled = true
}

See recording configuration and Recording Lifecycle.

stopRecording​

Signature
fun stopRecording(reason: String?)

Stop recording, optionally explaining why. Call from the main thread to stop immediately; other threads dispatch to it. Stopping does not delete already recorded data or wait for uploads. Recording cannot restart in the same process lifetime.

Java usage
Coryn.stopRecording("User signed out");

getRecordingId​

Signature
fun getRecordingId(): String?

Return the recording session ID, or null if the recorder is unavailable or not yet initialised. Call on the main thread after initialisation to avoid racing a queued initialisation call. An ID can exist before recording actually starts; it is not an active-recording check. Use recording listener to observe the start.

registerScreen​

Signature
fun registerScreen(name: String, fragment: Fragment, arguments: Bundle? = null)
fun registerScreen(name: String, activity: ComponentActivity, arguments: Bundle? = null)
fun registerScreen(
name: String,
savedStateRegistryOwner: SavedStateRegistryOwner,
lifecycle: Lifecycle,
arguments: Bundle? = null
)

Register a screen whose active state and removal follow the supplied lifecycle. Use the Fragment overload for a whole-screen Fragment, or the Activity overload when the Activity represents the screen. The Fragment overload uses its current view lifecycle, so register after the view exists; registration is skipped if that view has been destroyed and not recreated. The custom lifecycle overload removes the registration when that lifecycle is destroyed.

name identifies the screen. arguments records optional String, Number, and Boolean values; visual privacy masks do not redact them. Java overloads can omit arguments.

See Screens and XML Views.

Manual screens​

Signature
fun registerManualScopeScreen(name: String, arguments: Bundle? = null): CorynManualScopeScreenId
fun unregisterManualScopeScreen(screenId: CorynManualScopeScreenId)

Register a screen without a lifecycle, keeping the returned ID to unregister it when it leaves the screen. Arguments have the same supported types as registerScreen. Java can omit arguments.

Unregistering affects only manual registrations. It does not remove lifecycle-managed screens.

provide​

Signature
fun provide(stateId: String, provider: CorynStateProvider<out CorynState>, activity: ComponentActivity)
fun provide(stateId: String, provider: CorynStateProvider<out CorynState>, fragment: Fragment)
fun provide(stateId: String, provider: CorynStateProvider<out CorynState>, lifecycle: Lifecycle)
fun <T> provide(stateId: String, providerActivity: T)
where T : CorynStateProvider<out CorynState>, T : ComponentActivity
fun <T> provide(stateId: String, providerFragment: T)
where T : CorynStateProvider<out CorynState>, T : Fragment

Register a State Provider with automatic lifecycle cleanup. Only one provider can be active per stateId; a new registration with that ID replaces the previous provider. The two-argument overloads use an Activity or Fragment that itself implements CorynStateProvider.

The Fragment overload uses the current view lifecycle. If its view has been destroyed and not recreated, the provider's onProviderRemove() callback runs instead of registering it. Prefer a whole-screen owner; use a custom Lifecycle when neither a Fragment nor an Activity fits.

Manual State Providers​

Signature
fun provideManualScopeStateProvider(stateId: String, provider: CorynStateProvider<out CorynState>)
fun removeManualScopeStateProvider(stateId: String)

Register a provider without automatic lifecycle cleanup. Remove it when its scope ends to release its resources and references. The same one-provider-per-ID rule applies. Removal affects manual providers only; lifecycle-managed registrations are ignored by this removal method.

See States for stable snapshots and cleanup examples.

addEvent​

Signature
fun addEvent(eventId: String)
fun addEvent(eventId: String, timePassedMs: Long)
fun addEvent(eventId: String, state: CorynState?)
fun addEvent(eventId: String, state: CorynState?, timePassedMs: Long)

Add a one-time Event to an active recording. eventId is its identifier; state is an optional stable snapshot. Without timePassedMs, the Event uses the current time; otherwise the value describes how many milliseconds ago it happened.

The recorder accepts at most 256 pending State/Event operations. Exceeding that limit reports a recording-critical error and stops recording. State snapshots must follow the equality and JSON contract. UI masking does not redact Event payloads.

See Events, API requests, and UI capture APIs for the remaining Coryn methods.