mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 03:23:45 +08:00
feat(analytics) add Mixpanel
Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1299
This commit is contained in:
parent
6b270734ef
commit
809033c601
3 changed files with 70 additions and 1 deletions
|
@ -42,9 +42,10 @@ module.exports =
|
||||||
MessageStore: require '../src/flux/stores/message-store'
|
MessageStore: require '../src/flux/stores/message-store'
|
||||||
ContactStore: require '../src/flux/stores/contact-store'
|
ContactStore: require '../src/flux/stores/contact-store'
|
||||||
NamespaceStore: require '../src/flux/stores/namespace-store'
|
NamespaceStore: require '../src/flux/stores/namespace-store'
|
||||||
|
AnalyticsStore: require '../src/flux/stores/analytics-store'
|
||||||
|
WorkspaceStore: require '../src/flux/stores/workspace-store'
|
||||||
FileUploadStore: require '../src/flux/stores/file-upload-store'
|
FileUploadStore: require '../src/flux/stores/file-upload-store'
|
||||||
FileDownloadStore: require '../src/flux/stores/file-download-store'
|
FileDownloadStore: require '../src/flux/stores/file-download-store'
|
||||||
WorkspaceStore: require '../src/flux/stores/workspace-store'
|
|
||||||
|
|
||||||
## TODO move to inside of individual Salesforce package. See https://trello.com/c/tLAGLyeb/246-move-salesforce-models-into-individual-package-db-models-for-packages-various-refactors
|
## TODO move to inside of individual Salesforce package. See https://trello.com/c/tLAGLyeb/246-move-salesforce-models-into-individual-package-db-models-for-packages-various-refactors
|
||||||
SalesforceAssociation: require '../src/flux/models/salesforce-association'
|
SalesforceAssociation: require '../src/flux/models/salesforce-association'
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
"less-cache": "0.21",
|
"less-cache": "0.21",
|
||||||
"marked": "^0.3",
|
"marked": "^0.3",
|
||||||
"mkdirp": "^0.5",
|
"mkdirp": "^0.5",
|
||||||
|
"mixpanel": "^0.0.20",
|
||||||
"moment": "^2.8",
|
"moment": "^2.8",
|
||||||
"moment-timezone": "^0.3",
|
"moment-timezone": "^0.3",
|
||||||
"nslog": "^2.0.0",
|
"nslog": "^2.0.0",
|
||||||
|
|
67
src/flux/stores/analytics-store.coffee
Normal file
67
src/flux/stores/analytics-store.coffee
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
_ = require 'underscore-plus'
|
||||||
|
Reflux = require 'reflux'
|
||||||
|
Mixpanel = require 'mixpanel'
|
||||||
|
|
||||||
|
Actions = require '../actions'
|
||||||
|
NamespaceStore = require './namespace-store'
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
AnalyticsStore = Reflux.createStore
|
||||||
|
init: ->
|
||||||
|
@analytics = Mixpanel.init("625e2300ef07cb4eb70a69b3638ca579")
|
||||||
|
@listenTo NamespaceStore, => @identify()
|
||||||
|
@identify()
|
||||||
|
|
||||||
|
@_listenToActions()
|
||||||
|
|
||||||
|
# We white list actions to track.
|
||||||
|
#
|
||||||
|
# The Key is the action and the value is the callback function for that
|
||||||
|
# action. That callback function should return the data we pass along to
|
||||||
|
# our analytics service based on the sending data.
|
||||||
|
#
|
||||||
|
# IMPORTANT: Be VERY careful about what private data we send to our
|
||||||
|
# analytics service!!
|
||||||
|
#
|
||||||
|
# Only completely anonymous data essential to future metrics or
|
||||||
|
# debugging may be sent.
|
||||||
|
actionsToTrack: ->
|
||||||
|
logout: -> {}
|
||||||
|
fileAborted: (uploadData={}) -> {fileSize: uploadData.fileSize}
|
||||||
|
fileUploaded: (uploadData={}) -> {fileSize: uploadData.fileSize}
|
||||||
|
sendDraftError: (dId, msg) -> {drafLocalId: dId, error: msg}
|
||||||
|
sendDraftSuccess: (draftLocalId) -> {draftLocalId: draftLocalId}
|
||||||
|
destroyDraftSuccess: -> {}
|
||||||
|
destroyDraftError: (msg) -> {error: msg}
|
||||||
|
showDeveloperConsole: -> {}
|
||||||
|
composeReply: ({threadId, messageId}) -> {threadId, messageId}
|
||||||
|
composeForward: ({threadId, messageId}) -> {threadId, messageId}
|
||||||
|
composeReplyAll: ({threadId, messageId}) -> {threadId, messageId}
|
||||||
|
composePopoutDraft: (localId) -> {draftLocalId: draftLocalId}
|
||||||
|
composeNewBlankDraft: -> {}
|
||||||
|
sendDraft: (draftLocalId) -> {draftLocalId: draftLocalId}
|
||||||
|
destroyDraft: (draftLocalId) -> {draftLocalId: draftLocalId}
|
||||||
|
searchQueryCommitted: (query) -> {}
|
||||||
|
fetchAndOpenFile: -> {}
|
||||||
|
fetchAndSaveFile: -> {}
|
||||||
|
abortDownload: -> {}
|
||||||
|
fileDownloaded: -> {}
|
||||||
|
|
||||||
|
track: (action, data={}) ->
|
||||||
|
return unless @id
|
||||||
|
@analytics.track(action, _.extend(data, namespaceId: @id))
|
||||||
|
|
||||||
|
identify: ->
|
||||||
|
@id = NamespaceStore.current?()?.id?
|
||||||
|
return unless @id
|
||||||
|
me = NamespaceStore.current().me()
|
||||||
|
@analytics.people.set @id,
|
||||||
|
"$email": me.email
|
||||||
|
"$first_name": me.firstName()
|
||||||
|
"$last_name": me.lastName()
|
||||||
|
"namespaceId": me.namespaceId
|
||||||
|
|
||||||
|
_listenToActions: ->
|
||||||
|
_.each @actionsToTrack(), (callback, action) =>
|
||||||
|
@listenTo Actions[action], (args...) =>
|
||||||
|
@track(action, callback(args...))
|
Loading…
Reference in a new issue