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

IntentIq Analytics Adapter: add pcid value to the payload #12169

Merged
merged 2 commits into from
Aug 23, 2024
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
6 changes: 4 additions & 2 deletions modules/intentIqAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const REPORTER_ID = Date.now() + '_' + getRandom(0, 1000);

const FIRST_PARTY_KEY = '_iiq_fdata';
const FIRST_PARTY_DATA_KEY = '_iiq_fdata';
const JSVERSION = 0.1
const JSVERSION = 0.2

const PARAMS_NAMES = {
abTestGroup: 'abGroup',
Expand Down Expand Up @@ -50,7 +50,8 @@ const PARAMS_NAMES = {
referrer: 'vrref',
isInBrowserBlacklist: 'inbbl',
prebidVersion: 'pbjsver',
partnerId: 'partnerId'
partnerId: 'partnerId',
firstPartyId: 'pcid'
};

let iiqAnalyticsAnalyticsAdapter = Object.assign(adapter({ defaultUrl, analyticsType }), {
Expand Down Expand Up @@ -157,6 +158,7 @@ export function preparePayload(data) {
result[PARAMS_NAMES.isInTestGroup] = iiqAnalyticsAnalyticsAdapter.initOptions.currentGroup == 'A';

result[PARAMS_NAMES.agentId] = REPORTER_ID;
if (iiqAnalyticsAnalyticsAdapter.initOptions.fpid?.pcid) result[PARAMS_NAMES.firstPartyId] = encodeURIComponent(iiqAnalyticsAnalyticsAdapter.initOptions.fpid.pcid)

fillPrebidEventData(data, result);

Expand Down
6 changes: 5 additions & 1 deletion modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const OPT_OUT = 'O';
export const BLACK_LIST = 'L';
export const CLIENT_HINTS_KEY = '_iiq_ch';
export const EMPTY = 'EMPTY'
export const VERSION = 0.1
export const VERSION = 0.2

const encoderCH = {
brands: 0,
Expand Down Expand Up @@ -223,6 +223,10 @@ export function detectBrowserFromUserAgent(userAgent) {

return 'unknown';
}
/**
* @typedef {Object} NavigatorUAData
* @property {Array<{brand: string, version: string}>} brands - The list of brands associated with the user agent.
*/

/**
* Detects the browser from the NavigatorUAData object
Expand Down
13 changes: 8 additions & 5 deletions test/spec/modules/intentIqAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { REPORTER_ID, getReferrer, preparePayload } from '../../../modules/inten

const partner = 10;
const defaultData = '{"pcid":"f961ffb1-a0e1-4696-a9d2-a21d815bd344", "group": "A"}';
const version = 0.2;

const storage = getStorageManager({ moduleType: 'analytics', moduleName: 'iiqAnalytics' });

Expand Down Expand Up @@ -111,7 +112,7 @@ describe('IntentIQ tests all', function () {
expect(server.requests.length).to.be.above(0);
const request = server.requests[0];
expect(request.url).to.contain('https://reports.intentiq.com/report?pid=' + partner + '&mct=1');
expect(request.url).to.contain('&jsver=0.1&vrref=http://localhost:9876/');
expect(request.url).to.contain(`&jsver=${version}&vrref=http://localhost:9876/`);
expect(request.url).to.contain('&payload=');
expect(request.url).to.contain('iiqid=f961ffb1-a0e1-4696-a9d2-a21d815bd344');
});
Expand All @@ -128,23 +129,25 @@ describe('IntentIQ tests all', function () {
expect(server.requests.length).to.be.above(0);
const request = server.requests[0];
expect(request.url).to.contain('https://reports.intentiq.com/report?pid=' + partner + '&mct=1');
expect(request.url).to.contain('&jsver=0.1&vrref=http://localhost:9876/');
expect(request.url).to.contain(`&jsver=${version}&vrref=http://localhost:9876/`);
expect(request.url).to.contain('iiqid=testpcid');
});

it('should handle BID_WON event with default group configuration', function () {
localStorage.setItem(FIRST_PARTY_KEY, defaultData);
const defaultDataObj = JSON.parse(defaultData)

events.emit(EVENTS.BID_WON, wonRequest);

expect(server.requests.length).to.be.above(0);
const request = server.requests[0];
const data = preparePayload(wonRequest);
const base64String = btoa(JSON.stringify(data));
const dataToSend = preparePayload(wonRequest);
const base64String = btoa(JSON.stringify(dataToSend));
const payload = `[%22${base64String}%22]`;
expect(request.url).to.equal(
`https://reports.intentiq.com/report?pid=${partner}&mct=1&iiqid=f961ffb1-a0e1-4696-a9d2-a21d815bd344&agid=${REPORTER_ID}&jsver=0.1&vrref=${getReferrer()}&source=pbjs&payload=${payload}`
`https://reports.intentiq.com/report?pid=${partner}&mct=1&iiqid=${defaultDataObj.pcid}&agid=${REPORTER_ID}&jsver=${version}&vrref=${getReferrer()}&source=pbjs&payload=${payload}`
);
expect(dataToSend.pcid).to.equal(defaultDataObj.pcid)
});

it('should not send request if manualReport is true', function () {
Expand Down