Class: Client

Client

new Client(options)

Parameters:
Name Type Description
options AMA.Client.Options A configuration map for the AMA.Client
Source:
Returns:
A new instance of the Mobile Analytics Mid Level Client

Methods

createEvent(eventType, session, attributes=, metrics=) → {AMA.Event}

AMA.Client.createEvent
Parameters:
Name Type Argument Description
eventType string Custom Event Type to be displayed in Console
session AMA.Session Session Object (required for use within console)
Properties
Name Type Description
id string Identifier for current session
startTimestamp string Timestamp that indicates the start of the session
attributes= <optional>
Custom attributes
metrics= <optional>
Custom metrics
Source:
Returns:
Type
AMA.Event

pushEvent(event) → {int}

AMA.Client.pushEvent
Parameters:
Name Type Description
event AMA.Event event to be pushed onto queue
Source:
Returns:
Index of event in outputs.events
Type
int

recordEvent(eventType, session, attributes=, metrics=) → {AMA.Event}

Helper to record events, will automatically submit if the events exceed batchSizeLimit
Parameters:
Name Type Argument Description
eventType string Custom event type name
session AMA.Session Session object
attributes= AMA.Client.Attributes <optional>
Custom attributes
metrics= AMA.Client.Metrics <optional>
Custom metrics
Source:
Returns:
The event that was recorded
Type
AMA.Event

recordMonetizationEvent(session, monetizationDetails, attributes=, metrics=) → {event}

recordMonetizationEvent
Parameters:
Name Type Argument Description
session
monetizationDetails Object Details about Monetization Event
Properties
Name Type Description
currency string ISO Currency of event
productId string Product Id of monetization event
quantity number Quantity of product in transaction
price string | number Price of product either ISO formatted string, or number with associated ISO Currency
attributes= AMA.Client.Attributes <optional>
Custom attributes
metrics= AMA.Client.Metrics <optional>
Custom metrics
Source:
Returns:
The event that was recorded
Type
event

submitEvents(options=) → {Array}

submitEvents
Parameters:
Name Type Argument Default Description
options= Object <optional>
options for submitting events
options.clientContext Object <optional>
this.options.clientContext clientContext to submit with defaults to options.clientContext
options.submitCallback SubmitCallback <optional>
this.options.submitCallback Callback function that is executed when events are successfully submitted
Source:
Returns:
Array of batch indices that were submitted
Type
Array

Type Definitions

Attributes

A collection of key-value pairs that give additional context to the event. The key-value pairs are specified by the developer.
Type:
  • object
Source:

Event

A JSON object representing an event occurrence in your app and consists of the following:
Type:
  • object
Properties:
Name Type Argument Description
eventType string A name signifying an event that occurred in your app. This is used for grouping and aggregating like events together for reporting purposes.
timestamp string The time the event occurred in ISO 8601 standard date time format. For example, 2014-06-30T19:07:47.885Z
attributes= AMA.Client.Attributes <optional>
A collection of key-value pairs that give additional context to the event. The key-value pairs are specified by the developer. This collection can be empty or the attribute object can be omitted.
metrics= AMA.Client.Metrics <optional>
A collection of key-value pairs that gives additional measurable context to the event. The pairs specified by the developer.
session AMA.Session Describes the session. Session information is required on ALL events.
Source:

Logger

Uses Javascript Style log levels, one function for each level. Basic usage is to pass the console object which will output directly to browser developer console.
Properties:
Name Type Argument Description
log= function <optional>
Logger for client log level messages
info= function <optional>
Logger for interaction level messages
warn= function <optional>
Logger for warn level messages
error= function <optional>
Logger for error level messages
Source:

Metrics

A collection of key-value pairs that gives additional measurable context to the event. The pairs specified by the developer.
Type:
  • object
Source:

Options

Properties:
Name Type Argument Default Description
appId string The Application ID from the Amazon Mobile Analytics Console
apiVersion string <optional>
2014-06-05 The version of the Mobile Analytics API to submit to.
provider object <optional>
AWS.config.credentials Credentials to use for submitting events. **Never check in credentials to source control.
autoSubmitEvents boolean <optional>
true Automatically Submit Events, Default: true
autoSubmitInterval number <optional>
10000 Interval to try to submit events in ms, Default: 10s
batchSizeLimit number <optional>
256000 Batch Size in Bytes, Default: 256Kb
submitCallback= AMA.Client.SubmitCallback <optional>
Callback function that is executed when events are successfully submitted
globalAttributes= AMA.Client.Attributes <optional>
Attribute to be applied to every event, may be overwritten with a different value when recording events.
globalMetrics= AMA.Client.Metrics <optional>
Metric to be applied to every event, may be overwritten with a different value when recording events.
clientId string <optional>
GUID() A unique identifier representing this installation instance of your app. This will be managed and persisted by the SDK by default.
appTitle= string <optional>
The title of your app. For example, My App.
appVersionName= string <optional>
The version of your app. For example, V2.0.
appVersionCode= string <optional>
The version code for your app. For example, 3.
appPackageName= string <optional>
The name of your package. For example, com.example.my_app.
platform= string <optional>
The operating system of the device. For example, iPhoneOS.
plaformVersion= string <optional>
The version of the operating system of the device. For example, 4.0.4.
model= string <optional>
The model of the device. For example, Nexus.
make= string <optional>
The manufacturer of the device. For example, Samsung.
locale= string <optional>
The locale of the device. For example, en_US.
logger= AMA.Client.Logger <optional>
Object of logger functions
storage= AMA.Storage <optional>
Storage client to persist events, will create a new AMA.Storage if not provided
clientOptions= Object <optional>
Low level client options to be passed to the AWS.MobileAnalytics low level SDK
Source:

SubmitCallback(err, data, batchId)

Parameters:
Name Type Description
err Error
data Null
batchId string
Source: