From 1be36c278670d9b4e9fa9437c2bcccf024fd4a79 Mon Sep 17 00:00:00 2001 From: Alex Khmelnitsky Date: Mon, 13 May 2019 15:27:07 +0300 Subject: [PATCH] Added iframe user sync support --- modules/cedatoBidAdapter.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/modules/cedatoBidAdapter.js b/modules/cedatoBidAdapter.js index 8c049410b3a..78bb7b45c7b 100644 --- a/modules/cedatoBidAdapter.js +++ b/modules/cedatoBidAdapter.js @@ -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;