Skip to content

udaan-com/percept-ios

Repository files navigation

percept-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.0")
],

Using CocoaPods

Add it to your podfile

pod "Percept", "~> 1.0.0"

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()