Skip to content

Commit

Permalink
Added iframe user sync support (prebid#3822)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkh13 authored and Alex committed Aug 1, 2019
1 parent b4483c4 commit 9002e69
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions modules/cedatoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,35 @@ export const spec = {
const syncs = [];
if (syncOptions.pixelEnabled) {
resps.forEach(() => {
const uuid = getUserID();
const syncUrl = SYNC_URL;
let params = '';
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
params += `?gdpr_consent=${gdprConsent.consentString}`;
}
}
syncs.push({
type: 'image',
url: syncUrl.replace('{UUID}', uuid) + params,
});
syncs.push(getSync('image', gdprConsent));
});
}
if (syncOptions.iframeEnabled) {
resps.forEach(() => {
syncs.push(getSync('iframe', gdprConsent));
});
}
return syncs;
}
}

const getSync = (type, gdprConsent) => {
const uuid = getUserID();
const syncUrl = SYNC_URL;
let params = '&type=' + type;
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
params += `&gdpr_consent=${gdprConsent.consentString}`;
}
}
return {
type: type,
url: syncUrl.replace('{UUID}', uuid) + params,
};
}

const getUserID = () => {
const cookieName = COOKIE_NAME;
const uuidLen = UUID_LEN;
Expand Down

0 comments on commit 9002e69

Please sign in to comment.