Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crowdstart-analytics

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crowdstart-analytics - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

71

lib/integrations/google-analytics.js
// Generated by CoffeeScript 1.9.3
var GoogleAnalytics, Integration,
var GoogleAnalytics, Integration, parseValue,
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; },

@@ -8,2 +8,13 @@ hasProp = {}.hasOwnProperty;

parseValue = function(value) {
if (typeof value === 'string') {
if ((value.indexOf('.')) !== -1) {
value = Math.round(parseFloat(value, 10));
} else {
value = parseInt(value, 10);
}
}
return value;
};
module.exports = GoogleAnalytics = (function(superClass) {

@@ -59,3 +70,3 @@ extend(GoogleAnalytics, superClass);

GoogleAnalytics.prototype.sendEvent = function(event, props) {
var ref;
var campaign, data, ref, ref1, ref2;
if (props == null) {

@@ -65,5 +76,28 @@ props = {};

this.log('GoogleAnalytics.sendEvent', arguments);
return ga('send', 'event', (ref = props.category) != null ? ref : 'EnhancedEcommerce', event);
data = {
eventAction: event
};
if (props != null) {
data.eventCategory = props.category;
data.eventLabel = props.label;
data.eventValue = parseValue((ref = (ref1 = (ref2 = props.value) != null ? ref2 : props.total) != null ? ref1 : props.revenue) != null ? ref : 0);
data.nonInteraction = props.nonInteraction;
if ((campaign = props.campaign) != null) {
data.campaignName = campaign.name;
data.campaignSource = campaign.source;
data.campaignMedium = campaign.medium;
data.campaignContent = campaign.content;
data.campaignKeyword = campaign.term;
}
}
return ga('send', 'event', data);
};
GoogleAnalytics.prototype.sendEEEvent = function(event, props) {
if (props.category == null) {
props.category = 'EnhancedEcommerce';
}
return this.sendEvent(event, props);
};
GoogleAnalytics.prototype.identify = function(userId, traits, opts, cb) {

@@ -105,3 +139,2 @@ if (cb == null) {

GoogleAnalytics.prototype.track = function(event, props, opts, cb) {
var campaign, data;
if (cb == null) {

@@ -111,19 +144,3 @@ cb = function() {};

this.log('GoogleAnalytics.track', arguments);
data = {
eventAction: event
};
if (props != null) {
data.eventCategory = props.category;
data.eventLabel = props.label;
data.eventValue = props.value;
data.nonInteraction = props.nonInteraction;
if ((campaign = props.campaign) != null) {
data.campaignName = campaign.name;
data.campaignSource = campaign.source;
data.campaignMedium = campaign.medium;
data.campaignContent = campaign.content;
data.campaignKeyword = campaign.term;
}
}
ga('send', 'event', data);
this.sendEvent(event, props);
return cb(null);

@@ -153,3 +170,3 @@ };

this.setAction('detail', props);
this.sendEvent(event, props);
this.sendEEEvent(event, props);
return cb(null);

@@ -166,3 +183,3 @@ };

this.setAction('add', props);
this.sendEvent(event, props);
this.sendEEEvent(event, props);
return cb(null);

@@ -179,3 +196,3 @@ };

this.setAction('remove', props);
this.sendEvent(event, props);
this.sendEEEvent(event, props);
return cb(null);

@@ -185,3 +202,3 @@ };

GoogleAnalytics.prototype.completedOrder = function(event, props, opts, cb) {
var i, len, product, ref;
var i, len, product, ref, ref1;
if (cb == null) {

@@ -203,3 +220,3 @@ cb = function() {};

affiliation: props.affiliation,
revenue: props.total,
revenue: (ref1 = props.total) != null ? ref1 : props.revenue,
tax: props.tax,

@@ -209,3 +226,3 @@ shipping: props.shipping,

});
this.sendEvent(event, props);
this.sendEEEvent(event, props);
return cb(null);

@@ -212,0 +229,0 @@ };

{
"name": "crowdstart-analytics",
"version": "0.1.1",
"version": "0.1.2",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc