Custom event
Pre API 2.0
// Without properties
Smartlook.trackCustomEvent("sample_event");
// With properties
Smartlook.trackCustomEvent("sample_event", eventProperties: : Dictionary<string> = {});
Smartlook.trackCustomEvent("sample_event", "key", "value");
API 2.0
JSONObject
, Bundle
, etc. are no longer supported and Properties
are used.
// Without properties
Smartlook.instance.trackEvent("sample_event")
// With properties
import Smartlook, { Properties } from 'react-native-smartlook-analytics';
const properties = new Properties();
properties.putString("sample-key", "event");
Smartlook.instance.analytics.trackEvent("sample-event", 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("SampleScreen", viewState: Smartlook.ViewState);
API 2.0
ViewState
and ViewType
are no longer part of the API:
ViewState
is not needed because there 2 methodsenter
andexit
.ViewType
navigation events do not have any types and it's universal for all cases on both iOS and Android.
Smartlook.instance.analytics.trackNavigationEnter("SampleScreen");
Smartlook.instance.analytics.trackNavigationExit("SampleScreen");
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
Smartlook.setGlobalEventProperties(properties: {}, immutable: boolean);
Smartlook.setGlobalEventProperty(key: string, value: string, immutable: boolean);
API 2.0
Smartlook.instance.analytics.putStringEventProperty("sample-name", "sample-value");
const eventPropertyValue = await Smartlook.instance.analytics.getStringEventProperty("sample-name");
Smartlook.instance.analytics.removeEventProperty("sample-name");
Properties mutability
All event properties are now mutable. If immutability of certain properties is needed it must be ensured on the client-side.