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

@financial-times/n-tracking

Package Overview
Dependencies
Maintainers
16
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@financial-times/n-tracking - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

dist/tracking/__test__/index.integration.spec.js

79

dist/context/__test__/prepare-context.spec.js
"use strict";
var _helpers = require("../../__test__/helpers");
var _withDomOverwrites = _interopRequireDefault(require("with-dom-overwrites"));

@@ -11,2 +11,4 @@ var _error = require("../../utilities/error");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

@@ -60,5 +62,7 @@

it('should add the content info to the created context it is present', function () {
(0, _helpers.withDOM)({
html: '<html data-content-id="10001"></html>',
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': '<html data-content-id="10001"></html>'
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -77,5 +81,7 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, {

var taxonomy = 'taxonomy-123';
(0, _helpers.withDOM)({
html: "<html data-concept-id=\"".concat(conceptId, "\" data-taxonomy=\"").concat(taxonomy, "\"></html>"),
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t\t<html data-concept-id=\"".concat(conceptId, "\" data-taxonomy=\"").concat(taxonomy, "\"></html>\n\t\t\t\t\t\t")
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -92,5 +98,7 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, {

it('should not add the concept info to the created context', function () {
(0, _helpers.withDOM)({
html: '<html data-taxonomy="123"></html>',
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': '<html data-taxonomy="123"></html>'
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -123,5 +131,7 @@ expect(context).toEqual(expectedContextAppInfo);

var edition = 'edition123';
(0, _helpers.withDOM)({
html: "\n\t\t\t\t\t<html>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div data-next-edition=\"".concat(edition, "\">\n\t\t\t\t\t\t\t\t...\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>\n\t\t\t\t"),
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t\t<div data-next-edition=\"".concat(edition, "\">\n\t\t\t\t\t\t\t\t\t...\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</html>\n\t\t\t\t\t")
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -139,5 +149,7 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, {

var url = "https://www.ft.com/content/foo?desktop=true&segmentId=".concat(segmentId, "#myft:notification:instant-email:content");
(0, _helpers.withDOM)({
url: url,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.location.href': url
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -155,5 +167,7 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, {

var url = "https://enterprise.ft.com/en-gb/contact-us/?cpccampaign=".concat(cpcCampaign);
(0, _helpers.withDOM)({
url: url,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.location.href': url
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -169,11 +183,14 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, {

it('should add the page meta info to the context if it is present', function () {
window.FT = {
pageMeta: {
one: '1',
two: '2'
(0, _withDomOverwrites["default"])({
overwrites: {
'window.FT.pageMeta': {
one: '1',
two: '2'
}
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);
expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, window.FT.pageMeta));
}
};
var context = (0, _prepareContext.prepareContext)(appInfo);
expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, window.FT.pageMeta));
delete window.FT;
});
});

@@ -183,5 +200,7 @@ });

it('should add the AB state data to the context if it is present', function () {
(0, _helpers.withDOM)({
html: "\n\t\t\t\t\t<html data-ab-state=\"one:on,two:off\">\n\t\t\t\t\t\t...\n\t\t\t\t\t</html>\n\t\t\t\t",
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t<html data-ab-state=\"one:on,two:off\">\n\t\t\t\t\t\t\t...\n\t\t\t\t\t\t</html>\n\t\t\t\t\t"
},
run: function run() {
var context = (0, _prepareContext.prepareContext)(appInfo);

@@ -188,0 +207,0 @@ expect(context).toEqual(_objectSpread({}, expectedContextAppInfo, _defineProperty({}, 'active_ammit_flags', {

"use strict";
var _helpers = require("../../__test__/helpers");
var _withDomOverwrites = _interopRequireDefault(require("with-dom-overwrites"));
var _prepareErrorInfoForContext = require("../prepare-error-info-for-context");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var referrer = 'foo-referrer';

@@ -13,6 +15,8 @@ var errorStatus = '503';

var url = createErrorUrl(errorStatus);
(0, _helpers.withDOM)({
url: url,
referrer: referrer,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.referrer': referrer,
'document.location.href': url
},
run: function run() {
var info = (0, _prepareErrorInfoForContext.prepareErrorInfoForContext)();

@@ -29,6 +33,8 @@ expect(info).toEqual({

var url = createErrorUrl(errorStatus, errorReason);
(0, _helpers.withDOM)({
url: url,
referrer: referrer,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.referrer': referrer,
'document.location.href': url
},
run: function run() {
var info = (0, _prepareErrorInfoForContext.prepareErrorInfoForContext)();

@@ -35,0 +41,0 @@ expect(info).toEqual({

"use strict";
var _helpers = require("../../__test__/helpers");
var _withDomOverwrites = _interopRequireDefault(require("with-dom-overwrites"));

@@ -43,5 +43,7 @@ var _barrierViewTracking = _interopRequireDefault(require("../barrier-view-tracking"));

it('should return an array of acquisition context entries if they have been specified', function () {
(0, _helpers.withDOM)({
html: "\n\t\t\t\t\t<html>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<div data-acquisition-context=\"a\"></div>\n\t\t\t\t\t\t\t\t<div data-acquisition-context=\"b\"></div>\n\t\t\t\t\t\t\t\t<div data-acquisition-context=\"c\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>\n\t\t\t\t",
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<div data-acquisition-context=\"a\"></div>\n\t\t\t\t\t\t\t\t\t<div data-acquisition-context=\"b\"></div>\n\t\t\t\t\t\t\t\t\t<div data-acquisition-context=\"c\"></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</html>\n\t\t\t\t\t"
},
run: function run() {
var tracking = new _barrierViewTracking["default"]();

@@ -59,5 +61,7 @@ expect(tracking.getAcquisitionContext()).toEqual(['a', 'b', 'c']);

it('should return the ids of all the offers', function () {
(0, _helpers.withDOM)({
html: "\n\t\t\t\t\t<html>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<div data-offer-id=\"1\"></div>\n\t\t\t\t\t\t\t\t<div data-offer-id=\"2\"></div>\n\t\t\t\t\t\t\t\t<div data-offer-id=\"3\"></div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>\n\t\t\t\t",
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<div data-offer-id=\"1\"></div>\n\t\t\t\t\t\t\t\t\t<div data-offer-id=\"2\"></div>\n\t\t\t\t\t\t\t\t\t<div data-offer-id=\"3\"></div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</html>\n\t\t\t\t\t"
},
run: function run() {
var tracking = new _barrierViewTracking["default"]();

@@ -77,5 +81,7 @@ expect(tracking.getOffers()).toEqual(['1', '2', '3']);

var url = "https://www.ft.com/products?barrierReferrer=".concat(referrer);
(0, _helpers.withDOM)({
url: url,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.location.href': url
},
run: function run() {
var tracking = new _barrierViewTracking["default"]();

@@ -93,5 +99,7 @@ expect(tracking.getBarrierReferrer()).toBe(referrer);

it('should return the barrier data if it has been specified', function () {
(0, _helpers.withDOM)({
html: "\n\t\t\t\t\t<html>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tdata-barrier=\"".concat(barrierData.type, "\"\n\t\t\t\t\t\t\t\tdata-barrier-messaging=\"").concat(barrierData.messaging, "\"\n\t\t\t\t\t\t\t\tdata-opportunity-subtype=\"").concat(barrierData.opportunitySubType, "\"\n\t\t\t\t\t\t\t\tdata-barrier-is-product-selector=\"").concat(barrierData.isProductSelector, "\">\n\t\t\t\t\t\t\t\t...\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</body>\n\t\t\t\t\t</html>\n\t\t\t\t"),
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.documentElement.outerHTML': "\n\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tdata-barrier=\"".concat(barrierData.type, "\"\n\t\t\t\t\t\t\t\t\tdata-barrier-messaging=\"").concat(barrierData.messaging, "\"\n\t\t\t\t\t\t\t\t\tdata-opportunity-subtype=\"").concat(barrierData.opportunitySubType, "\"\n\t\t\t\t\t\t\t\t\tdata-barrier-is-product-selector=\"").concat(barrierData.isProductSelector, "\">\n\t\t\t\t\t\t\t\t\t...\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</html>\n\t\t\t\t\t")
},
run: function run() {
var tracking = new _barrierViewTracking["default"]();

@@ -98,0 +106,0 @@ expect(tracking.getBarrierData()).toEqual(barrierData);

@@ -7,3 +7,3 @@ "use strict";

var _helpers = require("../../__test__/helpers");
var _withDomOverwrites = _interopRequireDefault(require("with-dom-overwrites"));

@@ -219,5 +219,7 @@ var _dom = require("../../utilities/dom");

it('should return `true` if the script is not running within an iframe', function () {
(0, _helpers.withDOM)({
windowTop: {},
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'window.top': {}
},
run: function run() {
var tracking = new _pageViewTracking["default"]();

@@ -232,5 +234,7 @@ expect(tracking.isFrameset()).toBe(true);

var url = 'http://errors-next.ft.com/foo';
(0, _helpers.withDOM)({
url: url,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.location.href': url
},
run: function run() {
var tracking = new _pageViewTracking["default"]();

@@ -237,0 +241,0 @@ expect(tracking.isInErrorDomain()).toBe(true);

@@ -8,4 +8,6 @@ "use strict";

var _copyTracking = _interopRequireDefault(require("copy-tracking"));
var _oTracking = _interopRequireDefault(require("o-tracking"));
var _copyTracking = _interopRequireDefault(require("./copy-tracking"));
var _pageAttentionTracking = _interopRequireDefault(require("./page-attention-tracking"));

@@ -17,3 +19,3 @@

// Click-event tracking - https://github.com/Financial-Times/o-tracking
_copyTracking["default"].click.init('cta');
_oTracking["default"].click.init('cta');

@@ -20,0 +22,0 @@ _copyTracking["default"].init();

@@ -12,2 +12,4 @@ "use strict";

var _getAppInfo = require("./get-app-info");
var _getUserData = require("./get-user-data");

@@ -32,6 +34,6 @@

var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
flags = _ref.flags,
context = _ref.context,
_ref$appInfo = _ref.appInfo,
appInfo = _ref$appInfo === void 0 ? {} : _ref$appInfo,
appInfo = _ref.appInfo,
_ref$flags = _ref.flags,
flags = _ref$flags === void 0 ? window.FT.flags : _ref$flags,
_ref$additionalContex = _ref.additionalContext,

@@ -41,3 +43,3 @@ additionalContext = _ref$additionalContex === void 0 ? {} : _ref$additionalContex;

try {
if (!flags || !flags.get('oTracking')) {
if (!flags || !flags['oTracking']) {
return;

@@ -47,3 +49,4 @@ }

var userData = (0, _getUserData.getUserData)();
var contextToUse = context || (0, _context.prepareContext)(appInfo);
var appInfoToUse = appInfo || (0, _getAppInfo.getAppInfo)();
var contextToUse = context || (0, _context.prepareContext)(appInfoToUse);

@@ -54,3 +57,3 @@ _oTracking["default"].init({

user: userData,
useSendBeacon: flags.get('sendBeacon')
useSendBeacon: flags['sendBeacon']
});

@@ -57,0 +60,0 @@

"use strict";
var _helpers = require("../../__test__/helpers");
var _withDomOverwrites = _interopRequireDefault(require("with-dom-overwrites"));
var _error = require("../error");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
describe('helper: error', function () {

@@ -12,5 +14,7 @@ describe('getErrorStatus()', function () {

var url = "http://errors-next.ft.com/errors/page/503?anonymous=true&edition=uk&nextErrorStatus=".concat(errorStatus);
(0, _helpers.withDOM)({
url: url,
assertion: function assertion() {
(0, _withDomOverwrites["default"])({
overwrites: {
'document.location.href': url
},
run: function run() {
expect((0, _error.getErrorStatus)()).toBe(errorStatus);

@@ -17,0 +21,0 @@ }

@@ -8,2 +8,3 @@ "use strict";

exports.getRootData = getRootData;
exports.hasRootData = hasRootData;
exports.findInQueryString = findInQueryString;

@@ -20,2 +21,6 @@ exports.selectEachAttributeValue = selectEachAttributeValue;

function hasRootData(name) {
return document.documentElement.hasAttribute("data-".concat(name));
}
function findInQueryString(name) {

@@ -22,0 +27,0 @@ var exp = new RegExp("[?&]".concat(name, "=([^?&]+)"));

{
"name": "@financial-times/n-tracking",
"description": "Client-side tracking for ft.com apps",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",

@@ -23,3 +23,4 @@ "main": "dist/index.js",

"jest": "^24.7.1",
"jsdom": "^15.0.0"
"jsdom": "^15.0.0",
"with-dom-overwrites": "^1.2.0"
},

@@ -26,0 +27,0 @@ "config": {},

@@ -1,2 +0,2 @@

import { withDOM } from '../../__test__/helpers';
import withDomOverwrites from 'with-dom-overwrites';
import { getErrorStatus } from '../../utilities/error';

@@ -52,5 +52,8 @@ import { prepareContext } from '../prepare-context';

it('should add the content info to the created context it is present', () => {
withDOM({
html: '<html data-content-id="10001"></html>',
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML':
'<html data-content-id="10001"></html>'
},
run: () => {
const context = prepareContext(appInfo);

@@ -72,5 +75,9 @@ expect(context).toEqual({

withDOM({
html: `<html data-concept-id="${conceptId}" data-taxonomy="${taxonomy}"></html>`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html data-concept-id="${conceptId}" data-taxonomy="${taxonomy}"></html>
`
},
run: () => {
const context = prepareContext(appInfo);

@@ -90,5 +97,8 @@

it('should not add the concept info to the created context', () => {
withDOM({
html: '<html data-taxonomy="123"></html>',
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML':
'<html data-taxonomy="123"></html>'
},
run: () => {
const context = prepareContext(appInfo);

@@ -124,13 +134,15 @@

const edition = 'edition123';
withDOM({
html: `
<html>
<body>
<div data-next-edition="${edition}">
...
</div>
</body>
</html>
`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html>
<body>
<div data-next-edition="${edition}">
...
</div>
</body>
</html>
`
},
run: () => {
const context = prepareContext(appInfo);

@@ -148,5 +160,7 @@ expect(context).toEqual({ ...expectedContextAppInfo, edition });

withDOM({
url,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.location.href': url
},
run: () => {
const context = prepareContext(appInfo);

@@ -167,5 +181,7 @@ expect(context).toEqual({

withDOM({
url,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.location.href': url
},
run: () => {
const context = prepareContext(appInfo);

@@ -183,16 +199,17 @@ expect(context).toEqual({

it('should add the page meta info to the context if it is present', () => {
window.FT = {
pageMeta: {
one: '1',
two: '2'
withDomOverwrites({
overwrites: {
'window.FT.pageMeta': {
one: '1',
two: '2'
}
},
run: () => {
const context = prepareContext(appInfo);
expect(context).toEqual({
...expectedContextAppInfo,
...window.FT.pageMeta
});
}
};
const context = prepareContext(appInfo);
expect(context).toEqual({
...expectedContextAppInfo,
...window.FT.pageMeta
});
delete window.FT;
});

@@ -203,9 +220,11 @@ });

it('should add the AB state data to the context if it is present', () => {
withDOM({
html: `
<html data-ab-state="one:on,two:off">
...
</html>
`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html data-ab-state="one:on,two:off">
...
</html>
`
},
run: () => {
const context = prepareContext(appInfo);

@@ -212,0 +231,0 @@ expect(context).toEqual({

@@ -1,2 +0,2 @@

import { withDOM } from '../../__test__/helpers';
import withDomOverwrites from 'with-dom-overwrites';
import { prepareErrorInfoForContext } from '../prepare-error-info-for-context';

@@ -12,8 +12,14 @@

withDOM({
url,
referrer,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.referrer': referrer,
'document.location.href': url
},
run: () => {
const info = prepareErrorInfoForContext();
expect(info).toEqual({ url, referrer, errorStatus });
expect(info).toEqual({
url,
referrer,
errorStatus
});
}

@@ -26,8 +32,15 @@ });

withDOM({
url,
referrer,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.referrer': referrer,
'document.location.href': url
},
run: () => {
const info = prepareErrorInfoForContext();
expect(info).toEqual({ url, referrer, errorStatus, errorReason });
expect(info).toEqual({
url,
referrer,
errorStatus,
errorReason
});
}

@@ -34,0 +47,0 @@ });

@@ -1,2 +0,2 @@

import { withDOM } from '../../__test__/helpers';
import withDomOverwrites from 'with-dom-overwrites';
import BarrierViewTracking from '../barrier-view-tracking';

@@ -20,15 +20,17 @@

it('should return an array of acquisition context entries if they have been specified', () => {
withDOM({
html: `
<html>
<body>
<div>
<div data-acquisition-context="a"></div>
<div data-acquisition-context="b"></div>
<div data-acquisition-context="c"></div>
</div>
</body>
</html>
`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html>
<body>
<div>
<div data-acquisition-context="a"></div>
<div data-acquisition-context="b"></div>
<div data-acquisition-context="c"></div>
</div>
</body>
</html>
`
},
run: () => {
const tracking = new BarrierViewTracking();

@@ -48,15 +50,17 @@ expect(tracking.getAcquisitionContext()).toEqual(['a', 'b', 'c']);

it('should return the ids of all the offers', () => {
withDOM({
html: `
<html>
<body>
<div>
<div data-offer-id="1"></div>
<div data-offer-id="2"></div>
<div data-offer-id="3"></div>
</div>
</body>
</html>
`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html>
<body>
<div>
<div data-offer-id="1"></div>
<div data-offer-id="2"></div>
<div data-offer-id="3"></div>
</div>
</body>
</html>
`
},
run: () => {
const tracking = new BarrierViewTracking();

@@ -79,5 +83,7 @@ expect(tracking.getOffers()).toEqual(['1', '2', '3']);

withDOM({
url,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.location.href': url
},
run: () => {
const tracking = new BarrierViewTracking();

@@ -97,17 +103,19 @@ expect(tracking.getBarrierReferrer()).toBe(referrer);

it('should return the barrier data if it has been specified', () => {
withDOM({
html: `
<html>
<body>
<div
data-barrier="${barrierData.type}"
data-barrier-messaging="${barrierData.messaging}"
data-opportunity-subtype="${barrierData.opportunitySubType}"
data-barrier-is-product-selector="${barrierData.isProductSelector}">
...
</div>
</body>
</html>
`,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.documentElement.outerHTML': `
<html>
<body>
<div
data-barrier="${barrierData.type}"
data-barrier-messaging="${barrierData.messaging}"
data-opportunity-subtype="${barrierData.opportunitySubType}"
data-barrier-is-product-selector="${barrierData.isProductSelector}">
...
</div>
</body>
</html>
`
},
run: () => {
const tracking = new BarrierViewTracking();

@@ -114,0 +122,0 @@ expect(tracking.getBarrierData()).toEqual(barrierData);

import oTracking from 'o-tracking';
import PageViewTracking from '../page-view-tracking';
import { withDOM } from '../../__test__/helpers';
import withDomOverwrites from 'with-dom-overwrites';
import { getRootData } from '../../utilities/dom';

@@ -167,5 +167,7 @@ import { getErrorStatus } from '../../utilities/error';

it('should return `true` if the script is not running within an iframe', () => {
withDOM({
windowTop: {},
assertion: () => {
withDomOverwrites({
overwrites: {
'window.top': {}
},
run: () => {
const tracking = new PageViewTracking();

@@ -182,5 +184,7 @@ expect(tracking.isFrameset()).toBe(true);

withDOM({
url,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.location.href': url
},
run: () => {
const tracking = new PageViewTracking();

@@ -187,0 +191,0 @@ expect(tracking.isInErrorDomain()).toBe(true);

@@ -1,3 +0,3 @@

import oTracking from 'copy-tracking';
import CopyTracking from 'copy-tracking';
import oTracking from 'o-tracking';
import CopyTracking from './copy-tracking';
import PageAttentionTracking from './page-attention-tracking';

@@ -4,0 +4,0 @@

import oTracking from 'o-tracking';
import { broadcast } from '../broadcast';
import { getAppInfo } from './get-app-info';
import { getUserData } from './get-user-data';

@@ -11,5 +12,10 @@ import { prepareContext } from '../context';

export const tracking = {
init ({ flags, context, appInfo = {}, additionalContext = {} } = {}) {
init ({
context,
appInfo,
flags = window.FT.flags,
additionalContext = {}
} = {}) {
try {
if (!flags || !flags.get('oTracking')) {
if (!flags || !flags['oTracking']) {
return;

@@ -19,3 +25,4 @@ }

const userData = getUserData();
const contextToUse = context || prepareContext(appInfo);
const appInfoToUse = appInfo || getAppInfo();
const contextToUse = context || prepareContext(appInfoToUse);

@@ -26,3 +33,3 @@ oTracking.init({

user: userData,
useSendBeacon: flags.get('sendBeacon')
useSendBeacon: flags['sendBeacon']
});

@@ -29,0 +36,0 @@

@@ -1,2 +0,2 @@

import { withDOM } from '../../__test__/helpers';
import withDomOverwrites from 'with-dom-overwrites';
import { getErrorStatus } from '../error';

@@ -10,5 +10,7 @@

withDOM({
url,
assertion: () => {
withDomOverwrites({
overwrites: {
'document.location.href': url
},
run: () => {
expect(getErrorStatus()).toBe(errorStatus);

@@ -15,0 +17,0 @@ }

@@ -9,2 +9,6 @@ export function nodesToArray (nodelist) {

export function hasRootData (name) {
return document.documentElement.hasAttribute(`data-${name}`);
}
export function findInQueryString (name) {

@@ -11,0 +15,0 @@ let exp = new RegExp(`[?&]${name}=([^?&]+)`);

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