   other: 'Other Events'
 
 module.exports.track = track =
-  _.reduce(Object.keys(categories), (memo, kind) ->
+  reduce(Object.keys(categories), (memo, kind) ->
     memo[kind] = (description, options = {}) ->
       # Send google analytics event
       ga? 'send', {

_ = require 'underscore'
_s = require 'underscore.string'
sd = require('sharify').data
qs = require('querystring')

module.exports = (options) =>
  return if module.exports.getUserAgent()?.indexOf?('PhantomJS') > -1

  { @ga, @location } = options
  @location ?= window?.location
  if sd.GOOGLE_ANALYTICS_ID
    googleAnalyticsParams = cookieDomain: 'are.na'

    if sd.CURRENT_USER?.id
      googleAnalyticsParams.userId = sd.CURRENT_USER?.id

    @ga? 'create', sd.GOOGLE_ANALYTICS_ID, googleAnalyticsParams

module.exports.getUserAgent = ->
  window?.navigator?.userAgent

module.exports.trackPageview = (args = {}) =>
  opts = _.extend { hitType: 'pageview' }, args
  ga? 'send', opts

module.exports.trackOutboundLink = (url, cb = $.noop) =>

    'hitCallback': cb

module.exports.registerCurrentUser = ->
  userType = if CURRENT_USER then "Logged In" else "Logged Out"
  ga?('set', 'dimension1', userType)
  ga?('set', 'dimension2', CURRENT_USER?.registered) if CURRENT_USER

module.exports.modelNameAndIdToLabel = (modelName, id) ->
  throw new Error('Requires modelName and id') unless modelName? and id?

  "#{capitalize modelName}:#{id}"

categories =
  impression: 'Impressions'
