Preferences and State

Preferences

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

Smartlook.instance.preferences;

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.
  • Initial configuration specified by SetupConfiguration.
  • Settings retrieved from the backend.
  • Preferred behavior specified via Preferences.
Smartlook.instance.state;

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:

final RecordingStatus status = await Smartlook.instance.state.getRecordingStatus();

enum RecordingStatus {
  recording,
  not_started,
  stopped,
  project_limit_reached,
  storage_limit_reached,
  internal_error,
}

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 RecordingStatus.not_started.

Project key

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

Set the project key

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

📘

Your project key

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

Read the project key

final String? projectKey = await Smartlook.instance.state.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.setFrameRate(2);

Read the frame rate

final int frameRate = await Smartlook.instance.state.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. 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();

User interaction events

All automatically detected user interaction events can be enabled/disabled. Rage clicks and trackUser (selector, clicks) can be tracked individually.

final EventTracking eventTracking = Smartlook.instance.preferences.eventTracking;

eventTracking.interaction.enableAll();
eventTracking.interaction.disableAll();
  
eventTracking.interaction.setRageClickEnabled(true);
eventTracking.interaction.setTrackUserInteraction(true);

Navigation events

Native navigation event tracking is disabled by default from version 4.1.17. It can be enabled using the following:

Smartlook.instance.preferences.eventTracking.setTrackingNavigationEnabled(true);

Default value

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

Smartlook.instance.preferences.eventTracking.restoreDefault();