Skip to content

Commit

Permalink
AGT-388: Add missed params and return old params (#12524)
Browse files Browse the repository at this point in the history
Co-authored-by: dmytro-po <[email protected]>
  • Loading branch information
DimaIntentIQ and dmytro-po authored Dec 2, 2024
1 parent f7e8034 commit cafb7f7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libraries/intentIqConstants/intentIqConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ 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.23
export const VERSION = 0.24
65 changes: 47 additions & 18 deletions modules/intentIqAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const PARAMS_NAMES = {
isInBrowserBlacklist: 'inbbl',
prebidVersion: 'pbjsver',
partnerId: 'partnerId',
firstPartyId: 'pcid'
firstPartyId: 'pcid',
placementId: 'placementId'
};

let iiqAnalyticsAnalyticsAdapter = Object.assign(adapter({defaultUrl, analyticsType}), {
Expand Down Expand Up @@ -138,6 +139,10 @@ function initReadLsIds() {
iiqAnalyticsAnalyticsAdapter.initOptions.terminationCause = pData.terminationCause
iiqAnalyticsAnalyticsAdapter.initOptions.dataInLs = pData.data;
iiqAnalyticsAnalyticsAdapter.initOptions.eidl = pData.eidl || -1;
iiqAnalyticsAnalyticsAdapter.initOptions.ct = pData.ct || null;
iiqAnalyticsAnalyticsAdapter.initOptions.siteId = pData.siteId || null;
iiqAnalyticsAnalyticsAdapter.initOptions.wsrvcll = pData.wsrvcll || false;
iiqAnalyticsAnalyticsAdapter.initOptions.rrtt = pData.rrtt || null;
}

iiqAnalyticsAnalyticsAdapter.initOptions.clientsHints = clientsHints
Expand Down Expand Up @@ -198,13 +203,18 @@ export function preparePayload(data) {
result[PARAMS_NAMES.referrer] = getReferrer();
result[PARAMS_NAMES.terminationCause] = iiqAnalyticsAnalyticsAdapter.initOptions.terminationCause;
result[PARAMS_NAMES.abTestGroup] = iiqAnalyticsAnalyticsAdapter.initOptions.currentGroup;
result[PARAMS_NAMES.clientType] = iiqAnalyticsAnalyticsAdapter.initOptions.ct;
result[PARAMS_NAMES.siteId] = iiqAnalyticsAnalyticsAdapter.initOptions.siteId;
result[PARAMS_NAMES.wasServerCalled] = iiqAnalyticsAnalyticsAdapter.initOptions.wsrvcll;
result[PARAMS_NAMES.requestRtt] = iiqAnalyticsAnalyticsAdapter.initOptions.rrtt;

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)
if (iiqAnalyticsAnalyticsAdapter.initOptions.fpid?.pcid) result[PARAMS_NAMES.firstPartyId] = encodeURIComponent(iiqAnalyticsAnalyticsAdapter.initOptions.fpid.pcid);
if (iiqAnalyticsAnalyticsAdapter.initOptions.fpid?.pid) result[PARAMS_NAMES.profile] = encodeURIComponent(iiqAnalyticsAnalyticsAdapter.initOptions.fpid.pid)

fillPrebidEventData(data, result);
prepareData(data, result);

fillEidsData(result);

Expand All @@ -218,27 +228,46 @@ function fillEidsData(result) {
}
}

function fillPrebidEventData(eventData, result) {
if (eventData.bidderCode) {
result.bidderCode = eventData.bidderCode;
function prepareData (data, result) {
if (data.bidderCode) {
result.bidderCode = data.bidderCode;
}
if (eventData.cpm) {
result.cpm = eventData.cpm;
if (data.cpm) {
result.cpm = data.cpm;
}
if (eventData.currency) {
result.currency = eventData.currency;
if (data.currency) {
result.currency = data.currency;
}
if (eventData.originalCpm) {
result.originalCpm = eventData.originalCpm;
if (data.originalCpm) {
result.originalCpm = data.originalCpm;
}
if (eventData.originalCurrency) {
result.originalCurrency = eventData.originalCurrency;
if (data.originalCurrency) {
result.originalCurrency = data.originalCurrency;
}
if (eventData.status) {
result.status = eventData.status;
if (data.status) {
result.status = data.status;
}
if (eventData.auctionId) {
result.prebidAuctionId = eventData.auctionId;
if (data.auctionId) {
result.prebidAuctionId = data.auctionId;
}
if (data.placementId) {
result.placementId = data.placementId;
} else {
// Simplified placementId determination
let placeIdFound = false;
if (data.params && Array.isArray(data.params)) {
for (let i = 0; i < data.params.length; i++) {
const param = data.params[i];
if (param.placementId) {
result.placementId = param.placementId;
placeIdFound = true;
break;
}
}
}
if (!placeIdFound && data.adUnitCode) {
result.placementId = data.adUnitCode;
}
}

result.biddingPlatformId = 1;
Expand Down
16 changes: 16 additions & 0 deletions modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ export const intentIqIdSubmodule = {
const savedData = tryParse(readData(FIRST_PARTY_DATA_KEY, allowedStorage))
if (savedData) {
partnerData = savedData;

if (partnerData.wsrvcll) {
partnerData.wsrvcll = false;
storeData(FIRST_PARTY_DATA_KEY, JSON.stringify(partnerData), allowedStorage);
}
}

if (partnerData.data) {
Expand Down Expand Up @@ -434,6 +439,14 @@ export const intentIqIdSubmodule = {
partnerData.data = respJson.data;
}

if ('ct' in respJson) {
partnerData.ct = respJson.ct;
}

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

if (rrttStrtTime && rrttStrtTime > 0) {
partnerData.rrtt = Date.now() - rrttStrtTime;
}
Expand All @@ -459,7 +472,10 @@ export const intentIqIdSubmodule = {
callback(runtimeEids);
}
};
rrttStrtTime = Date.now();

partnerData.wsrvcll = true;
storeData(FIRST_PARTY_DATA_KEY, JSON.stringify(partnerData), allowedStorage);
ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true});
};
const respObj = {callback: resp};
Expand Down

0 comments on commit cafb7f7

Please sign in to comment.