Fixed tracking for non production environments

This commit is contained in:
Michael Schmatz 2015-02-27 14:44:06 -05:00
parent 4efb73d8d7
commit d0d622445f

View file

@ -89,15 +89,23 @@ module.exports = class Tracker
delete properties.category
properties[key] = value for key, value of @explicitTraits if @explicitTraits?
console.log 'Tracking internal analytics event:', event, properties if debugAnalytics
if @isProduction
eventObject = {}
eventObject["event"] = event
eventObject["properties"] = properties unless _.isEmpty properties
eventObject["user"] = me.id
console.log 'Tracking internal analytics event:', event, properties if debugAnalytics
dataToSend = JSON.stringify eventObject
console.log dataToSend if debugAnalytics
$.post("http://analytics.codecombat.com/analytics", dataToSend).fail ->
console.error "Analytics post failed!"
else
request = @supermodel.addRequestResource 'log_event', {
url: '/db/analytics_log_event/-/log_event'
data: {event: event, properties: properties}
method: 'POST'
}, 0
request.load()
trackTiming: (duration, category, variable, label, samplePercentage=5) ->
# https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingTiming