Lifecycle & Recording

SDK instance

A Smartlook SDK instance is instantiated automatically during the application process creation and is available for the entire application run.

final Smartlook smartlookInstance = Smartlook.instance;

The Smartlook instance is used to access all SDK functions and fields.

Project key

Your unique project key is needed for the SDK to upload and process the recordings. You can find your project key in the mobile project setting on the [Smartlook Dashboard](https://app.smartlook.com/.)

Smartlook.instance.preferences.setProjectKey('YOUR PROJECT KEY');

Starting and stopping recordings

Recordings can be started or stopped at any time. Multiple subsequent start() or stop() calls will be ignored.

Smartlook.instance.start();
Smartlook.instance.stop();

When a user closes your app, the user sessions automatically stops recording. you don't need to use the stopRecording() call when the user stops using your app.

📘

Recording start and project key

User sessions can be recorded even if you haven't set the project key. Recorded data is saved but not sent. Once you set the project key, the data is sent.

This can be beneficial when the project key is fetched from a server. In this scenario, the recording can be started right away (on the application start). The recording will be complete, but the upload of recorded data is postponed for the moment until the project key is set.

Checking if the SDK is recording

To see if SDK is recording:

Smartlook.instance.state.isRecording();

📘

Why isn't the SDK recording?

You can see why your SDK is not recording by calling status. For more information on possible reasons the SDK is not recording and status, see K is not(https://mobile.developer.smartlook.com/reference/android-preferences-state#status.)

Opening a new session

You can close the current session and start a new session:

Smartlook.instance.user.session.openNew();

Session URL

The URL of the currently recorded session can be obtained with or without timestamp:

final String? sessionUrl = await smartlook.user.session.getUrl();
final String? sessionUrlWithTimestamp = await smartlook.user.session.getUrlWithTimeStamp();

🚧

Nullability & shareability

URLs are only available when the SDK is able to communicate with the Smartlook backend. Otherwise, they are null.

URLs are not publicly sharable and login to the dashboard is mandatory before opening.

Session Listener

A listener can be registered to listen to the session URL changes.

Smartlook.instance.eventListeners.registerSessionChangedListener(() {
      //TODO
});

When onUrlChanged is called, both session url and urlWithTimestamp are present.

📘

Multiple listeners

Multiple Session.Listener can be registered and will work in parallel.