public class AnalyticsEvent extends Object implements com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializable
The example below demonstrates how to record events.
// get the event client from your amazon PinpointManager instance
EventClient analyticsClient = mobileAnalyticsManager.getAnalyticsClient();
// create and record the view event
Event level1CompleteEvent = analyticsClient.createEvent("level1Complete");
analyticsClient.recordEvent(level1CompleteEvent);
// record if the user bought an upgrade (conversion)
if (userBoughtUpgrade) {
Event level1UserBoughtUpgradeEvent = analyticsClient.createEvent("level1UserBoughtUpgrade");
analyticsClient.recordEvent(level1UserBoughtUpgradeEvent);
}
public static AnalyticsEvent createFromEvent(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext context, String sessionId, long timestamp, AnalyticsEvent copyEvent)
public static AnalyticsEvent newInstance(com.amazonaws.mobileconnectors.pinpoint.internal.core.PinpointContext context, String sessionId, Long sessionStart, Long sessionEnd, Long duration, long timestamp, String eventType)
public static AnalyticsEvent newInstance(String eventId, String eventType, Map<String,String> attributes, Map<String,Double> metrics, com.amazonaws.mobileconnectors.pinpoint.internal.core.util.SDKInfo sdkInfo, String sessionId, Long sessionStart, Long sessionStop, Long sessionDuration, long timestamp, String uniqueId, com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidAppDetails appDetails, com.amazonaws.mobileconnectors.pinpoint.internal.core.system.AndroidDeviceDetails deviceDetails)
public String getEventId()
public void addAttribute(String name, String value)
AnalyticsEvent with the specified key.
Only 40 attributes/metrics are allowed to be added to an Event. If 40
attribute/metrics already exist on this Event, the call may be ignored.name - The name of the attribute. The name will be truncated if it
exceeds 50 characters.value - The value of the attribute. The value will be truncated if
it exceeds 200 characters.public boolean hasAttribute(String attributeName)
AnalyticsEvent contains a specific attributeattributeName - The name of the attributeAnalyticsEvent has an attribute with the
specified name, false otherwisepublic void addMetric(String name, Double value)
AnalyticsEvent with the specified key. Only
40 attributes/metrics are allowed to be added to an Event. If 50
attribute/metrics already exist on this Event, the call may be ignored.name - The name of the metric. The name will be truncated if it
exceeds 50 characters.value - The value of the metric.public boolean hasMetric(String metricName)
AnalyticsEvent contains a specific metric.metricName - The name of the metricAnalyticsEvent has a metric with the
specified name, false otherwisepublic String getEventType()
AnalyticsEventAnalyticsEventpublic String getAttribute(String name)
name - The name of the attribute to returnpublic Double getMetric(String name)
name - The name of the metric to returnpublic PinpointSession getSession()
public Long getEventTimestamp()
public String getUniqueId()
public String getSdkName()
public String getSdkVersion()
public AnalyticsEvent withAttribute(String name, String value)
AnalyticsEvent with the specified key.
Only 40 attributes/metrics are allowed to be added to an
AnalyticsEvent. If 40 attribute/metrics already exist on this
AnalyticsEvent, the call may be ignored.name - The name of the attribute. The name will be truncated if it
exceeds 50 characters.value - The value of the attribute. The value will be truncated if
it exceeds 200 characters.AnalyticsEvent instance is returned to allow for
method chaining.public AnalyticsEvent withMetric(String name, Double value)
AnalyticsEvent with the specified key. Only
40 attributes/metrics are allowed to be added to an
AnalyticsEvent. If 40 attribute/metrics already exist on this
AnalyticsEvent, the call may be ignored.name - The name of the metric. The name will be truncated if it
exceeds 50 characters.value - The value of the metric.AnalyticsEvent instance is returned to allow for
method chaining.public Map<String,String> getAllAttributes()
AnalyticsEventpublic Map<String,Double> getAllMetrics()
AnalyticsEventpublic org.json.JSONObject toJSONObject()
toJSONObject in interface com.amazonaws.mobileconnectors.pinpoint.internal.core.util.JSONSerializablepublic com.amazonaws.mobileconnectors.pinpoint.internal.event.ClientContext createClientContext(String networkType)
public static org.json.JSONObject translateFromEvent(AnalyticsEvent source)
public static AnalyticsEvent translateToEvent(org.json.JSONObject source) throws org.json.JSONException
org.json.JSONExceptionCopyright © 2016. All rights reserved.