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.

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        SmartlookUnity.SetupOptionsBuilder builder = new SmartlookUnity.SetupOptionsBuilder("API_KEY");
        SmartlookUnity.Smartlook.SetupAndStartRecording(builder.Build());
    }

    // Update is called once per frame
    void Update()
    {
        ...
    }
}

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

SmartlookUnity.Smartlook.SetupAndStartRecording(string apiKey);

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

SmartlookUnity.Smartlook.Setup(string apiKey);

And then the recording can be started by calling:

SmartlookUnity.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.

SmartlookUnity.SetupOptionsBuilder builder = new SmartlookUnity.SetupOptionsBuilder("API_KEY");
builder.
  .SetFps(2)
  .SetStartNewSession(true);
SmartlookUnity.Smartlook.SetupAndStartRecording(builder.Build());

Start and stop recording

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

SmartlookUnity.Smartlook.StartRecording();
SmartlookUnity.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:

SmartlookUnity.Smartlook.IsRecording();