The client can either be passed around explicitly throughout your app, or
exposed through a React context
hook. To pass the
context through a Context, use AnalyticsProvider and useAnalytics.
import { AnalyticsProvider } from'@ht-sdks/events-sdk-react-native';
// The Child component can retrieve the htClient by calling `useAnalytics()`.constApp = () => (
<AnalyticsProviderclient={htClient}><Child /></AnalyticsProvider>
);
The client may be configured with the following options:
Parameter
Type
Description
writeKey
String
The write key used to identify the source in Hightouch.
collectDeviceId
Boolean
Whether to autocollect a device ID via the Android DRM API. The ID is stored in context.device.id on all events. This is only supported on Android, and is disabled by default.
debug
Boolean
Whether to generate debug logs. Defaults to true.
logger
Logger
Custom logger instance to redirect internal logging from the library.
flushAt
Number
Maximum number of events to accumulate before sending to the Hightouch API. Defaults to 20.
flushInterval
Number
Maximum number of seconds to hold events before sending to the Hightouch API. Defaults to 30.
flushPolicies
Array
Optional advanced customization for how events are buffered before sending to the Hightouch API.
maxBatchSize
Number
The maximum number of events to send in one HTTP request to the Hightouch API. You may want to adjust this if your events are extremely large. Defaults to 1000.
trackAppLifecycleEvents
Boolean
Whether to automatically track lifecycle events like Application Installed. Defaults to false.
trackDeepLinks
Boolean
Whether to automatically track deep links. Only supported for Android. Defaults to false.
proxy
String
Used to override the URL used for sending events to Hightouch. This should contain the full path, e.g. https://us-east-1.hightouch-events.com/v1/batch
The reset method resets the identify calls for the local session.
Specifically, it resets the anonymousId, userId, and traits.
The reset method should be called when users log out. This way, if the user
logs back in with another account, the userIds and traits from the different
sessions remain separate.
To collect IDFAs and AAIDs for advertising identification, you may use the
@ht-sdks/events-sdk-react-native-plugin-advertising-id and
@ht-sdks/events-sdk-react-native-plugin-idfa packages.
These plugins load native modules that pull the local advertising ID.
Add the plugin to your code by adding the following code after initializing your client.
htClient.add({plugin: new IdfaPlugin()});
Update your Info.plist to set
NSUserTrackingUsageDescription.
This description will be displayed when prompting users for permission to
track their IDFA.
Ready to get started?
Jump right in or a book a demo. Your first destination is always free.