Skip to content

API

The LiteratorClient singleton provides additional functionality beyond recording. These methods are available after the SDK is initialized. Refer to the initialization instructions to get started.

Analytics

In order to forward analytics calls, please reference the below APIs invoked on LiteratorClient.

Method Description
sendAnalytics(eventName: String, properties: Encodable) Forward analytics using an eventName and any Encodable piece of data
sendAnalytics(eventName: String, properties: Encodable, tag: String) Forward analytics with an additional tag field

Example

Below is an example with an Analytics wrapper that forwards calls to Literal.

import Foundation
import Literator
import Amplitude

enum Analytics {
    func trackEvent(eventName: String, properties: [String: String]) {
        // Example call to Amplitude
        Amplitude.instance().logEvent(eventName, withEventProperties: properties)

        // Option 1: Forward analytics to Literal without tag
        LiteratorClient.sendAnalytics(eventName: eventName, properties: properties)

        // Option 2: Include an optional tag ("amplitude") for the analytics provider of choice
        LiteratorClient.sendAnalytics(eventName: eventName, properties: properties, tag: "amplitude")
    }
}

App build identifier

A unique app board is created according to these criteria:

  • App name
  • App version
  • Operating system

Screens from recordings with the same criteria will appear on the same board. However, you may override the standard behavior by providing a custom build identifier.

Use custom identifier

During regular development cycles, it's common to retain the existing app version until a new app store release is created. This means that new app content may appear on the same board unintentionally.

The standard board behavior can be overridden by providing a custom app identifier. A common example is to use the current date or a commit SHA by storing the value in info.plist during the build phase.

To create a separate board per commit hash, grab the value from the main Bundle and pass it to customBuildIdentifier().

    let gitSha = Bundle.main.object(forInfoDictionaryKey: "GIT_COMMIT_SHA")
    let literatorConfig = LiteratorConfig.builder()
        .customBuildIdentifier(gitSha)
        .build()

    LiteratorClient.start(token, application, literatorConfig)    

Use device model

To create a separate board per unique device model, leverage useDeviceAsBuildIdentifier which relies on UiDevice.name internally.

val literatorConfig = LiteratorConfig.builder()
    .useDeviceAsBuildIdentifier()
    .build()

LiteratorClient.start(token, application, literatorConfig)