Skip to content

Commit

Permalink
Merge pull request #207 from spring-media/snowplow_poc
Browse files Browse the repository at this point in the history
use utag.data instead of global window var
  • Loading branch information
nickyanalytics authored Mar 21, 2024
2 parents 26fa448 + 3104741 commit e1f9fd5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
24 changes: 12 additions & 12 deletions extensions/doPlugins_global.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ s._articleViewTypeObj = {

if (!s._utils.isAdWall(s)) {
if (s._utils.isArticlePage()) {
s._articleViewType = s.eVar44 = window.sp_events = pageViewEvent;
s.eVar37 = s.prop59 = window.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.sp_m_channel_category = channelCategory;
s._articleViewType = s.eVar44 = window.utag.data.sp_events = pageViewEvent;
s.eVar37 = s.prop59 = window.utag.data.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.utag.data.sp_m_channel_category = channelCategory;
s._eventsObj.addEvent(pageViewEvent);
this.setPageSourceAndAgeForCheckout(s);
}
Expand Down Expand Up @@ -657,9 +657,9 @@ s._setExternalReferringDomainEvents = function (s) {
});
if (isRegexMatch || isDomainMatch) {
s._eventsObj.addEvent(event);
s.eVar44 = window.sp_events = s.eVar44 ? s.eVar44 + ',' + event : event;
s.eVar37 = s.prop59 = window.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.sp_m_channel_category = channelCategory;
s.eVar44 = window.utag.data.sp_events = s.eVar44 ? s.eVar44 + ',' + event : event;
s.eVar37 = s.prop59 = window.utag.data.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.utag.data.sp_m_channel_category = channelCategory;
s._articleViewType = s.eVar44;
}
});
Expand Down Expand Up @@ -721,9 +721,9 @@ s._setTrackingValueEvents = function (s) {
channelCategory = 'Other organic Social';
}
s._eventsObj.addEvent(event);
s._articleViewType = s.eVar44 = window.sp_events += ',' + event;
s.eVar37 = s.prop59 = window.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.sp_m_channel_category = channelCategory || '';
s._articleViewType = s.eVar44 = window.utag.data.sp_events += ',' + event;
s.eVar37 = s.prop59 = window.utag.data.sp_m_channel = channel || 'no-entry';
s.eVar38 = s.prop60 = window.utag.data.sp_m_channel_category = channelCategory || '';
}
}
}
Expand Down Expand Up @@ -790,9 +790,9 @@ s._homeTeaserTrackingObj = {
const blockValue = this.getBlockValue();
const pageId = this.getPageId();
if (trackingValue) {
s.eVar66 = window.sp_teaser_position = trackingValue;
s.eVar92 = window.sp_teaser_position_page = trackingValue + '|' + pageId;
s.eVar97 = window.sp_teaser_block = blockValue;
s.eVar66 = window.utag.data.sp_teaser_position = trackingValue;
s.eVar92 = window.utag.data.sp_teaser_position_page = trackingValue + '|' + pageId;
s.eVar97 = window.utag.data.sp_teaser_block = blockValue;
}
},

Expand Down
5 changes: 5 additions & 0 deletions tests/doplugins/doplugins_externel_referring_domain.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const sObject = require('../../extensions/doPlugins_global');
const {createWindowMock} = require('../mocks/browserMocks');

describe('External referring domains', () => {
let s;
Expand All @@ -7,6 +8,10 @@ describe('External referring domains', () => {
let isArticlePageMock;

beforeEach(() => {
// Create a fresh window mock for each test.
const windowMock = createWindowMock();
jest.spyOn(global, 'window', 'get')
.mockImplementation(() => (windowMock));
// Provide a fresh copy of the s-object for each test.
s = {...sObject};
addEventMock = jest.spyOn(s._eventsObj, 'addEvent').mockImplementation();
Expand Down
5 changes: 5 additions & 0 deletions tests/doplugins/doplugins_trackingValue_events.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const sObject = require('../../extensions/doPlugins_global');
const {createWindowMock} = require('../mocks/browserMocks');

describe('_setTrackingValueEvents (URL Parameter like cid)', () => {
let s;
Expand All @@ -8,6 +9,10 @@ describe('_setTrackingValueEvents (URL Parameter like cid)', () => {
let isSocialTrackingParameterMock;

beforeEach(() => {
// Create a fresh window mock for each test.
const windowMock = createWindowMock();
jest.spyOn(global, 'window', 'get')
.mockImplementation(() => (windowMock));
// Provide a fresh copy of the s-object for each test.
s = {...sObject};
addEventMock = jest.spyOn(s._eventsObj, 'addEvent').mockImplementation();
Expand Down

0 comments on commit e1f9fd5

Please sign in to comment.