 
 Analytics = require('analytics-node')
 analytics = new Analytics(KONFIG.segment)
-
-mqClient = null
 
 module.exports = class Tracker extends bongo.Base
 

    event.from       or= defaultFromMail
    event.properties   = @addDefaults { options, username }

    unless mqClient
      console.error errMQClientNotSet
      return callback errMQClientNotSet

    sendMessage = ->
      mqClient.exchange "#{exchangeName}", exchangeOpts, (exchange) ->
        unless exchange
          err = new Error "Tracker: Exchange not found to queue: #{exchangeName}"
          console.error err
          return callback err

        exchange.publish '', event, { type: EVENT_TYPE }, (errored, err) ->
          return callback err

    if mqClient.readyEmitted then sendMessage()
    else mqClient.on 'ready', -> sendMessage()


  @page = (userId, name, category, properties) ->

    opts['env']      = KONFIG.environment
    opts['hostname'] = KONFIG.hostname
    opts
