Skip to content

Commit de82bae

Browse files
vrtcal-devUbuntu
and
Ubuntu
authored
VRTCAL Bid Adapter : updated user sync support (#10579)
* Updated User Sync Support * Simple var to let adjustment --------- Co-authored-by: Ubuntu <[email protected]>
1 parent 695da70 commit de82bae

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

modules/vrtcalBidAdapter.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { config } from '../src/config.js';
55
import {deepAccess, isFn, isPlainObject} from '../src/utils.js';
66

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

911
export const spec = {
1012
code: 'vrtcal',
@@ -148,7 +150,34 @@ export const spec = {
148150
);
149151
ajax(winUrl, null);
150152
return true;
153+
},
154+
155+
getUserSyncs: function(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '', gppConsent = {}) {
156+
const syncs = [];
157+
const gdprFlag = `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`;
158+
const gdprString = `&gdpr_consent=${encodeURIComponent((gdprConsent.consentString || ''))}`;
159+
const usPrivacy = `&us_privacy=${encodeURIComponent(uspConsent)}`;
160+
const gpp = gppConsent.gppString ? gppConsent.gppString : '';
161+
const gppSid = Array.isArray(gppConsent.applicableSections) ? gppConsent.applicableSections.join(',') : '';
162+
let vrtcalSyncURL = ''
163+
164+
if (syncOptions.iframeEnabled) {
165+
vrtcalSyncURL = `${VRTCAL_USER_SYNC_URL_IFRAME}${usPrivacy}${gdprFlag}${gdprString}&gpp=${gpp}&gpp_sid=${gppSid}&surl=`;
166+
syncs.push({
167+
type: 'iframe',
168+
url: vrtcalSyncURL
169+
});
170+
} else {
171+
vrtcalSyncURL = `${VRTCAL_USER_SYNC_URL_REDIRECT}${usPrivacy}${gdprFlag}${gdprString}&gpp=${gpp}&gpp_sid=${gppSid}&surl=`;
172+
syncs.push({
173+
type: 'image',
174+
url: vrtcalSyncURL
175+
});
176+
}
177+
178+
return syncs;
151179
}
180+
152181
};
153182

154183
registerBidder(spec);

test/spec/modules/vrtcalBidAdapter_spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,39 @@ describe('vrtcalBidAdapter', function () {
134134
).to.be.true
135135
})
136136
})
137+
138+
describe('getUserSyncs', function() {
139+
const syncurl_iframe = 'https://usync.vrtcal.com/i?ssp=1804&synctype=iframe';
140+
const syncurl_redirect = 'https://usync.vrtcal.com/i?ssp=1804&synctype=redirect';
141+
142+
it('base iframe sync pper config', function() {
143+
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{
144+
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
145+
}]);
146+
});
147+
148+
it('base redirect sync per config', function() {
149+
expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal([{
150+
type: 'image', url: syncurl_redirect + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
151+
}]);
152+
});
153+
154+
it('pass with ccpa data', function() {
155+
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, 'ccpa_consent_string', undefined)).to.deep.equal([{
156+
type: 'iframe', url: syncurl_iframe + '&us_privacy=ccpa_consent_string&gdpr=0&gdpr_consent=&gpp=&gpp_sid=&surl='
157+
}]);
158+
});
159+
160+
it('pass with gdpr data', function() {
161+
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: 1, consentString: 'gdpr_consent_string'}, undefined, undefined)).to.deep.equal([{
162+
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=1&gdpr_consent=gdpr_consent_string&gpp=&gpp_sid=&surl='
163+
}]);
164+
});
165+
166+
it('pass with gpp data', function() {
167+
expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined, {gppString: 'gpp_consent_string', applicableSections: [1, 5]})).to.deep.equal([{
168+
type: 'iframe', url: syncurl_iframe + '&us_privacy=&gdpr=0&gdpr_consent=&gpp=gpp_consent_string&gpp_sid=1,5&surl='
169+
}]);
170+
});
171+
})
137172
})

0 commit comments

Comments
 (0)