public class AnalyticsClient
extends java.lang.Object
implements com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializable
AnalyticsEvent
objects are created, recorded, and submitted to the
Amazon Pinpoint Service. Recording Events Example:
// 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);
Submitting Events:
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)
A client to manage creating and sending analytics events.
|
Modifier and Type | Method and Description |
---|---|
void |
addGlobalAttribute(java.lang.String attributeName,
java.lang.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(java.lang.String eventType,
java.lang.String attributeName,
java.lang.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(java.lang.String metricName,
java.lang.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(java.lang.String eventType,
java.lang.String metricName,
java.lang.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 |
closeDB()
Closes the database
|
AnalyticsEvent |
createEvent(java.lang.String eventType)
Create an event with the specified eventType.
|
java.util.List<org.json.JSONObject> |
getAllEvents()
Returns a list of all events
|
java.lang.String |
getSessionId()
Get the current sessionId
|
long |
getSessionStartTime()
Get the session start time
|
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(java.lang.String attributeName)
Removes the specified attribute.
|
void |
removeGlobalAttribute(java.lang.String eventType,
java.lang.String attributeName)
Removes the specified attribute.
|
void |
removeGlobalMetric(java.lang.String metricName)
Removes the specified metric.
|
void |
removeGlobalMetric(java.lang.String eventType,
java.lang.String metricName)
Removes the specified metric.
|
void |
setCampaignAttributes(java.util.Map<java.lang.String,java.lang.String> campaign)
Deprecated.
|
void |
setSessionId(java.lang.String sessionId)
Sets the sessionId
|
void |
setSessionStartTime(long sessionStartTime)
Set the session start time
|
void |
submitEvents()
Submit all recorded events.
|
org.json.JSONObject |
toJSONObject() |
java.lang.String |
toString() |
void |
updateEventSourceGlobally(java.util.Map<java.lang.String,java.lang.String> attributes)
Replaces the current event source attributes (if any)
with a new set of event source attributes
|
public AnalyticsClient(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext context)
context
- The PinpointContext
of the Pinpoint Managerpublic AnalyticsEvent createEvent(java.lang.String eventType)
eventType
- the type of event to createpublic 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(java.lang.String attributeName, java.lang.String attributeValue)
attributeName
- the name of the attribute to addattributeValue
- the value of the attributepublic void addGlobalAttribute(java.lang.String eventType, java.lang.String attributeName, java.lang.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(java.lang.String metricName, java.lang.Double metricValue)
metricName
- the name of the metric to addmetricValue
- the value of the metricpublic void addGlobalMetric(java.lang.String eventType, java.lang.String metricName, java.lang.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(java.lang.String attributeName)
attributeName
- the name of the attribute to removepublic void removeGlobalAttribute(java.lang.String eventType, java.lang.String attributeName)
eventType
- the type of events to remove the attribute fromattributeName
- the name of the attribute to removepublic void removeGlobalMetric(java.lang.String metricName)
metricName
- the name of the metric to removepublic void removeGlobalMetric(java.lang.String eventType, java.lang.String metricName)
eventType
- the type of events to remove the metric frommetricName
- the name of the metric to remove@Deprecated public void setCampaignAttributes(java.util.Map<java.lang.String,java.lang.String> campaign)
updateEventSourceGlobally(Map)
campaign
- public void updateEventSourceGlobally(java.util.Map<java.lang.String,java.lang.String> attributes)
attributes
- map of attribute valuespublic java.lang.String toString()
toString
in class java.lang.Object
public org.json.JSONObject toJSONObject()
toJSONObject
in interface com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializable
public void closeDB()
public java.util.List<org.json.JSONObject> getAllEvents()
public java.lang.String getSessionId()
public void setSessionId(java.lang.String sessionId)
sessionId
- The sessionIdpublic long getSessionStartTime()
public void setSessionStartTime(long sessionStartTime)
sessionStartTime
- The sessionStartTimeCopyright © 2018 Amazon Web Services, Inc. All Rights Reserved.