Skip to content

Commit

Permalink
Revert "Vidazoo Adapter: refactor/user-sync (prebid#5654)"
Browse files Browse the repository at this point in the history
This reverts commit 971d29f.
  • Loading branch information
BrightMountainMedia authored Sep 14, 2020
1 parent f852eb0 commit 783fa60
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
45 changes: 34 additions & 11 deletions modules/vidazooBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const TTL_SECONDS = 60 * 5;
const DEAL_ID_EXPIRY = 1000 * 60 * 15;
const UNIQUE_DEAL_ID_EXPIRY = 1000 * 60 * 15;
const SESSION_ID_KEY = 'vidSid';
const INTERNAL_SYNC_TYPE = {
IFRAME: 'iframe',
IMAGE: 'img'
};
const EXTERNAL_SYNC_TYPE = {
IFRAME: 'iframe',
IMAGE: 'image'
};
export const SUPPORTED_ID_SYSTEMS = {
'britepoolid': 1,
'criteoId': 1,
Expand Down Expand Up @@ -168,24 +176,39 @@ function interpretResponse(serverResponse, request) {
}
}

function getUserSyncs(syncOptions, responses, gdprConsent = {}, uspConsent = '') {
let syncs = [];
function getUserSyncs(syncOptions, responses) {
const { iframeEnabled, pixelEnabled } = syncOptions;
const { gdprApplies, consentString = '' } = gdprConsent;
const params = `?gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${encodeURIComponent(consentString || '')}&us_privacy=${encodeURIComponent(uspConsent || '')}`

if (iframeEnabled) {
syncs.push({
return [{
type: 'iframe',
url: `https://prebid.cootlogix.com/api/sync/iframe/${params}`
});
url: 'https://static.cootlogix.com/basev/sync/user_sync.html'
}];
}

if (pixelEnabled) {
syncs.push({
type: 'image',
url: `https://prebid.cootlogix.com/api/sync/image/${params}`
const lookup = {};
const syncs = [];
responses.forEach(response => {
const { body } = response;
const results = body ? body.results || [] : [];
results.forEach(result => {
(result.cookies || []).forEach(cookie => {
if (cookie.type === INTERNAL_SYNC_TYPE.IMAGE) {
if (pixelEnabled && !lookup[cookie.src]) {
syncs.push({
type: EXTERNAL_SYNC_TYPE.IMAGE,
url: cookie.src
});
}
}
});
});
});
return syncs;
}
return syncs;

return [];
}

export function hashCode(s, prefix = '_') {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/vidazooBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ describe('VidazooBidAdapter', function () {

expect(result).to.deep.equal([{
type: 'iframe',
url: 'https://prebid.cootlogix.com/api/sync/iframe/?gdpr=0&gdpr_consent=&us_privacy='
url: 'https://static.cootlogix.com/basev/sync/user_sync.html'
}]);
});

it('should have valid user sync with pixelEnabled', function () {
const result = adapter.getUserSyncs({ pixelEnabled: true }, [SERVER_RESPONSE]);

expect(result).to.deep.equal([{
'url': 'https://prebid.cootlogix.com/api/sync/image/?gdpr=0&gdpr_consent=&us_privacy=',
'url': 'https://sync.com',
'type': 'image'
}]);
})
Expand Down

0 comments on commit 783fa60

Please sign in to comment.