crowdstart-analytics
Advanced tools
Comparing version 0.1.2 to 0.2.0
// Generated by CoffeeScript 1.9.3 | ||
var Analytics, Integration, | ||
slice = [].slice; | ||
var Analytics, Integration; | ||
@@ -9,3 +8,2 @@ Integration = require('./integration'); | ||
function Analytics() { | ||
var i, len, method, ref; | ||
this.integrations = []; | ||
@@ -17,11 +15,2 @@ Integration.prototype.log = (function(_this) { | ||
})(this); | ||
ref = ['addedProduct', 'completedCheckoutStep', 'completedOrder', 'experimentViewed', 'removedProduct', 'viewedCheckoutStep', 'viewedProduct', 'viewedProductCategory']; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
method = ref[i]; | ||
this[method] = (function(_this) { | ||
return function() { | ||
return _this.call(method, arguments); | ||
}; | ||
})(this); | ||
} | ||
} | ||
@@ -59,6 +48,8 @@ | ||
Analytics.prototype.call = function() { | ||
var args, i, integration, len, method, ref, results; | ||
method = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
this.log('Analytics.call', method, args); | ||
Analytics.prototype.call = function(method, event, props, opts, cb) { | ||
var i, integration, len, ref, results; | ||
if (cb == null) { | ||
cb = function() {}; | ||
} | ||
this.log('Analytics.call', method, event, props, opts); | ||
ref = this.integrations; | ||
@@ -69,5 +60,5 @@ results = []; | ||
if (integration[method] != null) { | ||
results.push(integration[method].apply(integration, args)); | ||
results.push(integration[method].call(integration, event, props, opts, cb)); | ||
} else { | ||
results.push(void 0); | ||
results.push(integration.track.call(integration, event, props, opts, cb)); | ||
} | ||
@@ -88,7 +79,3 @@ } | ||
method = method[0].toLowerCase() + method.substring(1); | ||
if (this[method] != null) { | ||
return this.call(method, event, props, opts, cb); | ||
} else { | ||
return this.call('track', event, props, opts, cb); | ||
} | ||
return this.call(method, event, props, opts, cb); | ||
}; | ||
@@ -95,0 +82,0 @@ |
@@ -18,13 +18,17 @@ // Generated by CoffeeScript 1.9.3 | ||
Integration.prototype.load = function(cb) { | ||
var ref, ref1; | ||
if (cb == null) { | ||
cb = function() {}; | ||
} | ||
this.log('Integration.load', this.type); | ||
switch (this.type) { | ||
this.log('Integration.load', this.src); | ||
if (!((((ref = this.src) != null ? ref.type : void 0) != null) && (((ref1 = this.src) != null ? ref1.url : void 0) != null))) { | ||
return; | ||
} | ||
switch (this.src.type) { | ||
case 'script': | ||
return loadScript(this, cb); | ||
return loadScript(this.src.url, cb); | ||
case 'img': | ||
return loadImg(this, cb); | ||
return loadImg(this.src.url, cb); | ||
case 'iframe': | ||
return loadIframe(this, cb); | ||
return loadIframe(this.src.url, cb); | ||
} | ||
@@ -31,0 +35,0 @@ }; |
@@ -11,6 +11,7 @@ // Generated by CoffeeScript 1.9.3 | ||
FacebookAudiences.prototype.type = 'script'; | ||
FacebookAudiences.prototype.src = { | ||
type: 'script', | ||
url: '//connect.facebook.net/en_US/fbevents.js' | ||
}; | ||
FacebookAudiences.prototype.src = '//connect.facebook.net/en_US/fbevents.js'; | ||
function FacebookAudiences(opts1) { | ||
@@ -17,0 +18,0 @@ this.opts = opts1; |
@@ -11,6 +11,7 @@ // Generated by CoffeeScript 1.9.3 | ||
FacebookConversions.prototype.type = 'script'; | ||
FacebookConversions.prototype.src = { | ||
type: 'script', | ||
url: '//connect.facebook.net/en_US/fbds.js' | ||
}; | ||
FacebookConversions.prototype.src = '//connect.facebook.net/en_US/fbds.js'; | ||
function FacebookConversions(opts1) { | ||
@@ -17,0 +18,0 @@ this.opts = opts1; |
@@ -11,6 +11,7 @@ // Generated by CoffeeScript 1.9.3 | ||
GoogleAdWords.prototype.type = 'script'; | ||
GoogleAdWords.prototype.src = { | ||
type: 'script', | ||
url: '//www.googleadservices.com/pagead/conversion_async.js' | ||
}; | ||
GoogleAdWords.prototype.src = '//www.googleadservices.com/pagead/conversion_async.js'; | ||
function GoogleAdWords(opts1) { | ||
@@ -17,0 +18,0 @@ this.opts = opts1; |
@@ -22,6 +22,7 @@ // Generated by CoffeeScript 1.9.3 | ||
GoogleAnalytics.prototype.type = 'script'; | ||
GoogleAnalytics.prototype.src = { | ||
type: 'script', | ||
url: '//www.google-analytics.com/analytics.js' | ||
}; | ||
GoogleAnalytics.prototype.src = '//www.google-analytics.com/analytics.js'; | ||
function GoogleAnalytics(opts1) { | ||
@@ -28,0 +29,0 @@ this.opts = opts1; |
// Generated by CoffeeScript 1.9.3 | ||
module.exports = { | ||
Generic: require('./generic'), | ||
FacebookAudiences: require('./facebook-audiences'), | ||
@@ -4,0 +5,0 @@ FacebookConversions: require('./facebook-conversions'), |
{ | ||
"name": "crowdstart-analytics", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
148384
53
1945