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.
  • Settings retrieved from the backend.
  • Preferences specified through the API .
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:

switch Smartlook.instance.state.status {
case .recording:
  break
  
case .notRecording(.projectLimitReached):
  break
  
case .notRecording(.notStarted), .notRecording(.stopped):
  break
    
case .notRecording(.internalError):
  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
.notStartedThe recording has not started yet.
.stoppedThe recording was stopped using stop().
.projectLimitReachedThe project limit of recorded sessions has been reached.
.internalErrorThe SDK stopped recording due to an internal error.

Default value

The default status is .NotRecording with cause .notStarted.

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"

πŸ“˜

Unique project key

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

Read the project key

let projectKey = Smartlook.instance.state.projectKey

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

Read the frame rate

let frameRate = Smartlook.instance.state.framerate

Default value

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

Rendering mode

The SDK can use different methods of capturing screen image data. These are called rendering modes.

Several rendering modes are available:

  • .native – Captures the application as the user sees it. Elements set as View sensitive (read more) are hidden.
  • .wireframe – Symbolic representation of the application that does not expose sensitive data by default.
  • .noRendering – Nothing is recorded.

The RenderingMode.wireframe can be further fine-tuned by setting a RenderingMode.Option.

Several rendering mode options are available:

  • .color – Captures View colors.
  • .blueprint – Does not capture View colors (only View outlines).
  • .iconBlueprint – Similar to RenderingMode.blueprint, but adds View type icons for known Views.

Set rendering mode

Smartlook.instance.preferences.renderingMode = .native
Smartlook.instance.preferences.renderingMode = .wireframe(.blueprint)

Read rendering mode

let renderingMode = Smartlook.instance.state.renderingMode

Default value

The default rendering mode is RenderingMode.native.

Adaptive frame rate

To lower requirements on the CPU, storage space, and network bandwidth, the SDK captures the screen only when there is something drawn in the application. This detection works well in typical native applications, but might be problematic when Metal or similar is used. Thus adaptive frame rate can be disabled.

Set adaptive frame rate

Smartlook.instance.preferences.useAdaptiveFramerate = false

Read adaptive frame rate

let isAdaptiveFrameRateEnabled = Smartlook.instance.state.useAdaptiveFramerate

Default value

By default, adaptive frame rate is enabled, thus the default value is true.

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 = EventTracking.default
Smartlook.instance.preferences.eventTracking = EventTracking.noTracking

Navigation events

All automatically detected navigation events can be enabled or disabled.

Smartlook.instance.preferences.eventTracking = EventTracking(trackUserInteraction: false)

Smartlook.instance.preferences.eventTracking = EventTracking()
Smartlook.instance.preferences.eventTracking?.trackNavigation = false

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.

Smartlook.instance.preferences.eventTracking = EventTracking()
Smartlook.instance.preferences.eventTracking?.trackUserInteraction = true
Smartlook.instance.preferences.eventTracking?.trackNavigation = true
Smartlook.instance.preferences.eventTracking?.trackRageClicks = true

Default value

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

Smartlook.instance.preferences.eventTracking = EventTracking.default