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 deviceready callback:

if(document.readyState === "complete") {
  document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
    Smartlook.setupAndStartRecording({smartlookAPIKey: "API_KEY"});
}

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

Smartlook.setupAndStartRecording({smartlookAPIKey: 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({smartlookAPIKey: string});

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

RenderingMode.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 setup() or setupAndStartRecording() method.

Smartlook.setup({
  smartlookAPIKey: "API_KEY",
  fps: 2,
  renderingMode: Smartlook.RenderingMode.NATIVE,
  startNewSession: true,
  eventTrackingModes: [EventTrackingMode.FULL_TRACKING]
});

Smartlook.setupAndStartRecording({
  smartlookAPIKey: "API_KEY",
  fps: 2,
  renderingMode: Smartlook.RenderingMode.NATIVE,
  startNewSessionAndUser: true,
  eventTrackingModes: [EventTrackingMode.FULL_TRACKING]
});

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(isRecording: function(isRecording: string))
Smartlook.isRecording(
    function(isRecording){
        //check here
    }
)