Skip to content

Commit 9002e69

Browse files
alexkh13Alex
authored and
Alex
committed
Added iframe user sync support (prebid#3822)
1 parent b4483c4 commit 9002e69

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

modules/cedatoBidAdapter.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,35 @@ export const spec = {
109109
const syncs = [];
110110
if (syncOptions.pixelEnabled) {
111111
resps.forEach(() => {
112-
const uuid = getUserID();
113-
const syncUrl = SYNC_URL;
114-
let params = '';
115-
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
116-
if (typeof gdprConsent.gdprApplies === 'boolean') {
117-
params += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
118-
} else {
119-
params += `?gdpr_consent=${gdprConsent.consentString}`;
120-
}
121-
}
122-
syncs.push({
123-
type: 'image',
124-
url: syncUrl.replace('{UUID}', uuid) + params,
125-
});
112+
syncs.push(getSync('image', gdprConsent));
113+
});
114+
}
115+
if (syncOptions.iframeEnabled) {
116+
resps.forEach(() => {
117+
syncs.push(getSync('iframe', gdprConsent));
126118
});
127119
}
128120
return syncs;
129121
}
130122
}
131123

124+
const getSync = (type, gdprConsent) => {
125+
const uuid = getUserID();
126+
const syncUrl = SYNC_URL;
127+
let params = '&type=' + type;
128+
if (gdprConsent && typeof gdprConsent.consentString === 'string') {
129+
if (typeof gdprConsent.gdprApplies === 'boolean') {
130+
params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
131+
} else {
132+
params += `&gdpr_consent=${gdprConsent.consentString}`;
133+
}
134+
}
135+
return {
136+
type: type,
137+
url: syncUrl.replace('{UUID}', uuid) + params,
138+
};
139+
}
140+
132141
const getUserID = () => {
133142
const cookieName = COOKIE_NAME;
134143
const uuidLen = UUID_LEN;

0 commit comments

Comments
 (0)