crowdstart-analytics
Advanced tools
Comparing version 0.2.5 to 0.2.6
// Generated by CoffeeScript 1.9.3 | ||
var GoogleAnalytics, Integration, parseValue, | ||
var GoogleAnalytics, Integration, parseValue, payload, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
@@ -19,2 +19,17 @@ hasProp = {}.hasOwnProperty; | ||
payload = function(opts) { | ||
var data, k, v; | ||
if (opts == null) { | ||
opts = {}; | ||
} | ||
data = {}; | ||
for (k in opts) { | ||
v = opts[k]; | ||
if (v != null) { | ||
data[k] = v; | ||
} | ||
} | ||
return data; | ||
}; | ||
module.exports = GoogleAnalytics = (function(superClass) { | ||
@@ -47,3 +62,3 @@ extend(GoogleAnalytics, superClass); | ||
this.log('GoogleAnalytics.addProduct', arguments); | ||
return ga('ec:addProduct', { | ||
return ga('ec:addProduct', payload({ | ||
id: (ref = props.id) != null ? ref : props.sku, | ||
@@ -58,3 +73,3 @@ brand: props.brand, | ||
variant: props.variant | ||
}); | ||
})); | ||
}; | ||
@@ -64,3 +79,3 @@ | ||
this.log('GoogleAnalytics.setAction', arguments); | ||
return ga('ec:setAction', action, props); | ||
return ga('ec:setAction', action, payload(props)); | ||
}; | ||
@@ -90,3 +105,3 @@ | ||
} | ||
return ga('send', 'event', data); | ||
return ga('send', 'event', payload(data)); | ||
}; | ||
@@ -111,3 +126,2 @@ | ||
GoogleAnalytics.prototype.page = function(category, name, props, opts, cb) { | ||
var payload; | ||
if (props == null) { | ||
@@ -123,17 +137,4 @@ props = {}; | ||
this.log('GoogleAnalytics.page', arguments); | ||
if (arguments.length === 1) { | ||
name = category; | ||
} | ||
payload = {}; | ||
if (opts.page != null) { | ||
payload.page = opts.page; | ||
} | ||
if (opts.title != null) { | ||
payload.title = opts.title; | ||
} | ||
ga('set', payload); | ||
if (opts.location != null) { | ||
payload.location = opts.location; | ||
} | ||
ga('send', 'pageview', payload); | ||
ga('set', payload(opts)); | ||
ga('send', 'pageview', payload(opts)); | ||
return cb(null); | ||
@@ -140,0 +141,0 @@ }; |
{ | ||
"name": "crowdstart-analytics", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "Analytics support for Crowdstart.", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149405