public class Snowplow extends Object
| Constructor and Description |
|---|
Snowplow() |
| Modifier and Type | Method and Description |
|---|---|
static TrackerController |
createTracker(Context context,
String namespace,
NetworkConfiguration network,
Configuration... configurations)
Create a new tracker instance which will be used inside the app to track events.
|
static TrackerController |
createTracker(Context context,
String namespace,
String endpoint,
HttpMethod method)
Create a new tracker instance which will be used inside the app to track events.
|
static TrackerController |
getDefaultTracker()
The default tracker instance is the first created in the app, but that can be overridden programmatically
calling
setTrackerAsDefault(TrackerController). |
static Set<String> |
getInstancedTrackerNamespaces() |
static TrackerController |
getTracker(String namespace)
Using the namespace identifier is possible to get the trackerController if already instanced.
|
static void |
refresh(Context context,
androidx.core.util.Consumer<List<String>> onSuccess)
Reconfigure, create or delete the trackers based on the configuration downloaded remotely.
|
static void |
removeAllTrackers()
Remove all the trackers.
|
static boolean |
removeTracker(TrackerController trackerController)
A tracker can be removed from the active trackers of the app.
|
static boolean |
setTrackerAsDefault(TrackerController trackerController)
Set the passed tracker as default tracker if it's registered as an active tracker in the app.
|
static void |
setup(Context context,
RemoteConfiguration remoteConfiguration,
List<com.snowplowanalytics.snowplow.internal.remoteconfiguration.ConfigurationBundle> defaultBundles,
androidx.core.util.Consumer<List<String>> onSuccess)
Setup a single or a set of tracker instances which will be used inside the app to track events.
|
public static void setup(@NonNull
Context context,
@NonNull
RemoteConfiguration remoteConfiguration,
@Nullable
List<com.snowplowanalytics.snowplow.internal.remoteconfiguration.ConfigurationBundle> defaultBundles,
@Nullable
androidx.core.util.Consumer<List<String>> onSuccess)
context - The Android app context.remoteConfiguration - The remote configuration used to indicate where to download the configuration from.defaultBundles - The default configuration passed by default in case there isn't a cached version and it's able to download a new one.onSuccess - The callback called when a configuration (cached or downloaded) is set It passes the list of the namespaces associated
to the created trackers.public static void refresh(@NonNull
Context context,
@Nullable
androidx.core.util.Consumer<List<String>> onSuccess)
context - The Android app context.onSuccess - The callback called when a configuration (cached or downloaded) is set It passes the list of the namespaces associated
to the created trackers.@NonNull public static TrackerController createTracker(@NonNull Context context, @NonNull String namespace, @NonNull String endpoint, @NonNull HttpMethod method)
TrackerConfiguration(String)
To configure tracker with more details see createTracker(Context, String, NetworkConfiguration, Configuration...)
To use the tracker as singleton see getDefaultTracker()context - The Android app context.namespace - The namespace used to identify the current tracker among the possible
multiple tracker instances.endpoint - The URL of the collector.method - The method for the requests to the collector (GET or POST).@NonNull public static TrackerController createTracker(@NonNull Context context, @NonNull String namespace, @NonNull NetworkConfiguration network, @NonNull Configuration... configurations)
Configuration interface.
For the default configuration of the tracker see TrackerConfiguration(String)
The configurations are only for the setup of the tracker and *any change to the configuration
object properties will NOT change the tracker setup at runtime*.
To use the tracker as singleton see getDefaultTracker()context - The Android app context.namespace - The namespace used to identify the current tracker among the possible
multiple tracker instances.network - The NetworkConfiguration object with settings for the communication with the
collector.configurations - All the configuration objects with the details about the fine tuning of
the tracker.@Nullable public static TrackerController getDefaultTracker()
setTrackerAsDefault(TrackerController).@Nullable public static TrackerController getTracker(@NonNull String namespace)
namespace - The namespace that identifies the tracker.public static boolean setTrackerAsDefault(@NonNull
TrackerController trackerController)
removeTracker)
then it can't become the new default tracker and the operation fails.trackerController - The new default tracker.public static boolean removeTracker(@NonNull
TrackerController trackerController)
trackerController - The tracker controller to remove.public static void removeAllTrackers()
removeTracker(TrackerController)