Lifecycle & Recording

SDK instance

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

val smartlookInstance = Smartlook.instance
Smartlook smartlookInstance = Smartlook.getInstance();

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 settings on the Smartlook Dashboard.

Smartlook.instance.preferences.projectKey = "YOUR PROJECT KEY"
Smartlook.getInstance().getPreferences().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()
Smartlook.getInstance().start();
Smartlook.getInstance().stop();

When a user closes your app, the user session 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.

Checking if the SDK is recording

To see if the SDK is recording:

Smartlook.instance.state.status.isRecording
Smartlook.gettInstance().getState().getStatus().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 Status.

Opening a new session

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

Smartlook.instance.user.session.openNew()
Smartlook.getInstance().getUser().getSession().openNew()

Session URL

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

val sessionURL = Smartlook.instance.user.session.url
val sessionURLWithTimestamp = Smartlook.instance.user.session.urlWithTimestamp
URL sessionURL = Smartlook.getInstance().getUser().getSession().getUrl();
URL sessionURLWithTimestamp = Smartlook.getInstance().getUser().getSession().getUrlWithTimestamp();

🚧

Nullability and 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 these.

Session Listener

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

Smartlook.instance.user.session.listeners += object : Session.Listener {
  override fun onUrlChanged(url: URL) {
		// Called when session URL changes
  }
}
Smartlook.getInstance().getUser().getSession().getListeners().add(
  url -> {
		// Called when session URL changes
  }
);

When onUrlChanged gets called both session url and urlWithTimestamp are present.

📘

Multiple listeners

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