Skip to content
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
2 changes: 1 addition & 1 deletion libraries/intentIqConstants/intentIqConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DEFAULT_PERCENTAGE = 95;
export const CLIENT_HINTS_KEY = "_iiq_ch";
export const EMPTY = "EMPTY";
export const GVLID = "1323";
export const VERSION = 0.37;
export const VERSION = 0.371;
export const PREBID = "pbjs";
export const HOURS_24 = 86400000;
export const HOURS_72 = HOURS_24 * 3;
Expand Down
9 changes: 7 additions & 2 deletions modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@

function verifyIdType(value) {
if (value === 0 || value === 1 || value === 3 || value === 4) return value;
return -1;

Check warning on line 105 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

105 line is not covered with tests
}

function appendPartnersFirstParty(url, configParams) {
Expand Down Expand Up @@ -148,7 +148,7 @@
+d[3]
);
} catch (e) {
return NaN;

Check warning on line 151 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

151 line is not covered with tests
}
}

Expand Down Expand Up @@ -356,13 +356,18 @@
const cmpData = getCmpData();
const gdprDetected = cmpData.gdprString;
firstPartyData = tryParse(readData(FIRST_PARTY_KEY_FINAL, allowedStorage));
actualABGroup = defineABTestingGroup(configParams, partnerData?.terminationCause);
if (groupChanged) groupChanged(actualABGroup, partnerData?.terminationCause);
const currentBrowserLowerCase = detectBrowser();
const browserBlackList = typeof configParams.browserBlackList === 'string' ? configParams.browserBlackList.toLowerCase() : '';
const isBlacklisted = browserBlackList?.includes(currentBrowserLowerCase);
let newUser = false;

if (!isBlacklisted) {
actualABGroup = defineABTestingGroup(configParams, partnerData?.terminationCause);
if (groupChanged) groupChanged(actualABGroup, partnerData?.terminationCause);
} else {
actualABGroup = undefined;
}

setGamReporting(gamObjectReference, gamParameterName, actualABGroup, isBlacklisted);

callbackTimeoutID = setTimeout(() => {
Expand Down Expand Up @@ -421,7 +426,7 @@
if (chSupported) {
chPromise = fetchAndHandleCH();
chPromise.catch(err => {
logError('fetchAndHandleCH failed', err);

Check warning on line 429 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

429 line is not covered with tests
});
} else {
clientHints = '';
Expand All @@ -437,8 +442,8 @@
if (typeof partnerData.failCount === 'number') failCount = partnerData.failCount;
if (typeof partnerData.noDataCounter === 'number') noDataCount = partnerData.noDataCounter;
if (partnerData.wsrvcll) {
partnerData.wsrvcll = false;
storeData(PARTNER_DATA_KEY, JSON.stringify(partnerData), allowedStorage, firstPartyData);

Check warning on line 446 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

445-446 lines are not covered with tests
}

if (partnerData.data) {
Expand Down Expand Up @@ -505,7 +510,7 @@
.then(ch => buildAndSendPixel(ch || ''));
}
} else {
buildAndSendPixel('');

Check warning on line 513 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

513 line is not covered with tests
}
return;
}
Expand Down Expand Up @@ -568,7 +573,7 @@
};
if (callbackTimeoutID) clearTimeout(callbackTimeoutID);
if ('cttl' in respJson) {
partnerData.cttl = respJson.cttl;

Check warning on line 576 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

576 line is not covered with tests
} else partnerData.cttl = HOURS_72;

if ('tc' in respJson) {
Expand Down Expand Up @@ -609,7 +614,7 @@
}
// If data is empty, means we should save as INVALID_ID
if (respJson.data === '') {
respJson.data = INVALID_ID;

Check warning on line 617 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

617 line is not covered with tests
} else {
// If data is a single string, assume it is an id with source intentiq.com
if (respJson.data && typeof respJson.data === 'string') {
Expand All @@ -624,7 +629,7 @@
}

if ('sid' in respJson) {
partnerData.siteId = respJson.sid;

Check warning on line 632 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

632 line is not covered with tests
}

if ('spd' in respJson) {
Expand All @@ -633,14 +638,14 @@
}

if ('abTestUuid' in respJson) {
if ('ls' in respJson && respJson.ls === true) {
partnerData.abTestUuid = respJson.abTestUuid;

Check warning on line 642 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

641-642 lines are not covered with tests
}
}

if ('gpr' in respJson) {
// GAM prediction reporting
partnerData.gpr = respJson.gpr;

Check warning on line 648 in modules/intentIqIdSystem.js

View workflow job for this annotation

GitHub Actions / Coverage

648 line is not covered with tests
} else {
delete partnerData.gpr; // remove prediction flag in case server doesn't provide it
}
Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/intentIqIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,42 @@ describe('IntentIQ tests', function () {
expect(groupChangedSpy.calledWith(usedGroup)).to.be.true;
});

it('should NOT call groupChanged when the current browser is blacklisted', async function () {
const groupChangedSpy = sinon.spy();
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk,
groupChanged: groupChangedSpy
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

expect(groupChangedSpy.called).to.be.false;
});

it('should not mark a test group on the sync pixel when the current browser is blacklisted', async function () {
const blk = detectBrowser();
const configParams = {
params: {
...defaultConfigParams.params,
browserBlackList: blk
}
};

intentIqIdSubmodule.getId(configParams);
await waitForClientHints();

const pixelRequest = server.requests[0];
expect(pixelRequest).to.exist;
expect(pixelRequest.url).to.include('at=20');
expect(pixelRequest.url).to.not.include('testGroup=');
expect(pixelRequest.url).to.include('isInTestGroup=false');
});

it('should include testPercentage with configured abPercentage in AT=39 URL', async function () {
const callBackSpy = sinon.spy();
const configParams = {
Expand Down
Loading