Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prod rebase #141

Merged
merged 20 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,961 changes: 2 additions & 7,959 deletions __tests__/prodsdk.js

Large diffs are not rendered by default.

7,072 changes: 2 additions & 7,070 deletions 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.

132 changes: 126 additions & 6 deletions dist/rudder-sdk-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@
Optimizely: "OPTIMIZELY",
FULLSTORY: "FULLSTORY",
Fullstory: "FULLSTORY",
BUGSNAG: "BUGSNAG"
BUGSNAG: "BUGSNAG",
TVSQUARED: "TVSQUARED"
};

// from client native integration name to server identified display name
Expand All @@ -693,7 +694,8 @@
LOTAME: "Lotame",
VWO: "VWO",
OPTIMIZELY: "Optimizely",
FULLSTORY: "Fullstory"
FULLSTORY: "Fullstory",
TVSQUUARED: "TVSquared"
};

// Message Type enumeration
Expand Down Expand Up @@ -735,7 +737,7 @@
PRODUCT_REVIEWED: "Product Reviewed"
}; // Enumeration for integrations supported

var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.0.10";
var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.0.11";
var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
/* module.exports = {
Expand Down Expand Up @@ -12693,6 +12695,123 @@
return Fullstory;
}();

var TVSquared = /*#__PURE__*/function () {
function TVSquared(config) {
_classCallCheck(this, TVSquared);

this.isLoaded = function () {
logger.debug("in TVSqaured isLoaded");
return !!(window._tvq && window._tvq.push !== Array.prototype.push);
};

this.isReady = function () {
logger.debug("in TVSqaured isReady");
return !!(window._tvq && window._tvq.push !== Array.prototype.push);
};

this.page = function () {
window._tvq.push(["trackPageView"]);
};

this.formatRevenue = function (revenue) {
var rev = revenue;
rev = parseFloat(rev.toString().replace(/^[^\d.]*/, ""));
return rev;
};

this.brandId = config.brandId;
this.clientId = config.clientId;
this.eventWhiteList = config.eventWhiteList || [];
this.customMetrics = config.customMetrics || [];
this.name = "TVSquared";
}

_createClass(TVSquared, [{
key: "init",
value: function init() {
logger.debug("===in init TVSquared===");
window._tvq = window._tvq || [];
var url = document.location.protocol === "https:" ? "https://" : "http://";
url += "collector-".concat(this.clientId, ".tvsquared.com/");

window._tvq.push(["setSiteId", this.brandId]);

window._tvq.push(["setTrackerUrl", "".concat(url, "tv2track.php")]);

ScriptLoader("TVSquared-integration", "".concat(url, "tv2track.js"));
}
}, {
key: "track",
value: function track(rudderElement) {
var _rudderElement$messag = rudderElement.message,
event = _rudderElement$messag.event,
userId = _rudderElement$messag.userId,
anonymousId = _rudderElement$messag.anonymousId;
var _rudderElement$messag2 = rudderElement.message.properties,
revenue = _rudderElement$messag2.revenue,
productType = _rudderElement$messag2.productType,
category = _rudderElement$messag2.category,
order_id = _rudderElement$messag2.order_id,
promotion_id = _rudderElement$messag2.promotion_id;
var i;
var j;
var whitelist = this.eventWhiteList.slice();
whitelist = whitelist.filter(function (wl) {
return wl.event !== "";
});

for (i = 0; i < whitelist.length; i += 1) {
if (event.toUpperCase() === whitelist[i].event.toUpperCase()) {
break;
}

if (i === whitelist.length - 1) {
return;
}
}

var session = {
user: userId || anonymousId || ""
};
var action = {
rev: revenue ? this.formatRevenue(revenue) : "",
prod: category || productType || "",
id: order_id || "",
promo: promotion_id || ""
};
var customMetrics = this.customMetrics.slice();
customMetrics = customMetrics.filter(function (cm) {
return cm.propertyName !== "";
});

if (customMetrics.length) {
for (j = 0; j < customMetrics.length; j += 1) {
var key = customMetrics[j].propertyName;
var value = rudderElement.message.properties[key];

if (value) {
action[key] = value;
}
}
}

window._tvq.push([function () {
this.setCustomVariable(5, "session", JSON.stringify(session), "visit");
}]);

if (event.toUpperCase() !== "RESPONSE") {
window._tvq.push([function () {
this.setCustomVariable(5, event, JSON.stringify(action), "page");
}]);

window._tvq.push(["trackPageView"]);
}
}
}]);

return TVSquared;
}();

// (config-plan name, native destination.name , exported integration name(this one below))

var integrations = {
Expand All @@ -12713,7 +12832,8 @@
LOTAME: Lotame,
OPTIMIZELY: Optimizely,
BUGSNAG: Bugsnag,
FULLSTORY: Fullstory
FULLSTORY: Fullstory,
TVSQUARED: TVSquared
};

// Application class
Expand All @@ -12723,15 +12843,15 @@
this.build = "1.0.0";
this.name = "RudderLabs JavaScript SDK";
this.namespace = "com.rudderlabs.javascript";
this.version = "1.0.10";
this.version = "1.0.11";
};

// Library information class
var RudderLibraryInfo = function RudderLibraryInfo() {
_classCallCheck(this, RudderLibraryInfo);

this.name = "RudderLabs JavaScript SDK";
this.version = "1.0.10";
this.version = "1.0.11";
}; // Operating System information class


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.10",
"version": "1.0.11",
"description": "Rudder Javascript SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down
104 changes: 104 additions & 0 deletions integrations/TVSquared/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/* eslint-disable camelcase */
/* eslint-disable no-underscore-dangle */
import ScriptLoader from "../ScriptLoader";
import logger from "../../utils/logUtil";

class TVSquared {
constructor(config) {
this.brandId = config.brandId;
this.clientId = config.clientId;
this.eventWhiteList = config.eventWhiteList || [];
this.customMetrics = config.customMetrics || [];
this.name = "TVSquared";
}

init() {
logger.debug("===in init TVSquared===");
window._tvq = window._tvq || [];
let url = document.location.protocol === "https:" ? "https://" : "http://";
url += `collector-${this.clientId}.tvsquared.com/`;
window._tvq.push(["setSiteId", this.brandId]);
window._tvq.push(["setTrackerUrl", `${url}tv2track.php`]);
ScriptLoader("TVSquared-integration", `${url}tv2track.js`);
}

isLoaded = () => {
logger.debug("in TVSqaured isLoaded");
return !!(window._tvq && window._tvq.push !== Array.prototype.push);
};

isReady = () => {
logger.debug("in TVSqaured isReady");
return !!(window._tvq && window._tvq.push !== Array.prototype.push);
};

page = () => {
window._tvq.push(["trackPageView"]);
};

track(rudderElement) {
const { event, userId, anonymousId } = rudderElement.message;
const {
revenue,
productType,
category,
order_id,
promotion_id,
} = rudderElement.message.properties;
let i;
let j;
let whitelist = this.eventWhiteList.slice();
whitelist = whitelist.filter((wl) => {
return wl.event !== "";
});
for (i = 0; i < whitelist.length; i += 1) {
if (event.toUpperCase() === whitelist[i].event.toUpperCase()) {
break;
}
if (i === whitelist.length - 1) {
return;
}
}

const session = { user: userId || anonymousId || "" };
const action = {
rev: revenue ? this.formatRevenue(revenue) : "",
prod: category || productType || "",
id: order_id || "",
promo: promotion_id || "",
};
let customMetrics = this.customMetrics.slice();
customMetrics = customMetrics.filter((cm) => {
return cm.propertyName !== "";
});
if (customMetrics.length) {
for (j = 0; j < customMetrics.length; j += 1) {
const key = customMetrics[j].propertyName;
const value = rudderElement.message.properties[key];
if (value) {
action[key] = value;
}
}
}
window._tvq.push([
function () {
this.setCustomVariable(5, "session", JSON.stringify(session), "visit");
},
]);
if (event.toUpperCase() !== "RESPONSE") {
window._tvq.push([
function () {
this.setCustomVariable(5, event, JSON.stringify(action), "page");
},
]);
window._tvq.push(["trackPageView"]);
}
};

formatRevenue = (revenue) => {
let rev = revenue;
rev = parseFloat(rev.toString().replace(/^[^\d.]*/, ""));
return rev;
};
}
export default TVSquared;
3 changes: 3 additions & 0 deletions integrations/TVSquared/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import TVSquared from "./browser";

export default TVSquared;
1 change: 1 addition & 0 deletions integrations/client_server_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const clientToServerNames = {
VWO: "VWO",
OPTIMIZELY: "Optimizely",
FULLSTORY: "Fullstory",
TVSQUUARED: "TVSquared"
};

export { clientToServerNames };
2 changes: 2 additions & 0 deletions integrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as Lotame from "./Lotame";
import * as Optimizely from "./Optimizely";
import * as Bugsnag from "./Bugsnag";
import * as Fullstory from "./Fullstory";
import * as TVSquared from "./TVSquared";

// the key names should match the destination.name value to keep partity everywhere
// (config-plan name, native destination.name , exported integration name(this one below))
Expand All @@ -39,6 +40,7 @@ const integrations = {
OPTIMIZELY: Optimizely.default,
BUGSNAG: Bugsnag.default,
FULLSTORY: Fullstory.default,
TVSQUARED: TVSquared.default,
};

export { integrations };
1 change: 1 addition & 0 deletions integrations/integration_cname.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const commonNames = {
FULLSTORY: "FULLSTORY",
Fullstory: "FULLSTORY",
BUGSNAG: "BUGSNAG",
TVSQUARED: "TVSQUARED",
};

export { commonNames };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rudder-analytics",
"version": "1.1.4",
"version": "1.1.5",
"description": "",
"main": "./dist/browser.min.js",
"size-limit": [
Expand Down