Skip to content

Commit

Permalink
Bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
arnab-p authored and sayan-mitra committed Nov 13, 2020
1 parent 1e19367 commit 631439c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 37 deletions.
2 changes: 1 addition & 1 deletion __tests__/prodsdk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rudder-analytics.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rudder-analytics.min.js.map

Large diffs are not rendered by default.

77 changes: 44 additions & 33 deletions dist/rudder-sdk-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2796,6 +2796,7 @@
this.optimizeContainerId = config.optimize || "";
this.resetCustomDimensionsOnPage = config.resetCustomDimensionsOnPage || [];
this.enhancedEcommerceLoaded = 0;
this.namedTracker = config.namedTracker || false;
this.name = "GA";
this.eventWithCategoryFieldProductScoped = ["product clicked", "product added", "product viewed", "product removed"];
}
Expand Down Expand Up @@ -2851,32 +2852,40 @@
sampleRate: this.sampleRate,
allowLinker: true,
useAmpClientId: this.useGoogleAmpClientId
};
}; // set tracker name to rudderGATracker if on

if (this.namedTracker) {
config.name = "rudderGATracker";
this.trackerName = "rudderGATracker.";
} else {
this.trackerName = "";
}

window.ga("create", this.trackingID, config);

if (this.optimizeContainerId) {
window.ga("require", this.optimizeContainerId);
window.ga("".concat(this.trackerName, "require"), this.optimizeContainerId);
} // ecommerce is required


if (!this.ecommerce) {
window.ga("require", "ecommerce");
window.ga("".concat(this.trackerName, "require"), "ecommerce");
this.ecommerce = true;
} // this is to display advertising


if (this.doubleClick) {
window.ga("require", "displayfeatures");
window.ga("".concat(this.trackerName, "require"), "displayfeatures");
} // https://support.google.com/analytics/answer/2558867?hl=en


if (this.enhancedLinkAttribution) {
window.ga("require", "linkid");
window.ga("".concat(this.trackerName, "require"), "linkid");
} // a warning is in ga debugger if anonymize is false after initialization


if (this.anonymizeIp) {
window.ga("set", "anonymizeIp", true);
window.ga("".concat(this.trackerName, "set"), "anonymizeIp", true);
}

logger.debug("===in init GA===");
Expand All @@ -2886,21 +2895,23 @@
value: function identify(rudderElement) {
// send global id
if (this.sendUserId && rudderElement.message.userId) {
window.ga("set", "userId", rudderElement.message.userId);
window.ga("".concat(this.trackerName, "set"), "userId", rudderElement.message.userId);
} // custom dimensions and metrics


var custom = this.metricsFunction(rudderElement.message.context.traits, this.dimensionsArray, this.metricsArray, this.contentGroupingsArray);

if (Object.keys(custom).length) {
window.ga("set", custom);
window.ga("".concat(this.trackerName, "set"), custom);
}

logger.debug("in GoogleAnalyticsManager identify");
}
}, {
key: "track",
value: function track(rudderElement) {
var _this2 = this;

var self = this; // Ecommerce events

var _rudderElement$messag = rudderElement.message,
Expand Down Expand Up @@ -2931,7 +2942,7 @@
} // add transaction


window.ga("ecommerce:addTransaction", {
window.ga("".concat(this.trackerName, "ecommerce:addTransaction"), {
affiliation: properties.affiliation,
shipping: properties.shipping,
revenue: total,
Expand All @@ -2942,7 +2953,7 @@

products.forEach(function (product) {
var productTrack = self.createProductTrack(rudderElement, product);
window.ga("ecommerce:addItem", {
window.ga("".concat(_this2.trackerName, "ecommerce:addItem"), {
category: productTrack.properties.category,
quantity: productTrack.properties.quantity,
price: productTrack.properties.price,
Expand All @@ -2952,7 +2963,7 @@
currency: productTrack.properties.currency
});
});
window.ga("ecommerce:send");
window.ga("".concat(this.trackerName, "ecommerce:send"));
} // enhanced ecommerce events
else if (this.enhancedEcommerce) {
switch (event) {
Expand All @@ -2967,7 +2978,7 @@
};
self.enhancedEcommerceTrackProduct(productTrack);
});
window.ga("ec:setAction", "checkout", {
window.ga("".concat(this.trackerName, "ec:setAction"), "checkout", {
step: properties.step || 1,
option: options || undefined
});
Expand All @@ -2985,8 +2996,8 @@
option: options || undefined
};
this.loadEnhancedEcommerce(rudderElement);
window.ga("ec:setAction", "checkout_option", params);
window.ga("send", "event", "Checkout", "Option");
window.ga("".concat(this.trackerName, "ec:setAction"), "checkout_option", params);
window.ga("".concat(this.trackerName, "send"), "event", "Checkout", "Option");
break;

case "Order Completed":
Expand All @@ -3005,7 +3016,7 @@
};
self.enhancedEcommerceTrackProduct(productTrack);
});
window.ga("ec:setAction", "purchase", {
window.ga("".concat(this.trackerName, "ec:setAction"), "purchase", {
id: orderId,
affiliation: props.affiliation,
revenue: total,
Expand All @@ -3027,12 +3038,12 @@
var track = {
properties: product
};
window.ga("ec:addProduct", {
window.ga("".concat(_this2.trackerName, "ec:addProduct"), {
id: track.properties.product_id || track.properties.id || track.properties.sku,
quantity: track.properties.quantity
});
});
window.ga("ec:setAction", "refund", {
window.ga("".concat(this.trackerName, "ec:setAction"), "refund", {
id: orderId
});
this.pushEnhancedEcommerce(rudderElement);
Expand Down Expand Up @@ -3066,7 +3077,7 @@

case "Promotion Viewed":
this.loadEnhancedEcommerce(rudderElement);
window.ga("ec:addPromo", {
window.ga("".concat(this.trackerName, "ec:addPromo"), {
id: props.promotion_id || props.id,
name: props.name,
creative: props.creative,
Expand All @@ -3077,13 +3088,13 @@

case "Promotion Clicked":
this.loadEnhancedEcommerce(rudderElement);
window.ga("ec:addPromo", {
window.ga("".concat(this.trackerName, "ec:addPromo"), {
id: props.promotion_id || props.id,
name: props.name,
creative: props.creative,
position: props.position
});
window.ga("ec:setAction", "promo_click", {});
window.ga("".concat(this.trackerName, "ec:setAction"), "promo_click", {});
this.pushEnhancedEcommerce(rudderElement);
break;

Expand Down Expand Up @@ -3113,14 +3124,14 @@
Object.keys(impressionObj).forEach(function (key) {
if (impressionObj[key] === undefined) delete impressionObj[key];
});
window.ga("ec:addImpression", impressionObj);
window.ga("".concat(_this2.trackerName, "ec:addImpression"), impressionObj);
});
this.pushEnhancedEcommerce(rudderElement);
break;

case "Product List Filtered":
props.filters = props.filters || [];
props.sorters = props.sorters || [];
props.sorts = props.sorts || [];
filters = props.filters.map(function (obj) {
return "".concat(obj.type, ":").concat(obj.value);
}).join();
Expand Down Expand Up @@ -3154,7 +3165,7 @@
Object.keys(impressionObj).forEach(function (key) {
if (impressionObj[key] === undefined) delete impressionObj[key];
});
window.ga("ec:addImpression", impressionObj);
window.ga("".concat(_this2.trackerName, "ec:addImpression"), impressionObj);
});
this.pushEnhancedEcommerce(rudderElement);
break;
Expand Down Expand Up @@ -3184,7 +3195,7 @@
payload = _objectSpread2({
payload: payload
}, this.setCustomDimenionsAndMetrics(rudderElement.message.properties));
window.ga("send", "event", payload.payload);
window.ga("".concat(this.trackerName, "send"), "event", payload.payload);
logger.debug("in GoogleAnalyticsManager track");
}
} else {
Expand Down Expand Up @@ -3212,7 +3223,7 @@
payload = _objectSpread2({
payload: payload
}, this.setCustomDimenionsAndMetrics(rudderElement.message.properties));
window.ga("send", "event", payload.payload);
window.ga("".concat(this.trackerName, "send"), "event", payload.payload);
logger.debug("in GoogleAnalyticsManager track");
}
}
Expand Down Expand Up @@ -3260,7 +3271,7 @@
}
}

window.ga("set", resetCustomDimensions); // adds more properties to pageview which will be sent
window.ga("".concat(this.trackerName, "set"), resetCustomDimensions); // adds more properties to pageview which will be sent

pageview = _objectSpread2(_objectSpread2({}, pageview), this.setCustomDimenionsAndMetrics(eventProperties));
var payload = {
Expand All @@ -3270,9 +3281,9 @@
logger.debug(pageReferrer);
logger.debug(document.referrer);
if (pageReferrer !== document.referrer) payload.referrer = pageReferrer;
window.ga("set", payload);
window.ga("".concat(this.trackerName, "set"), payload);
if (this.pageCalled) delete pageview.location;
window.ga("send", "pageview", pageview); // categorized pages
window.ga("".concat(this.trackerName, "send"), "pageview", pageview); // categorized pages

if (category && this.trackCategorizedPages) {
this.track(rudderElement, {
Expand Down Expand Up @@ -3352,7 +3363,7 @@

if (Object.keys(custom).length) {
if (this.setAllMappedProps) {
window.ga("set", custom);
window.ga("".concat(this.trackerName, "set"), custom);
} else {
Object.keys(custom).forEach(function (key) {
ret[key] = custom[key];
Expand Down Expand Up @@ -3409,11 +3420,11 @@
key: "loadEnhancedEcommerce",
value: function loadEnhancedEcommerce(rudderElement) {
if (this.enhancedEcommerceLoaded === 0) {
window.ga("require", "ec");
window.ga("".concat(this.trackerName, "require"), "ec");
this.enhancedEcommerceLoaded = 1;
}

window.ga("set", "&cu", rudderElement.message.properties.currency);
window.ga("".concat(this.trackerName, "set"), "&cu", rudderElement.message.properties.currency);
}
/**
* helper class to not repeat `ec:addProduct`
Expand Down Expand Up @@ -3443,7 +3454,7 @@
var coupon = props.coupon;
if (coupon) product.coupon = coupon;
product = _objectSpread2(_objectSpread2({}, product), this.metricsFunction(props, this.dimensionsArray, this.metricsArray, this.contentGroupingsArray));
window.ga("ec:addProduct", product);
window.ga("".concat(this.trackerName, "ec:addProduct"), product);
}
/**
* set action with data
Expand All @@ -3457,7 +3468,7 @@
key: "enhancedEcommerceTrackProductAction",
value: function enhancedEcommerceTrackProductAction(rudderElement, action, data) {
this.enhancedEcommerceTrackProduct(rudderElement);
window.ga("ec:setAction", action, data || {});
window.ga("".concat(this.trackerName, "ec:setAction"), action, data || {});
}
/**
* @param {} rudderElement
Expand Down
2 changes: 1 addition & 1 deletion dist/rudder-sdk-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-sdk-js",
"version": "1.0.11",
"version": "1.0.12",
"description": "Rudder Javascript SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 631439c

Please sign in to comment.