 module.exports =
 AnalyticsStore = Reflux.createStore
   init: ->
+    @listenAndTrack = (dispatcher=Actions) => (callback, action) =>
+      @listenTo dispatcher[action], (args...) =>
+        @track(action, callback(args...))
+
     @analytics = Mixpanel.init("625e2300ef07cb4eb70a69b3638ca579")
     @listenTo NamespaceStore, => @identify()
     @identify()
 
-    @_listenToActions()
+    @_listenToCoreActions()
+
+    @_setupGlobalPackageActions()
+
+  addPackageActions: (listeners, dispatcher=Actions) ->
+    _.each listeners, @listenAndTrack(dispatcher)
+
+  addGlobalPackageActions: (listeners) ->
+    @_globalPackageActions = _.extend @_globalPackageActions, listeners
+
+  _setupGlobalPackageActions: ->
+    @_globalPackageActions = {}
+    @listenTo Actions.sendToAllWindows, (actionData={}) =>
+      return unless atom.isMainWindow()
+      callback = @_globalPackageActions[actionData.action]
+      if callback?
+        @track(actionData.action, callback(actionData))
 
   # We white list actions to track.
   #

    abortDownload: -> {}
    fileDownloaded: -> {}

  track: (action, data={}) ->
    @analytics.track(action, _.extend(data, namespaceId: NamespaceStore.current()?.id))


  #
  # Only completely anonymous data essential to future metrics or
  # debugging may be sent.
  coreWindowActions: ->
    showDeveloperConsole: -> {}
    composeReply: ({threadId, messageId}) -> {threadId, messageId}
    composeForward: ({threadId, messageId}) -> {threadId, messageId}
