iOS
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 name | parameter key to control | description |
---|---|---|
App Opened | autoCaptureAppLifecycleEvents | Triggered when percept sdk is initialized |
App Active | autoCaptureAppLifecycleEvents | Triggered when app comes to foreground |
App Backgrounded | autoCaptureAppLifecycleEvents | Triggered when app goes to background |
Application Installed | autoCaptureAppLifecycleEvents | Triggered when app is installed for the first time |
Application Updated | autoCaptureAppLifecycleEvents | Triggered when app is updated |
Custom app and device properties attached by SDK
These properties are available in all events
property | description |
---|---|
pi_app_build | Build number like "2.3.7" or "237" |
pi_app_name | Application name |
pi_app_version | Human friendly app version like "2.3.7" |
pi_device_manufacturer | 'Apple' |
pi_device_name | Device model name |
pi_os_name | Operating system name like iOS or Android |
pi_os_version | Operating system version "7.1.3" |
pi_city | City of the user |
pi_country | City of the user |