mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Prune internal analytics event data
This commit is contained in:
parent
83efcb5113
commit
29c6b7c9f1
2 changed files with 37 additions and 4 deletions
|
@ -59,9 +59,24 @@ module.exports = class Tracker
|
|||
# https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#Anatomy
|
||||
# Mixpanel properties format: whatever you want unlike GA
|
||||
# https://segment.com/docs/integrations/mixpanel/
|
||||
properties = properties or {}
|
||||
|
||||
# Log internally
|
||||
# Skipping heavily logged actions we don't use internally
|
||||
unless action in ['Simulator Result', 'Loaded World Map', 'Started Level Load', 'Finished Level Load', 'Homepage Loaded']
|
||||
# Trimming properties we don't use internally
|
||||
# TODO: delete internalProperites.level for 'Saw Victory' after 2/8/15. Should be using levelID instead.
|
||||
internalProperties = _.cloneDeep properties
|
||||
if action in ['Clicked Level', 'Inventory Play', 'Heard Sprite', 'Started Level', 'Saw Victory', 'Click Play', 'Choose Inventory']
|
||||
delete internalProperties.category
|
||||
delete internalProperties.label
|
||||
|
||||
console.log 'Tracking internal analytics event:', action, internalProperties, includeIntegrations if debugAnalytics
|
||||
event = new AnalyticsLogEvent event: action, properties: internalProperties
|
||||
event.save()
|
||||
|
||||
console.log 'Would track analytics event:', action, properties, includeIntegrations if debugAnalytics
|
||||
return unless me and @isProduction and analytics? and not me.isAdmin()
|
||||
properties = properties or {}
|
||||
context = {}
|
||||
if includeIntegrations
|
||||
# https://segment.com/docs/libraries/analytics.js/#selecting-integrations
|
||||
|
@ -70,9 +85,6 @@ module.exports = class Tracker
|
|||
context.integrations[integration] = true
|
||||
analytics?.track action, properties, context
|
||||
|
||||
# Log internally too. Will turn off external event logging when internal logging is sufficient.
|
||||
event = new AnalyticsLogEvent event: action, properties: properties
|
||||
event.save()
|
||||
|
||||
trackTiming: (duration, category, variable, label, samplePercentage=5) ->
|
||||
# https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingTiming
|
||||
|
|
21
scripts/analytics/mongodb/queries/aggregateEventTotals.js
Normal file
21
scripts/analytics/mongodb/queries/aggregateEventTotals.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Print out event totals
|
||||
|
||||
// Usage:
|
||||
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
||||
|
||||
var cursor = db['analytics.log.events'].aggregate(
|
||||
[
|
||||
{ $match : {}},
|
||||
{
|
||||
$group : {
|
||||
_id: "$event",
|
||||
total: {$sum: 1}
|
||||
}
|
||||
},
|
||||
{ $sort : { total : -1} }
|
||||
]);
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
var myDoc = cursor.next();
|
||||
print(myDoc.total + "\t" + myDoc._id)
|
||||
}
|
Loading…
Reference in a new issue