Lifecycle & Recording

SDK setup (on application start)

Smartlook SDK setup needs to be called only once during an application’s lifetime and it should be called on application startup. There is no need to stop recording explicitly on application closure, SDK will stop itself automatically.

import Smartlook from 'smartlook-react-native-wrapper';
Smartlook.setupAndStartRecording("API_KEY");

The easiest way of setting up the SDK is with setupAndStartRecording() method:

Smartlook.setupAndStartRecording(optionsOrAPIKey: Smartlook.SetupOptions | string);

It will set the SDK up and also start the recording. SDK can be setup without starting the recording using the following:

Smartlook.setup(optionsOrAPIKey: Smartlook.SetupOptions | string);

And then the recording can be started by calling:

Smartlook.startRecording();

Setup configuration

Some recording parameters can be configured on setup:

ParameterRequiredDefault valueDescription
apiKeyyes""Unique 40-character key identifying your app (can be found in the dashboard).
fpsno2Recorded video frame rate (allowed values between 2 and 10). Note that by setting this value settings from the dashboard will be overridden!
startNewSessionnofalseIf set to true SDK forces start of new session on setup.
startNewSessionAndUsernofalseIf set to true SDK forces start of new session and creates new visitor on setup.

Full SDK setup configuration can be done with optional fps method parameter.

Smartlook.setupAndStartRecording({ smartlookAPIKey: token, fps: 2, startNewSessionAndUser: true });

Start and stop recording

Recording can be started or stopped at any time, the only requirement is that the SDK is set up.

Smartlook.startRecording();
Smartlook.stopRecording();

🚧

stopRecording()

doesn't need to be called on application closure. Recording is stopped automatically.

Check if SDK is recording

Check if SDK is currently recording can be handy when using startRecording() and stopRecording() methods. Simply call:

Smartlook.isRecording(): Promise<boolean>;
Smartlook.isRecording().then((isRecording: boolean) => {
  alert(isRecording);
});

Reset session

Current session can be ended and a new session created by calling:

Smartlook.resetSession(resetUser: boolean);

If resetUser is set to true, SDK will create a new visitor during the reset. This is especially beneficial when a new user needs to be identified (typically after logout).

A new visitor can also be created on SDK setup:

Smartlook.setupAndStartRecording({ smartlookAPIKey: API_KEY, startNewSessionAndUser: true });