Skip to content

Commit

Permalink
VRTCAL Bid Adapter : updated user sync support (#10579)
Browse files Browse the repository at this point in the history
* Updated User Sync Support

* Simple var to let adjustment

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-25-92.us-west-1.compute.internal>
  • Loading branch information
vrtcal-dev and Ubuntu authored Oct 12, 2023
1 parent 695da70 commit de82bae
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/vrtcalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { config } from '../src/config.js';
import {deepAccess, isFn, isPlainObject} from '../src/utils.js';

const GVLID = 706;
const VRTCAL_USER_SYNC_URL_IFRAME = `https://usync.vrtcal.com/i?ssp=1804&synctype=iframe`;
const VRTCAL_USER_SYNC_URL_REDIRECT = `https://usync.vrtcal.com/i?ssp=1804&synctype=redirect`;

export const spec = {
code: 'vrtcal',
Expand Down Expand Up @@ -148,7 +150,34 @@ export const spec = {
);
ajax(winUrl, null);
return true;
},

getUserSyncs: function(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '', gppConsent = {}) {
const syncs = [];
const gdprFlag = `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`;
const gdprString = `&gdpr_consent=${encodeURIComponent((gdprConsent.consentString || ''))}`;
const usPrivacy = `&us_privacy=${encodeURIComponent(uspConsent)}`;
const gpp = gppConsent.gppString ? gppConsent.gppString : '';
const gppSid = Array.isArray(gppConsent.applicableSections) ? gppConsent.applicableSections.join(',') : '';
let vrtcalSyncURL = ''

if (syncOptions.iframeEnabled) {
vrtcalSyncURL = `${VRTCAL_USER_SYNC_URL_IFRAME}${usPrivacy}${gdprFlag}${gdprString}&gpp=${gpp}&gpp_sid=${gppSid}&surl=`;
syncs.push({
type: 'iframe',
url: vrtcalSyncURL
});
} else {
vrtcalSyncURL = `${VRTCAL_USER_SYNC_URL_REDIRECT}${usPrivacy}${gdprFlag}${gdprString}&gpp=${gpp}&gpp_sid=${gppSid}&surl=`;
syncs.push({
type: 'image',
url: vrtcalSyncURL
});
}

return syncs;
}

};

registerBidder(spec);
35 changes: 35 additions & 0 deletions test/spec/modules/vrtcalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,39 @@ describe('vrtcalBidAdapter', function () {
).to.be.true
})
})

describe('getUserSyncs', function() {
const syncurl_iframe = 'https://usync.vrtcal.com/i?ssp=1804&synctype=iframe';
const syncurl_redirect = 'https://usync.vrtcal.com/i?ssp=1804&synctype=redirect';

it('base iframe sync pper config', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
}]);
});

it('base redirect sync per config', function() {
expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal([{
type: 'image', url: syncurl_redirect + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
}]);
});

it('pass with ccpa data', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, 'ccpa_consent_string', undefined)).to.deep.equal([{
type: 'iframe', url: syncurl_iframe + '&us_privacy=ccpa_consent_string&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
}]);
});

it('pass with gdpr data', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: 1, consentString: 'gdpr_consent_string'}, undefined, undefined)).to.deep.equal([{
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=1&gdpr_consent=gdpr_consent_string&gpp=&gpp_sid=&surl='
}]);
});

it('pass with gpp data', function() {
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined, {gppString: 'gpp_consent_string', applicableSections: [1, 5]})).to.deep.equal([{
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=gpp_consent_string&gpp_sid=1,5&surl='
}]);
});
})
})

0 comments on commit de82bae

Please sign in to comment.