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.

The best place to setup the SDK is in platform ready callback:

this.platform.ready().then(() => {
  var setupConfig = new SmartlookSetupConfigBuilder("API_KEY");
  this.smartlook.setupAndStartRecording(setupConfig.build());
}

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

var setupConfig = new SmartlookSetupConfigBuilder("API_KEY");
this.smartlook.setupAndStartRecording(setupConfig.build());

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

var setupConfig = new SmartlookSetupConfigBuilder("API_KEY");
this.smartlook.setup(setupConfig.build());

And then the recording can be started by calling:

smartlook.startRecording();

Setup configuration

Some recording parameters can be configured on setup:

Parameter

Required

Default value

Description

apiKey

yes

""

Unique 40-character key identifying your app (can be found in the dashboard).

fps

no

2

Recorded video frame rate (allowed values between 2 and 10). Note that by setting this value settings from the dashboard will be overridden!

renderingMode

no

SmartlookRenderingMode.NATIVE

Defines the way SDK is going to capture screen image data.

eventTrackingModes

no

[EventTrackingMode
.FULL_TRACKING()]

Event tracking modes can be used to disable some automatically detected events.

startNewSession

no

false

If set to true SDK forces start of new session on setup.

startNewSessionAndUser

no

false

If set to true SDK forces start of new session and creates new visitor on setup.

Full SDK setup configuration can be done with SmartlookSetupConfigBuilder, that provides methods for setting any of the setup parameters shown above.

var builder = new SmartlookSetupConfigBuilder(smartlookAPIKey: string)
        .fps(fps: number)
        .renderingMode(renderingMode: SmartlookRenderingMode)
        .startNewSession(startNewSession: boolean)
        .startNewSessionAndUser(startNewSessionAndUser: boolean)
        .eventTrackingModes(eventTrackingModes: SmartlookEventTrackingModes);

Smartlook.setupAndStartRecording(builder.build());

Last line can be replaced with Smartlook.setup(builder.build()) so the recording can be started later.

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) => {
  alert(isRecording)
});