Skip to content

Commit

Permalink
Merge pull request #620 from BoostIO/feature-AmazonMobileAnalytics
Browse files Browse the repository at this point in the history
Feature amazon mobile analytics
  • Loading branch information
kohei-takata authored Jun 10, 2017
2 parents be625f8 + 278061e commit 48ca13f
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 8 deletions.
2 changes: 2 additions & 0 deletions browser/finder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import StorageSection from './StorageSection'
import NoteList from './NoteList'
import NoteDetail from './NoteDetail'
import SideNavFilter from 'browser/components/SideNavFilter'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
require('!!style!css!stylus?sourceMap!../main/global.styl')
require('../lib/customMeta')

Expand Down Expand Up @@ -94,6 +95,7 @@ class FinderMain extends React.Component {

if (e.keyCode === 13) {
this.refs.detail.saveToClipboard()
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('COPY_FINDER')
hideFinder()
e.preventDefault()
}
Expand Down
3 changes: 3 additions & 0 deletions browser/main/Detail/MarkdownNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import markdown from 'browser/lib/markdown'
import StatusBar from '../StatusBar'
import _ from 'lodash'
import { findNoteTitle } from 'browser/lib/findNoteTitle'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'

const electron = require('electron')
const { remote } = electron
Expand Down Expand Up @@ -116,6 +117,7 @@ class MarkdownNoteDetail extends React.Component {
type: 'UPDATE_NOTE',
note: note
})
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('EDIT_NOTE')
})
}

Expand Down Expand Up @@ -154,6 +156,7 @@ class MarkdownNoteDetail extends React.Component {

handleStarButtonClick (e) {
let { note } = this.state
if (!note.isStarred) AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_STAR')

note.isStarred = !note.isStarred

Expand Down
3 changes: 3 additions & 0 deletions browser/main/Detail/SnippetNoteDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import context from 'browser/lib/context'
import ConfigManager from 'browser/main/lib/ConfigManager'
import _ from 'lodash'
import { findNoteTitle } from 'browser/lib/findNoteTitle'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'

function pass (name) {
switch (name) {
Expand Down Expand Up @@ -110,6 +111,7 @@ class SnippetNoteDetail extends React.Component {
type: 'UPDATE_NOTE',
note: note
})
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('EDIT_NOTE')
})
}

Expand Down Expand Up @@ -148,6 +150,7 @@ class SnippetNoteDetail extends React.Component {

handleStarButtonClick (e) {
let { note } = this.state
if (!note.isStarred) AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_STAR')

note.isStarred = !note.isStarred

Expand Down
2 changes: 2 additions & 0 deletions browser/main/Detail/TagSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
import CSSModules from 'browser/lib/CSSModules'
import styles from './TagSelect.styl'
import _ from 'lodash'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'

class TagSelect extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -56,6 +57,7 @@ class TagSelect extends React.Component {
}

submitTag () {
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_TAG')
let { value } = this.props
let newTag = this.refs.newTag.value.trim().replace(/ +/g, '_')

Expand Down
3 changes: 3 additions & 0 deletions browser/main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ConfigManager from 'browser/main/lib/ConfigManager'
import modal from 'browser/main/lib/modal'
import InitModal from 'browser/main/modals/InitModal'
import mixpanel from 'browser/main/lib/mixpanel'
import mobileAnalytics from 'browser/main/lib/awsMobileAnalyticsConfig'

function focused () {
mixpanel.track('MAIN_FOCUSED')
Expand All @@ -21,6 +22,8 @@ class Main extends React.Component {
constructor (props) {
super(props)

mobileAnalytics.initAwsMobileAnalytics()

let { config } = props

this.state = {
Expand Down
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:xxxxxxxxxxxxxxxxxxxxxxxxx'
})
const mobileAnalyticsClient = new AMA.Manager({
appId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
appTitle: 'xxxxxxxxxx'
})

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
}
2 changes: 2 additions & 0 deletions browser/main/modals/CreateFolderModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dataApi from 'browser/main/lib/dataApi'
import store from 'browser/main/store'
import consts from 'browser/lib/consts'
import ModalEscButton from 'browser/components/ModalEscButton'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'

class CreateFolderModal extends React.Component {
constructor (props) {
Expand Down Expand Up @@ -48,6 +49,7 @@ class CreateFolderModal extends React.Component {
}

confirm () {
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_FOLDER')
if (this.state.name.trim().length > 0) {
let { storage } = this.props
let input = {
Expand Down
5 changes: 5 additions & 0 deletions browser/main/modals/NewNoteModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dataApi from 'browser/main/lib/dataApi'
import { hashHistory } from 'react-router'
import ee from 'browser/main/lib/eventEmitter'
import ModalEscButton from 'browser/components/ModalEscButton'
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'

class NewNoteModal extends React.Component {
constructor (props) {
Expand All @@ -23,6 +24,8 @@ class NewNoteModal extends React.Component {
}

handleMarkdownNoteButtonClick (e) {
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_MARKDOWN')
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_ALLNOTE')
let { storage, folder, dispatch, location } = this.props
dataApi
.createNote(storage, {
Expand Down Expand Up @@ -53,6 +56,8 @@ class NewNoteModal extends React.Component {
}

handleSnippetNoteButtonClick (e) {
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_SNIPPET')
AwsMobileAnalyticsConfig.recordDynamitCustomEvent('ADD_ALLNOTE')
let { storage, folder, dispatch, location } = this.props

dataApi
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"dependencies": {
"@rokt33r/markdown-it-math": "^4.0.1",
"@rokt33r/season": "^5.3.0",
"aws-sdk": "^2.48.0",
"aws-sdk-mobile-analytics": "^0.9.2",
"codemirror": "^5.19.0",
"electron-config": "^0.2.1",
"electron-gh-releases": "^2.0.2",
Expand Down Expand Up @@ -104,6 +106,7 @@
"grunt-electron-installer": "^1.2.0",
"history": "^1.17.0",
"jsdom": "^9.4.2",
"json-loader": "^0.5.4",
"merge-stream": "^1.0.0",
"nib": "^1.1.0",
"react-color": "^2.2.2",
Expand Down
4 changes: 4 additions & 0 deletions webpack-production.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ var config = Object.assign({}, skeleton, {
test: /\.styl$/,
exclude: /(node_modules|bower_components)/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]___[path]!stylus?sourceMap'
},
{
test: /\.json$/,
loader: 'json'
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var config = Object.assign({}, skeleton, {
test: /\.styl$/,
exclude: /(node_modules|bower_components)/,
loader: 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]___[path]!stylus?sourceMap'
},
{
test: /\.json$/,
loader: 'json'
}
]
},
Expand Down
68 changes: 60 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@ ava@^0.16.0:
unique-temp-dir "^1.0.0"
update-notifier "^1.0.0"

aws-sdk-mobile-analytics@^0.9.2:
version "0.9.2"
resolved "https://registry.yarnpkg.com/aws-sdk-mobile-analytics/-/aws-sdk-mobile-analytics-0.9.2.tgz#b56a6e5206fc8c3975a19170b41536c53f6d5d91"
dependencies:
aws-sdk ">=2.2.37"

aws-sdk@>=2.2.37, aws-sdk@^2.48.0:
version "2.48.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.48.0.tgz#c89bbdbd71fdd33457cd65c46c4080e4e44b2702"
dependencies:
buffer "4.9.1"
crypto-browserify "1.0.9"
jmespath "0.15.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
uuid "3.0.1"
xml2js "0.4.17"
xmlbuilder "4.2.1"

aws-sign2@~0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63"
Expand Down Expand Up @@ -1242,7 +1262,7 @@ buffer-shims@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51"

buffer@^4.9.0:
buffer@4.9.1, buffer@^4.9.0:
version "4.9.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298"
dependencies:
Expand Down Expand Up @@ -1765,6 +1785,10 @@ cryptiles@2.x.x:
dependencies:
boom "2.x.x"

crypto-browserify@1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-1.0.9.tgz#cc5449685dfb85eb11c9828acc7cb87ab5bbfcc0"

crypto-browserify@3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.3.0.tgz#b9fc75bb4a0ed61dcf1cd5dae96eb30c9c3e506c"
Expand Down Expand Up @@ -3760,6 +3784,10 @@ isstream@~0.1.1, isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"

jmespath@0.15.0:
version "0.15.0"
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217"

jodid25519@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967"
Expand Down Expand Up @@ -3852,6 +3880,10 @@ jsesc@~0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"

json-loader@^0.5.4:
version "0.5.4"
resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.4.tgz#8baa1365a632f58a3c46d20175fc6002c96e37de"

json-schema@0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
Expand Down Expand Up @@ -5837,9 +5869,9 @@ sax@0.5.x:
version "0.5.8"
resolved "https://registry.yarnpkg.com/sax/-/sax-0.5.8.tgz#d472db228eb331c2506b0e8c15524adb939d12c1"

sax@^1.2.1, sax@~1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828"
sax@1.2.1, sax@>=0.6.0, sax@^1.2.1, sax@~1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"

semver-diff@^2.0.0:
version "2.1.0"
Expand Down Expand Up @@ -6656,6 +6688,13 @@ url-parse@^1.1.8:
querystringify "~1.0.0"
requires-port "1.0.x"

url@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64"
dependencies:
punycode "1.3.2"
querystring "0.2.0"

url@^0.11.0, url@~0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1"
Expand Down Expand Up @@ -6683,14 +6722,14 @@ utils-merge@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8"

uuid@3.0.1, uuid@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"

uuid@^2.0.1, uuid@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a"

uuid@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1"

validate-npm-package-license@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"
Expand Down Expand Up @@ -6977,12 +7016,25 @@ xml-name-validator@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635"

xml2js@0.4.17:
version "0.4.17"
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.17.tgz#17be93eaae3f3b779359c795b419705a8817e868"
dependencies:
sax ">=0.6.0"
xmlbuilder "^4.1.0"

xmlbuilder@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-4.0.0.tgz#98b8f651ca30aa624036f127d11cc66dc7b907a3"
dependencies:
lodash "^3.5.0"

xmlbuilder@4.2.1, xmlbuilder@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-4.2.1.tgz#aa58a3041a066f90eaa16c2f5389ff19f3f461a5"
dependencies:
lodash "^4.0.0"

xmldom@0.1.x:
version "0.1.27"
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9"
Expand Down

0 comments on commit 48ca13f

Please sign in to comment.