voxa-ama
Version:
Integrate Amazon Mobile Analytics analytics into your Alexa apps using the voxa framework
131 lines (84 loc) • 5.48 kB
Markdown
Voxa AWS Mobile Analytics
===========
[](https://travis-ci.org/mediarain/voxa-ama)
[](https://coveralls.io/github/mediarain/voxa-ama?branch=master)
An [AWS Mobile Analytics](https://aws.amazon.com/mobileanalytics/) plugin for [voxa](https://mediarain.github.io/voxa/)
Installation
-------------
Just install from [npm](https://www.npmjs.com/package/voxa-ama)
```bash
npm install --save voxa-ama
```
Usage
------
```javascript
const voxaAma = require('voxa-ama');
const amaConfig = {
appId: 'appId',
appTitle: 'appTitle',
make: 'Amazon',
platform: 'Alexa',
cognitoIdentityPoolId: 'cognitoIdentityPoolId',
suppressSending: false, // A flag to supress sending hits. Useful while developing on the skill
};
voxaAma(skill, amaConfig);
```
### Suppressing State Events
Sometimes smaller intermediary states can flood the pathways diagram. Suppress a state from logging as follows:
```javascript
skill.onState('my-state', (voxaEvent) => {
voxaEvent.ama.ignore();
return { reply: 'Greeting', to: 'my-next-state' };
})
```
### Logging custom variables
You can also add additional values which will be logged along with the state custom event
```javascript
skill.onState('my-state', (voxaEvent) => {
voxaEvent.ama.logEvents('response', 'hello');
return { reply: 'Greeting', to: 'my-next-state' };
})
```
### Specific Events
You can also log custom events from a state.
```javascript
skill.onState('my-state', (voxaEvent) => {
voxaEvent.ama.logEvents('my-custom-event', { myVariable: 'hello' });
return { reply: 'Greeting', to: 'my-next-state' };
})
```
### Creating AWS Mobile Analytics project
AWS Mobile Analytics works hand on hand with Pinpoint and Cognito Pools. The values we need for tracking analytics are:
- App ID
- App Name
- Cognito Identity Pool ID
For creating the property, you should follow the next steps:
1) Log in with your AWS account, then in the [AWS Dashboard](https://console.aws.amazon.com/console/home), look for mobile analytics

2) In the main menu of AWS Analytics hit the *Get Started with Amazon Pinpoint* button

3) You will see here your pinpoint apps. Hit the *Create a project in Mobile Hub* button

4) Enter the name and select the region, the default region is *US East (Virginia)*

5) Once created, make sure the Analytics checkbox is enabled

In this step, some resources will be automatically created: a specific role with S3, Pinpoint and Analytics permissions, a Cognito Pool Identity to manage authentication from users and an Amazon S3 Bucket to export your data.
6) Now, go to the [AWS Mobile Analytics](https://console.aws.amazon.com/mobileanalytics/home/) menu and you will see your analytics project ready to receive events from your skill

7) You will see the App Name at the top of the page. Click on it and hit the *Manage Apps* butotn

8) Here there are all the mobile analytics project including the one you just created. In the second column you will see the App Id for your project

9) After that, look for [Cognito](https://console.aws.amazon.com/cognito/home)

10) Hit the *Manage Federated Identities* button

11) You will see your cognito pool identities, click on the one created for your project

12) You might need to fix something in the configuration, you need to specify the role for your cognito pool. You can either hit the *Click here to fix* or *Edit identity pool* link to go to the configurations.

13) In this screen you can grab the Identity Pool ID and add the role missing.

Once you have the App ID, App Name, and Cognito Pool ID you can add them to the voxa plugin configuration and start tracking the events in your skill. Keep in mind the events will last up to 1 hour to show up in the dashboard and it will look like this:
