Summary:
This document contains information regarding the Tracker Class for the Android SDK. Contents include:
Tracker Class Summary
com.bluetriangle.analytics
Class Tracker
java.lang.Object
com.bluetriangle.analytics.Tracker
public class Tracker
extends java.lang.Object
The tracker is a global object responsible for taking submitted timers and reporting them to the cloud server via a background thread.
Field Summary
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BROWSER
The hardcoded browser
|
private java.lang.ref.WeakReference<android.content.Context> |
context
Weak reference to Android application context
|
private java.util.Map<java.lang.String,java.lang.String> |
globalFields
A map of fields that should be applied to all timers such as
|
private static Tracker |
instance
Singleton instance of the tracker
|
private static java.lang.String |
SHARED_PREFERENCES_NAME |
private static java.lang.String |
SITE_ID_RESOURCE_KEY
String resource name for the site ID
|
private static java.lang.String |
TRACKER_URL
Default URL to submit the timer data to
|
private TrackerExecutor |
trackerExecutor
Executor service to queue and submit timers
|
private java.lang.String |
trackerUrl
URL to submit timers to
|
Field Detail
SHARED_PREFERENCES_NAME
private static final java.lang.String SHARED_PREFERENCES_NAME
SITE_ID_RESOURCE_KEY
private static final java.lang.String SITE_ID_RESOURCE_KEY
String resource name for the site ID
TRACKER_URL
private static final java.lang.String TRACKER_URL
Default URL to submit the timer data to
BROWSER
private static final java.lang.String BROWSER
The hardcoded browser
instance
private static Tracker instance
Singleton instance of the tracker
context
private final java.lang.ref.WeakReference<android.content.Context> context
Weak reference to Android application context
globalFields
private final java.util.Map<java.lang.String,java.lang.String> globalFields
A map of fields that should be applied to all timers such as
trackerUrl
private final java.lang.String trackerUrl
URL to submit timers to
trackerExecutor
private final TrackerExecutor trackerExecutor
Executor service to queue and submit timers
Constructor Detail
Tracker
private Tracker(@NonNull android.content.Context context, @NonNull java.lang.String siteId, @NonNull java.lang.String trackerUrl)
Method Detail
init
public static Tracker init(@NonNull android.content.Context context)
Initialize the tracker with default tracker URL and Site ID from string resources.
- Parameters:
context
- application context- Returns:
- the initialized tracker
init
public static Tracker init(@NonNull android.content.Context context,
@Nullable java.lang.String siteId)
Initialize the tracker with default tracker URL and given Site ID
- Parameters:
context
- application contextsiteId
- Site ID to send with all timers- Returns:
- the initialized tracker
init
public static Tracker init(@NonNull android.content.Context context, @Nullable java.lang.String siteId, @Nullable java.lang.String trackerUrl)
Initialize the tracker with given tracker URL and site ID
- Parameters:
context
- application contextsiteId
- Site ID to send with all timerstrackerUrl
- the URL to submit timer data- Returns:
- the initialized tracker
getInstance
public static Tracker getInstance()
Gets the singleton tracker instance to submit timers to. If not setup via the builder, it will be null.
- Returns:
- Singleton tracker instance or null if not built yet.
getOrCreateGlobalUserId
private java.lang.String getOrCreateGlobalUserId()
Get the stored global user ID or generate and persist if not found
- Returns:
- the global user ID
submitTimer
public void submitTimer(@NonNull Timer timer)
Submit a timer to the tracker to be sent to the cloud server.
If the timer has not been ended, it will be ended on submit.
- Parameters:
timer
- The timer to submit
setSessionId
public void setSessionId(@NonNull java.lang.String sessionId)
set the current session ID for this tracker
- Parameters:
sessionId
- session ID to send with all timers submitted
setGlobalUserId
public void setGlobalUserId(@NonNull java.lang.String globalUserId)
set the global user ID for this tracker
- Parameters:
globalUserId
- the global user ID to send with all timers submitted
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, @NonNull java.lang.String value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, int value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, double value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, float value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, boolean value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
setGlobalField
public void setGlobalField(@NonNull java.lang.String fieldName, long value)
Set a global field to be applied to all trackers
- Parameters:
fieldName
- the name of the fieldvalue
- the value to set for the given field
getGlobalField
public java.lang.String getGlobalField(@NonNull java.lang.String fieldName)
Get the current value of a global field
- Parameters:
fieldName
- the name of the field to get- Returns:
- the value of the given field name or null if doesn't exist
clearGlobalField
public void clearGlobalField(@NonNull java.lang.String fieldName)
Clear a global field from being set on all trackers
Parameters:
fieldName
- the name of the field to remove
Comments
0 comments
Please sign in to leave a comment.