public class AnalyticsClient extends Object implements com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializable
AnalyticsEvent objects are created, recorded, and submitted to the
Amazon Pinpoint Service.
// get the event client from your PinpointManager instance
AnalyticsClient analyticsClient = pinpointManager.getAnalyticsClient();
// create and record an event
Event level1CompleteEvent = analyticsClient.createEvent("level1Complete");
analyticsClient.recordEvent(level1CompleteEvent);
The example below demonstrates how to submit events to the Amazon Pinpoint Service. You have direct control over when events are submitted in your app. Events are submitted in a background thread.
Example:// submit events to the website AnalyticsClient analyticsClient = pinpointManager.getAnalyticsClient(); analyticsClient.submitEvents();Amazon recommends that you call
submitEvents once you stop the session.
Note: This client will store at most 5MiB of event data locally. Past that events will be dropped. When events successfully submitted, they are removed from the local database.
| Constructor and Description |
|---|
AnalyticsClient(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addGlobalAttribute(String attributeName,
String attributeValue)
Adds the specified attribute to all subsequently created events Note: The
maximum allowed attributes and metrics on a single event is 40.
|
void |
addGlobalAttribute(String eventType,
String attributeName,
String attributeValue)
Adds the specified attribute to all subsequently created events with the
specified event type Note: The maximum allowed attributes and metrics on
a single event is 40.
|
void |
addGlobalMetric(String metricName,
Double metricValue)
Adds the specified metric to all subsequently created events Note: The
maximum allowed attributes and metrics on a single event is 40.
|
void |
addGlobalMetric(String eventType,
String metricName,
Double metricValue)
Adds the specified metric to all subsequently created events with the
specified event type Note: The maximum allowed attributes and metrics on
a single event is 40.
|
void |
clearCampaignAttributes()
Clears campaign attributes
You should not use this method as it will be called by the NotificationManager when the app is opened
from a push notification.
|
void |
closeDB() |
AnalyticsEvent |
createEvent(String eventType)
Create an event with the specified eventType.
|
protected AnalyticsEvent |
createEvent(String eventType,
long sessionStart,
Long sessionEnd,
Long sessionDuration) |
String |
getSessionId() |
long |
getSessionStartTime() |
void |
recordEvent(AnalyticsEvent event)
Record the specified event to the local filestore Please note if the
amount of data stored events takes up EXCEEDS 5MiB further recordings
will be dropped
|
void |
removeGlobalAttribute(String attributeName)
Removes the specified attribute.
|
void |
removeGlobalAttribute(String eventType,
String attributeName)
Removes the specified attribute.
|
void |
removeGlobalMetric(String metricName)
Removes the specified metric.
|
void |
removeGlobalMetric(String eventType,
String metricName)
Removes the specified metric.
|
void |
setCampaignAttributes(Map<String,String> campaign)
Adds the specified campaign attributes to events to track Campaign Analytic
You should not use this method as it will be called by the NotificationManager when the app is opened
from a push notification.
|
void |
setSessionId(String sessionId) |
void |
setSessionStartTime(long sessionStartTime) |
void |
submitEvents()
Submit all recorded events.
|
org.json.JSONObject |
toJSONObject() |
String |
toString() |
public AnalyticsClient(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext context)
public AnalyticsEvent createEvent(String eventType) throws IllegalArgumentException
eventType - the type of event to createIllegalArgumentExceptionprotected AnalyticsEvent createEvent(String eventType, long sessionStart, Long sessionEnd, Long sessionDuration)
public void recordEvent(AnalyticsEvent event)
event - The event to persistpublic void submitEvents()
PinpointConfiguration
for customizing which Internet connection the SDK can submit on.public void addGlobalAttribute(String attributeName, String attributeValue)
attributeName - the name of the attribute to addattributeValue - the value of the attributepublic void addGlobalAttribute(String eventType, String attributeName, String attributeValue)
eventType - the type of events to add the attribute toattributeName - the name of the attribute to addattributeValue - the value of the attributepublic void addGlobalMetric(String metricName, Double metricValue)
metricName - the name of the metric to addmetricValue - the value of the metricpublic void addGlobalMetric(String eventType, String metricName, Double metricValue)
eventType - the type of events to add the metric tometricName - the name of the metric to addmetricValue - the value of the metricpublic void removeGlobalAttribute(String attributeName)
attributeName - the name of the attribute to removepublic void removeGlobalAttribute(String eventType, String attributeName)
eventType - the type of events to remove the attribute fromattributeName - the name of the attribute to removepublic void removeGlobalMetric(String metricName)
metricName - the name of the metric to removepublic void removeGlobalMetric(String eventType, String metricName)
eventType - the type of events to remove the metric frommetricName - the name of the metric to removepublic void setCampaignAttributes(Map<String,String> campaign)
campaign - the map with campaign attributes of the campaign receivedpublic void clearCampaignAttributes()
public org.json.JSONObject toJSONObject()
toJSONObject in interface com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializablepublic void closeDB()
public void setSessionId(String sessionId)
public void setSessionStartTime(long sessionStartTime)
public String getSessionId()
public long getSessionStartTime()
Copyright © 2016. All rights reserved.