From c979c6b54eae658d62fcc7ea8e89ff1bf75b695a Mon Sep 17 00:00:00 2001 From: dmytro-po Date: Fri, 29 Nov 2024 20:23:45 +0200 Subject: [PATCH] AGT-388: Add missed params and return old params --- .../intentIqConstants/intentIqConstants.js | 2 +- modules/intentIqAnalyticsAdapter.js | 65 ++++++++++++++----- modules/intentIqIdSystem.js | 16 +++++ 3 files changed, 64 insertions(+), 19 deletions(-) diff --git a/libraries/intentIqConstants/intentIqConstants.js b/libraries/intentIqConstants/intentIqConstants.js index af7f7722213..ed9856fc213 100644 --- a/libraries/intentIqConstants/intentIqConstants.js +++ b/libraries/intentIqConstants/intentIqConstants.js @@ -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 diff --git a/modules/intentIqAnalyticsAdapter.js b/modules/intentIqAnalyticsAdapter.js index 1779152c5f0..1cf270117b7 100644 --- a/modules/intentIqAnalyticsAdapter.js +++ b/modules/intentIqAnalyticsAdapter.js @@ -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}), { @@ -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 @@ -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); @@ -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; diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index c854b6c4746..4a7d0f47b18 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -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) { @@ -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; } @@ -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};