Custom event
Pre API 2.0
// Without properties
Smartlook.trackCustomEvent(name: "sample_event")
// With properties
Smartlook.trackCustomEvent(name: "sample_name", props: ["key": "value"])
API 2.0
// Without properties
Smartlook.instance.track(event: "sample_event")
// With properties
let properties = Properties()
.setProperty("key_1", to: "value_1")
.setProperty("key_2", to: "value_2")
Smartlook.instance.track(event: "sample_event", properties: properties)
Event name restrictions
- Cannot be empty or
null
.- The maximum length is 200 characters.
- Contains only alphanumeric characters and “_”, " ", “.”, “-”.
- Must start with an alphabetic character.
An event with an incorrect
name
will be dropped.
Navigation event
Pre API 2.0
Smartlook.trackNavigationEvent(withControllerId: "SampleScreen")
Smartlook.trackNavigationEvent(withControllerId: "SampleScreen", type: .exit)
API 2.0
Smartlook.instance.track(navigationEvent: "SampleScreen")
Smartlook.instance.track(navigationEvent: "SampleScreen", direction: .exit)
Navigation event name restrictions
- Cannot be empty or
null
.- The maximum length is 200 characters.
- Contains only alphanumeric characters and “_”, " ", “.”, “-”.
- Must start with an alphabetic character.
An event with an incorrect
name
will be dropped.
Global event properties
Pre API 2.0
// set
Smartlook.setGlobalEventProperty(value: "sample_value", forName: "sample_name", options: .immutable)
Smartlook.setGlobalEventProperty(value: "sample_value", forName: "sample_name", immutable: true)
Smartlook.setGlobalEventProperty(value: "sample_value", forName: "sample_name")
// remove
Smartlook.removeGlobalEventProperty(forName: "sample_value")
// clear
Smartlook.clearGlobalEventProperties()
API 2.0
// set
Smartlook.instance.eventProperties["sample_name"] = "sample_value"
// remove
Smartlook.instance.eventProperties["sample_name"] = nil
// clear
Smartlook.instance.eventProperties = Properties()
Properties mutability
All event properties are now mutable. If immutability of certain properties is needed it must be ensured on the client-side.