You should initialize the SDK in a central location and store it in a variable
for use across your application. For example, you may want to initialize it in
your application's onCreate callback. After initialization, you can use the
SDK anywhere you import the Analytics class via the singleton instance.
By default, Highotuch automatically collects context such as the device
operating system. This context is forwarded with each event.
To modify the context sent with each event, modify the context dictionary
returned by getAnalyticsContext(). You may add additional values, as well as
remove default metadata.
You may also override the context in individual event calls. See the per-event
methods for more information.
The identify method sends an identify event. It accepts user id and trait
information for the current user -- if you only have partial information, you
can just supply a single parameter.
Java method signature:
Analytics.with(context).identify("userId", new Traits().putEmail("email"), null);
The screen method sends a screen event. The screen title is required, and
additional information about the screen's category and properties may be
supplied.
Java method signature:
Analytics.with(context).screen("category", "name", new Properties().putValue("custom", "property"), null);
The Android SDK buffers events locally before sending them to Hightouch's servers.
This minimizes the number of requests made by the SDK and makes the tracking
non-blocking.
To force the local buffer to be sent to Hightouch immediately call the flush
method.
The reset method resets the identify and group for the local session.
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.