aws-sdk-mobile-analytics
v0.9.2
Published
AWS Mobile Analytics SDK for JavaScript
Downloads
1,901
Readme
Amazon Mobile Analytics SDK for JavaScript
Developer Preview: We welcome developer feedback on this project. You can reach us by creating an issue on the GitHub repository or posting to the Amazon Mobile Analytics forums:
- https://github.com/aws/aws-sdk-mobile-analytics-js
- https://forums.aws.amazon.com/forum.jspa?forumID=174
Introduction
The Mobile Analytics SDK for JavaScript allows JavaScript enabled applications to create and submit events for analysis in the AWS Console and through Auto Export to S3 and Redshift. The library uses the browser's local storage API to create a local cache for the data, allowing your web application to batch and record events even when the app is offline.
Setup
- Download and include the AWS JavaScript SDK (minimum version 2.1.18):
- http://aws.amazon.com/sdk-for-browser/
- Download and include the Amazon Mobile Analytics SDK for JavaScript:
Usage
Step 1. Log in to the Amazon Mobile Analytics management console and create a new app. Be sure to note your App Id and Cognito Identity Pool Id.
- https://console.aws.amazon.com/mobileanalytics/home/?region=us-east-1
Step 2. Initialize the credentials provider using a Cognito Identity Pool ID. This is necessary for the AWS SDK to manage authentication to the Amazon Mobile Analytics REST API.
Step 3. Instantiate the Mobile Analytics Manager, including your App ID generated in Step 1, above. Session events will be automatically recorded and the client will batch and automatically submit events to Amazon Mobile Analytics every 10 seconds.
To manually force an event submission you can call:
Additional Options
Custom Events
You can optionally add custom events to capture additional information you find valuable.
Session Settings
By default a session lasts 10 minutes. You can override this default setting when initializing the Mobile Analytics Manager by including "sessionLength" in the "options" object.
A session's timeout can also be updated to allow for continuation of a session.
Record Monetization Event
You can record monetization events to enable reports such as Average Revenue Per User (ARPU) and more.
Add App Details to Events
Additional app and environment details can be added to the "options" object when initializing the SDK. These details will be captured and applied to all events and can be useful if using Auto Export for custom analysis of your data.
Please note, if device details are not specified Amazon Mobile Analytics will make best efforts to determine these values based on the User-Agent header value. It is always better to specify these values during initialization if they are available.
Further Documentation
Further documentation and advanced configurations can be found here:
https://aws.github.io/aws-sdk-mobile-analytics-js/doc/AMA.Manager.html
Network Configuration
The Amazon Mobile Analytics JavaScript SDK will make requests to the following endpoints
- For Event Submission: "https://mobileanalytics.us-east-1.amazonaws.com"
- For Cognito Authentication: "https://cognito-identity.us-east-1.amazonaws.com"
- This endpoint may change based on which region your Identity Pool was created in.
For most frameworks you can whitelist both domains by whitelisting all AWS endpoints with "*.amazonaws.com".
Change Log
v0.9.2:
- Bug Fixes:
- Fixed data loss issue on migration from previous versions
v0.9.1:
- Updated Dependency: aws-sdk-js v2.2.37
- Increase base delay between retries from 30ms to 3s
- Allow passing of configurations to the low level client via clientOptions attribute
- Local events from different apps are stored in different locations
- Improved retry strategies
- CorrectClockSkew is enabled by default for Sigv4 Signatures per Issue#7
- Bug Fixes:
- Fixed timer from being killed in cases where multiple submissions happened in under a second
- Fixed duplicate batch re-submission to the Mobile Analytics service
- Fixed delayed auto-submission of first _session.start event
- Fixed Safari throwing exception when in private browsing mode
v0.9.0:
- Initial release. Developer preview.