Skip to main content

iOS

Percept iOS SDK

Setup​

Using SPM​

Add Percept as a dependency in your Package.swift file

dependencies: [
.package(url: "https://github.com/udaan-com/percept-ios.git", from: "1.0.2")
],

Using CocoaPods​

Add it to your podfile

pod "Percept", "~> 1.0.2"

Usage​

import Percept

let config = PerceptConfig(apiKey: apiKey)
Percept.shared.setup(config)

Change the default configuration​

let config = PerceptConfig(apiKey: apiKey)
config.captureAppLifecycleEvents = false
config.debug = true
// .. and more

Capture an event​

Percept.shared.capture("Add To Cart", properties: ["item_name": "product name"])

Set user id​

Percept.shared.setUserId("testUser", withPerceptUserProps: [PerceptUserProperty.NAME: "John Doe"], additionalProps: ["isVerified": false])

We expose some default user property keys in PerceptUserProperty. Please use them as this helps in standarization and usage in the Engage feature provided by Percept.

You can set user properties post setting user id too by calling setCurrentUserProperties method.

Percept.shared.setCurrentUserProperties(withPerceptUserProps: [PerceptUserProperty.NAME: "John Doe"], additionalProps: ["isVerified": false])

Set global properties​

Percept.shared.setGlobalProperties(["tenant": "percept"])

Get global properties​

Percept.shared.getGlobalProperties(["tenant": "percept"])

Remove global property​

Percept.shared.removeGlobalProperty("tenant")

Clear​

This will clear all user info and cached data. Call clear function on logout to delete all user related information

Percept.shared.clear()

Close the SDK​

Percept.shared.close()

Events auto tracked by sdk​

event nameparameter key to controldescription
App OpenedautoCaptureAppLifecycleEventsTriggered when percept sdk is initialized
App ActiveautoCaptureAppLifecycleEventsTriggered when app comes to foreground
App BackgroundedautoCaptureAppLifecycleEventsTriggered when app goes to background
Application InstalledautoCaptureAppLifecycleEventsTriggered when app is installed for the first time
Application UpdatedautoCaptureAppLifecycleEventsTriggered when app is updated

Custom app and device properties attached by SDK​

These properties are available in all events

propertydescription
pi_app_buildBuild number like "2.3.7" or "237"
pi_app_nameApplication name
pi_app_versionHuman friendly app version like "2.3.7"
pi_device_manufacturer'Apple'
pi_device_nameDevice model name
pi_os_nameOperating system name like iOS or Android
pi_os_versionOperating system version "7.1.3"
pi_cityCity of the user
pi_countryCity of the user