Skip to content

Commit

Permalink
setting AMA custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Jun 10, 2017
1 parent 96dffae commit e485ea1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions browser/main/lib/AwsMobileAnalyticsConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const AWS = require('aws-sdk')
const AMA = require('aws-sdk-mobile-analytics')
const ConfigManager = require('browser/main/lib/ConfigManager')

AWS.config.region = 'us-east-1'
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:25089e0b-cfc5-4fc8-8212-3cfff647941e'
})
const mobileAnalyticsClient = new AMA.Manager({
appId: 'db50bef32cac4e598243dfe3f2ca7116',
appTitle: 'Boostnote'
})

function initAwsMobileAnalytics () {
AWS.config.credentials.get(function(err) {
if (!err) {
console.log("Cognito Identity ID: " + AWS.config.credentials.identityId)
}
})
recordStaticCustomEvent()
}

function recordDynamitCustomEvent (type) {
mobileAnalyticsClient.recordEvent(type)
}

function recordStaticCustomEvent () {
mobileAnalyticsClient.recordEvent('UI_COLOR_THEME', {
uiColorTheme: ConfigManager.default.get().ui.theme
})
}

module.exports = {
initAwsMobileAnalytics,
recordDynamitCustomEvent
}

0 comments on commit e485ea1

Please sign in to comment.