Skip to content
Merged
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
54 changes: 27 additions & 27 deletions modules/intentIqIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
* @requires module:modules/userId
*/

import {logError, isPlainObject, isStr, isNumber} from '../src/utils.js';
import {ajax} from '../src/ajax.js';
import {submodule} from '../src/hook.js'
import {detectBrowser} from '../libraries/intentIqUtils/detectBrowserUtils.js';
import {appendSPData} from '../libraries/intentIqUtils/urlUtils.js';
import { logError, isPlainObject, isStr, isNumber } from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { submodule } from '../src/hook.js'
import { detectBrowser } from '../libraries/intentIqUtils/detectBrowserUtils.js';
import { appendSPData } from '../libraries/intentIqUtils/urlUtils.js';
import { isCHSupported } from '../libraries/intentIqUtils/chUtils.js'
import {appendVrrefAndFui} from '../libraries/intentIqUtils/getRefferer.js';
import { appendVrrefAndFui } from '../libraries/intentIqUtils/getRefferer.js';
import { getCmpData } from '../libraries/intentIqUtils/getCmpData.js';
import {readData, storeData, defineStorageType, removeDataByKey, tryParse} from '../libraries/intentIqUtils/storageUtils.js';
import { readData, storeData, defineStorageType, removeDataByKey, tryParse } from '../libraries/intentIqUtils/storageUtils.js';
import {
FIRST_PARTY_KEY,
CLIENT_HINTS_KEY,
Expand All @@ -22,8 +22,8 @@ import {
VERSION, INVALID_ID, SYNC_REFRESH_MILL, META_DATA_CONSTANT, PREBID,
HOURS_24, CH_KEYS
} from '../libraries/intentIqConstants/intentIqConstants.js';
import {SYNC_KEY} from '../libraries/intentIqUtils/getSyncKey.js';
import {iiqPixelServerAddress, getIiqServerAddress} from '../libraries/intentIqUtils/intentIqConfig.js';
import { SYNC_KEY } from '../libraries/intentIqUtils/getSyncKey.js';
import { iiqPixelServerAddress, getIiqServerAddress } from '../libraries/intentIqUtils/intentIqConfig.js';
import { handleAdditionalParams } from '../libraries/intentIqUtils/handleAdditionalParams.js';
import { decryptData, encryptData } from '../libraries/intentIqUtils/cryptionUtils.js';
import { defineABTestingGroup } from '../libraries/intentIqUtils/defineABTestingGroupUtils.js';
Expand Down Expand Up @@ -81,7 +81,7 @@ function addUniquenessToUrl(url) {
return url;
}

function appendFirstPartyData (url, firstPartyData, partnerData) {
function appendFirstPartyData(url, firstPartyData, partnerData) {
url += firstPartyData.pid ? '&pid=' + encodeURIComponent(firstPartyData.pid) : '';
url += firstPartyData.pcid ? '&iiqidtype=2&iiqpcid=' + encodeURIComponent(firstPartyData.pcid) : '';
url += firstPartyData.pcidDate ? '&iiqpciddate=' + encodeURIComponent(firstPartyData.pcidDate) : '';
Expand All @@ -93,7 +93,7 @@ function verifyIdType(value) {
return -1;
}

function appendPartnersFirstParty (url, configParams) {
function appendPartnersFirstParty(url, configParams) {
const partnerClientId = typeof configParams.partnerClientId === 'string' ? encodeURIComponent(configParams.partnerClientId) : '';
const partnerClientIdType = typeof configParams.partnerClientIdType === 'number' ? verifyIdType(configParams.partnerClientIdType) : -1;

Expand All @@ -105,7 +105,7 @@ function appendPartnersFirstParty (url, configParams) {
return url;
}

function appendCMPData (url, cmpData) {
function appendCMPData(url, cmpData) {
url += cmpData.uspString ? '&us_privacy=' + encodeURIComponent(cmpData.uspString) : '';
url += cmpData.gppString ? '&gpp=' + encodeURIComponent(cmpData.gppString) : '';
url += cmpData.gdprApplies
Expand All @@ -114,7 +114,7 @@ function appendCMPData (url, cmpData) {
return url
}

function appendCounters (url) {
function appendCounters(url) {
url += '&jaesc=' + encodeURIComponent(callCount);
url += '&jafc=' + encodeURIComponent(failCount);
url += '&jaensc=' + encodeURIComponent(noDataCount);
Expand Down Expand Up @@ -146,7 +146,7 @@ function addMetaData(url, data) {
return url + '&fbp=' + data;
}

export function initializeGlobalIIQ (partnerId) {
export function initializeGlobalIIQ(partnerId) {
if (!globalName || !window[globalName]) {
globalName = `iiq_identity_${partnerId}`
window[globalName] = {}
Expand Down Expand Up @@ -184,7 +184,7 @@ function sendSyncRequest(allowedStorage, url, partner, firstPartyData, newUser)
const needToDoSync = (Date.now() - (firstPartyData?.date || firstPartyData?.sCal || Date.now())) > SYNC_REFRESH_MILL
if (newUser || needToDoSync) {
ajax(url, () => {
}, undefined, {method: 'GET', withCredentials: true});
}, undefined, { method: 'GET', withCredentials: true });
if (firstPartyData?.date) {
firstPartyData.date = Date.now()
storeData(FIRST_PARTY_KEY_FINAL, JSON.stringify(firstPartyData), allowedStorage, firstPartyData);
Expand All @@ -193,7 +193,7 @@ function sendSyncRequest(allowedStorage, url, partner, firstPartyData, newUser)
} else if (!lastSyncDate || lastSyncElapsedTime > SYNC_REFRESH_MILL) {
storeData(SYNC_KEY(partner), Date.now() + '', allowedStorage);
ajax(url, () => {
}, undefined, {method: 'GET', withCredentials: true});
}, undefined, { method: 'GET', withCredentials: true });
}
}

Expand Down Expand Up @@ -285,7 +285,7 @@ export const intentIqIdSubmodule = {
* @returns {{intentIqId: {string}}|undefined}
*/
decode(value) {
return value && INVALID_ID !== value ? {'intentIqId': value} : undefined;
return value && INVALID_ID !== value ? { 'intentIqId': value } : undefined;
},

/**
Expand Down Expand Up @@ -431,7 +431,7 @@ export const intentIqIdSubmodule = {
}
}

function updateGlobalObj () {
function updateGlobalObj() {
if (globalName) {
window[globalName].partnerData = partnerData
window[globalName].firstPartyData = firstPartyData
Expand All @@ -442,8 +442,8 @@ export const intentIqIdSubmodule = {

let hasPartnerData = !!Object.keys(partnerData).length;
if (!isCMPStringTheSame(firstPartyData, cmpData) ||
!firstPartyData.sCal ||
(hasPartnerData && (!partnerData.cttl || !partnerData.date || Date.now() - partnerData.date > partnerData.cttl))) {
!firstPartyData.sCal ||
(hasPartnerData && (!partnerData.cttl || !partnerData.date || Date.now() - partnerData.date > partnerData.cttl))) {
firstPartyData.uspString = cmpData.uspString;
firstPartyData.gppString = cmpData.gppString;
firstPartyData.gdprString = cmpData.gdprString;
Expand Down Expand Up @@ -528,6 +528,9 @@ export const intentIqIdSubmodule = {
const resp = function (callback) {
const callbacks = {
success: response => {
if (rrttStrtTime && rrttStrtTime > 0) {
partnerData.rrtt = Date.now() - rrttStrtTime;
}
const respJson = tryParse(response);
// If response is a valid json and should save is true
if (respJson) {
Expand Down Expand Up @@ -588,7 +591,7 @@ export const intentIqIdSubmodule = {
} else {
// If data is a single string, assume it is an id with source intentiq.com
if (respJson.data && typeof respJson.data === 'string') {
respJson.data = {eids: [respJson.data]}
respJson.data = { eids: [respJson.data] }
}
}
partnerData.data = respJson.data;
Expand Down Expand Up @@ -620,10 +623,6 @@ export const intentIqIdSubmodule = {
delete partnerData.gpr // remove prediction flag in case server doesn't provide it
}

if (rrttStrtTime && rrttStrtTime > 0) {
partnerData.rrtt = Date.now() - rrttStrtTime;
}

if (respJson.data?.eids) {
runtimeEids = respJson.data
callback(respJson.data.eids);
Expand All @@ -648,12 +647,13 @@ export const intentIqIdSubmodule = {
callback(runtimeEids);
}
};
rrttStrtTime = Date.now();

partnerData.wsrvcll = true;
storeData(PARTNER_DATA_KEY, JSON.stringify(partnerData), allowedStorage, firstPartyData);
clearCountersAndStore(allowedStorage, partnerData);

rrttStrtTime = Date.now();

const sendAjax = uh => {
if (uh) url += '&uh=' + encodeURIComponent(uh);
ajax(url, callbacks, undefined, { method: 'GET', withCredentials: true });
Expand All @@ -675,7 +675,7 @@ export const intentIqIdSubmodule = {
sendAjax('');
}
};
const respObj = {callback: resp};
const respObj = { callback: resp };

if (runtimeEids?.eids?.length) respObj.id = runtimeEids.eids;
return respObj
Expand Down
Loading