Skip to content

IOS - Configuration

The SDK is configurable at the start time. You can set a large set of options to customize how the SDK works.

The following section describes the usage of the Obsly SDK.

Initialize the sdk using ObslyOptions, this parameter is optional, if ObslyOptions is null, default options will be applied. (all modules deactivated).

Initialize Obsly early in didFinishLaunchingWithOptions, make sure to init the SDK, after the app launch, you can change the startup options later using updateOptions.

Example

    import ObslySDK
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

    let obsly = Obsly(apiKey: apiKey) { options in
    options.isCrasherEnabled = true
    options.isLifeCycleEnabled = true
    options.isRequestEnabled = true
    options.isTaggerEnabled = true
    }
    ....
    return true
    }

Start

Explicación

public func start()

Example

    obsly.start()

Update Options

You can update de Options anytime to change Obsly behaviour, if you send .updateOptions{ _ in} you can disable all the options. Review all the possible options in ObslyOptions

public func updateOptions(_ closure: (inout ObslyOptions) -> Void)

Example

    let osblyOptions: ObslyOptions = ObslyOptions()

    print(obslyOptions.isCrasherEnabled) // "false"
    obslyOptions.isCrasherEnabled = true

    obsly.updateOptions(obslyOptions)
    print(obslyOptions.isCrasherEnabled) // "true"

Create New Session

Obsly, automatically create a new Session when it's initialized, this method can be useful if you want to start "manually" a new sesion, in some scenarios will be useful to create a sesion when the users login. you can set the name of the session.

public func createNewSession(name: String?)
Parameter
Description
name: String? The name of the session

Example

    obsly.createNewSession(name: "newSession")

Close Current Session

You can close the current session, and obsly automatically creates a new one, if you want to limite you sessions duration you close using this method.

public func closeCurrentSession()

Example

    obsly.closeCurrentSession()

Set Environment

Set the session variable Environment, this value is used to filter and find sessions, you can set the development environment like 'DEV', 'PRO' etc

 public func set(environment: String)
Parameter
Description
environment: String The name of the Environment

Example

    obsly.set(environment:"DEV")

Set Release

Set the session variable release, this value is used to filter and find sessions, you can use a major, minor version like '4.2' to group diferent versions.

public func set(release: String)
Parameter
Description
release: String The name of the Release

Example

    obsly.set(release:"4.2")

Identifying Users

You can identify Users in different ways, Obsly doesn't add personal information to the events that collects. We strongly recommend use hash for all the information that will be sended to Obsly, to find/identify a session or user, you have a lot of ways to do it. You can use InstallationID (getUUID()) to find the unique id for this installation, and you can set up to 4 ID's, userID, personID, PassportID and contractID

all the ID's are optional

Remember, all this id's are optional, you can find the session or crashes using a filters, like device, model, number, app version more than 20 filters to find any session

Set User ID

Set the session variable UserID, this value is used to filter and find sessions.

public func set(userID: String?)
Parameter
Description
User: String? The User name

Example

    obsly.set(userID:"userIDexample")

Set Person ID

Set the session variable personID, this value is used to filter and find sessions.

public func set(personID: String?)
Parameter
Description
personID: String? The Person ID if available

Example

    obsly.set(personID:"personIDexample")

Set Passport ID

Set the session variable passportID, this value is used to filter and find sessions.

public func set(passportID: String?)
Parameter
Description
passportID: String? The passport string

Example

    obsly.set(passportID:"passaportIDexample")

Set Contract ID

Set the session variable contractID, this value is used to filter and find sessions.

public func set(contractID: String?)
Parameter
Description
contractID: String? The ContractID string

Example

    obsly.set(contractID:"contractIDexample")

Set Appp Name

Explicación

public func set(appName: String?)
Parameter
Description
appName: String? The AppName string

Example

    obsly.set(appName:"appNameExample")

Set Request Capture

Explicación

public func setRquestCapture(models: [RequestCaptureModel]) -> String?

struct RequestCaptureModel {
    let url: String
    let captureCodesRange: ClosedRange<Int>
    let captureResponseBody: Bool
    let captureRequestBody: Bool
}
Parameter
Description
models: [RequestCaptureModel] array of objects of type 'Request Capture Model'

Example

    let request = RequestCaptureModel(
            url: "https://www.example.com",
            captureCodesRange: 200...300,
            captureResponseBody: true,
            captureRequestBody: false
    )

    obsly.setRquestCapture(models: request)

Set Request Blacklist

Allows to set a list of hosts that be blacklisted, the http request to this hosts will not be tracked.

public func setRequestBlacklist(hosts: [String])
Parameter
Description
hosts: [String] array of hosts ignored

Example

    let hosts: [String] = ["host1.com", "host2.com", "host3.com"]

    obsly.setRequestBlacklist(hosts: hosts)

Get Obsly UUID

Returns de unique installation identifier for this installation, this number is unique for each installation of the Obsly sdk.

public func getObslyUUID() -> String?

Example

    let UUID = obsly.getOblsyUUID()

Get Translation

Explicación

public func getTranslation(lenguageCode: String, key: String) -> String?
Parameter
Description
lenguageCode: String Lenguage code ("es", "en")
key: String Text to translate

Example

    let translatedText = obsly.getTranslation(lenguageCode: "en",key:"Hola")

    print(translatedText) // Hello

Add Tags

Add an dictionary of custom tags (key-value) and optionally a category for this custom tags, the 2 values are optional

public func add(tags: [String: String]?, category: String?)
Parameter
Description
[String: String]? Dictionary of Tags
category: String? Optional Category to group tags

Example

    obsly.add (tags:"biometria","activada",category:"app.login")