Preferences and State

Preferences

Preferences are the settings that are preferred by the user. These preferences can differ from the settings the SDK uses when recording.

Smartlook.instance.preferences
Smartlook.getInstance().getPreferences();

State

Calling state returns the settings that are currently used by the SDK. The state of every SDK setting is based on:

  • Default SDK settings.
  • Settings retrieved from the backend.
  • Preferences specified through the API .
Smartlook.instance.state
Smartlook.getInstance().getState();

Status

Because status is read-only, you can only get it using state. It can be used to check if the SDK is currently recording. It can also provide additional information about why the SDK is not recording. Full usage example:

when(val status = Smartlook.instance.state.status) {
  Status.Recording -> {}
    is Status.NotRecording -> {
    when(status.cause) {
      Status.NotRecording.Cause.NOT_STARTED -> {}
      Status.NotRecording.Cause.STOPPED -> {}
      Status.NotRecording.Cause.PROJECT_LIMIT_REACHED -> {}
      Status.NotRecording.Cause.STORAGE_LIMIT_REACHED -> {}
      Status.NotRecording.Cause.INTERNAL_ERROR -> {}
    }
  }
}
Status status = Smartlook.getInstance().getState().getStatus();

if (status instanceof Status.Recording) {
} else if (status instanceof Status.NotRecording) {
	switch (((Status.NotRecording) status).getCause()) {
		case NOT_STARTED:
			break;
		case STOPPED:
			break;
		case PROJECT_LIMIT_REACHED:
			break;
		case STORAGE_LIMIT_REACHED:
			break;
		case INTERNAL_ERROR:
			break;
	}
}

If the SDK is recording, you get Status.Recording. If the SDK is not recording, you get Status.NotRecording and then possible causes. Causes of Status.NotRecording can be:

StatusPossible Cause
Cause.NOT_STARTEDThe recording has not started yet.
Cause.STOPPEDThe recording was stopped using stop().
Cause.PROJECT_LIMIT_REACHEDThe project limit of recorded sessions has been reached.
Cause.STORAGE_LIMIT_REACHEDThe SDK cannot record because it would violate storage limits.
Cause.INTERNAL_ERRORThe SDK stopped recording due to an internal error.

Default value

The default status is Status.NotRecording with cause Cause.NOT_STARTED.

Project key

A unique project key is needed for the SDK to upload and process recordings.

Set the project key

Smartlook.instance.preferences.projectKey = "YOUR PROJECT KEY"
Smartlook.getInstance().getPreferences().setProjectKey("YOUR PROJECT KEY");

📘

Your project key

You can find your project key in the mobile project settings the Smartlook app.

Read the project key

val projectKey = Smartlook.instance.preferences.projectKey
String projectKey = Smartlook.getInstance().getPreferences().getProjectKey();

Default value

The project key is not defined by default (set to null).

Frame rate

Set the preferred frame rate recorded by the SDK. Only settings between 2 and 10 frames per second are allowed.

🚧

Frame rate set through API

If you set a frame rate between 2 and 10 frames per second using the API, any settings that are set from the dashboard are ignored.

Set the frame rate

Smartlook.instance.preferences.frameRate = 2
Smartlook.getInstance().getPreferences().setframeRate(2);

Read the frame rate

val frameRate = Smartlook.instance.state.frameRate
int frameRate = Smartlook.getInstance().getState().getFrameRate();

Default value

The default frame rate used by the SDK is 2 frames per second.

Rendering modes

The SDK can use different methods of capturing screen image data. These are called rendering modes. For more information, see Rendering modes.

Event tracking

Tracking of some automatically tracked events can be enabled or disabled using Event Tracking API.

All automatically detected events

Smartlook.instance.preferences.eventTracking.enableAll()
Smartlook.instance.preferences.eventTracking.disableAll()
Smartlook.getInstance().getPreferences().getEventTracking().enableAll();
Smartlook.getInstance().getPreferences().getEventTracking().disableAll();

Navigation events

All automatically detected navigation events can be enabled or disabled. Or, Activity and Fragment detection can be enabled or disabled separately.

val eventTracking = Smartlook.instance.preferences.eventTracking
  
eventTracking.navigation.enableAll()
eventTracking.navigation.disableAll()
  
eventTracking.navigation.isActivityEnabled = true
eventTracking.navigation.isFragmentEnabled = true
EventTracking eventTracking = Smartlook.getInstance().getPreferences().getEventTracking();
  
eventTracking.getNavigation().enableAll();
eventTracking.getNavigation().disableAll();
  
eventTracking.getNavigation().setActivityEnabled(true);
eventTracking.getNavigation().setFragmentEnabled(true);

📘

Fragment navigation event detection is disabled by default.

Instances of Activity and Fragment can be excluded from navigation event detection using the following:

val eventTracking = Smartlook.instance.preferences.eventTracking
  
eventTracking.navigation.disabledActivityClasses += SampleActivity::class
eventTracking.navigation.disabledFragmentClasses += SampleFragment::class
EventTracking eventTracking = Smartlook.getInstance().getPreferences().getEventTracking();
  
eventTracking.getNavigation().getDisabledActivityClasses().add(SampleActivity.class);
eventTracking.getNavigation().getDisabledFragmentClasses().add(SampleFragment.class);

User interaction events

All automatically detected user interaction events can be enabled or disabled. Or, rage click, selector, and touch event detection can be enabled and disabled separately.

val eventTracking = Smartlook.instance.preferences.eventTracking
  
eventTracking.interaction.enableAll()
eventTracking.interaction.disableAll()
  
eventTracking.interaction.isRageClickEnabled = true
eventTracking.interaction.isSelectorEnabled = true
eventTracking.interaction.isTouchEnabled = true
EventTracking eventTracking = Smartlook.getInstance().getPreferences().getEventTracking();
  
eventTracking.getInteraction().enableAll();
eventTracking.getInteraction().disableAll();
  
eventTracking.getInteraction().setRageClickEnabled(true);
eventTracking.getInteraction().setSelectorEnabled(true);
eventTracking.getInteraction().setTouchEnabled(true);

Default value

By default , all automatically detected events are tracked, except Fragmentnavigation events.
The default can be restored using the following:

Smartlook.instance.preferences.eventTracking.default()
Smartlook.getInstance().getPreferences().getEventTracking().default();