Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions modules/boldwinBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ starts, whoever plays it. For banner and native it hands them to Prebid as event
Prebid fires `burl` when the bid becomes billable and native `nurl` when the bid wins. For
banners Prebid adds `nurl` to the markup as a pixel.

User sync is an image pixel. It carries the GDPR, US Privacy and GPP signals Prebid has, and
no sync is made when COPPA applies.
User sync is an iframe when the publisher allows iframe syncs, otherwise an image pixel; the
adapter returns one of them, never both. It carries the GDPR, US Privacy and GPP signals Prebid
has, and no sync is made when `pbjs.setConfig({ coppa: true })` is set.

# Bid Params

Expand Down
32 changes: 15 additions & 17 deletions modules/boldwinBidAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if (offered.includes(VIDEO) && (/^<\?xml|^<VAST/i.test(skipLeadingXmlComments(adm)) || (adm === '' && isStr(bid.nurl)))) return VIDEO;
if (offered.includes(NATIVE) && (adm.startsWith('{') || isPlainObject(bid.adm))) return NATIVE;
if (offered.includes(BANNER)) return BANNER;
return offered[0];

Check warning on line 62 in modules/boldwinBidAdapter.ts

View workflow job for this annotation

GitHub Actions / Coverage

62 line is not covered with tests
}

const converter = ortbConverter<typeof BIDDER_CODE>({
Expand Down Expand Up @@ -174,28 +174,26 @@
return bids;
},

// One sync per call: the iframe when the publisher allows it, otherwise the image pixel.
getUserSyncs(syncOptions, _serverResponses, gdprConsent, uspConsent, gppConsent, coppa) {
if (coppa || !syncOptions.pixelEnabled) {
if (coppa) {
return [];
}
const params = new URLSearchParams();
if (typeof gdprConsent?.gdprApplies === 'boolean') {
params.set('gdpr', gdprConsent.gdprApplies ? '1' : '0');
}
if (gdprConsent?.consentString) {
params.set('gdpr_consent', gdprConsent.consentString);
}
if (uspConsent) {
params.set('us_privacy', uspConsent);
}
if (gppConsent?.gppString) {
params.set('gpp', gppConsent.gppString);
const type = syncOptions.iframeEnabled ? 'iframe' : syncOptions.pixelEnabled ? 'image' : null;
if (!type) {
return [];
}
if (gppConsent?.applicableSections?.length) {
params.set('gpp_sid', gppConsent.applicableSections.join(','));
// Boldwin's sync endpoint expects every signal in the URL, with an empty value when it is unknown.
const params = new URLSearchParams();
if (type === 'iframe') {
params.set('type', 'iframe');
}
const query = params.toString();
return [{ type: 'image', url: query ? `${SYNC_URL}?${query}` : SYNC_URL }];
params.set('gdpr', typeof gdprConsent?.gdprApplies === 'boolean' ? (gdprConsent.gdprApplies ? '1' : '0') : '');
params.set('gdpr_consent', gdprConsent?.consentString || '');
params.set('us_privacy', uspConsent || '');
params.set('gpp', gppConsent?.gppString || '');
params.set('gpp_sid', gppConsent?.applicableSections?.join(',') || '');
return [{ type, url: `${SYNC_URL}?${params.toString()}` }];
},
};

Expand Down
41 changes: 24 additions & 17 deletions test/spec/modules/boldwinBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,36 +376,43 @@ describe('boldwin bid adapter', function () {

describe('getUserSyncs', function () {
const PIXEL = { iframeEnabled: false, pixelEnabled: true };
const IFRAME = { iframeEnabled: true, pixelEnabled: false };
const BOTH = { iframeEnabled: true, pixelEnabled: true };
const EMPTY_SIGNALS = 'gdpr=&gdpr_consent=&us_privacy=&gpp=&gpp_sid=';

it('returns one image pixel', function () {
expect(spec.getUserSyncs(PIXEL, [], null, null, null, false)).to.deep.equal([{ type: 'image', url: SYNC_URL }]);
it('returns one image pixel when only pixels are allowed', function () {
expect(spec.getUserSyncs(PIXEL, [], null, null, null, false)).to.deep.equal([{ type: 'image', url: `${SYNC_URL}?${EMPTY_SIGNALS}` }]);
});

it('returns no sync when pixels are disabled, even if iframes are allowed', function () {
expect(spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: false }, [], null, null, null, false)).to.deep.equal([]);
it('returns one iframe when iframes are allowed', function () {
const iframe = [{ type: 'iframe', url: `${SYNC_URL}?type=iframe&${EMPTY_SIGNALS}` }];
expect(spec.getUserSyncs(IFRAME, [], null, null, null, false)).to.deep.equal(iframe);
expect(spec.getUserSyncs(BOTH, [], null, null, null, false)).to.deep.equal(iframe);
});

it('returns no sync when neither iframes nor pixels are allowed', function () {
expect(spec.getUserSyncs({ iframeEnabled: false, pixelEnabled: false }, [], null, null, null, false)).to.deep.equal([]);
});

it('returns no sync under COPPA', function () {
expect(spec.getUserSyncs(PIXEL, [], null, '1YNN', null, true)).to.deep.equal([]);
expect(spec.getUserSyncs(BOTH, [], null, '1YNN', null, true)).to.deep.equal([]);
});

it('adds every privacy signal that is present, in the documented order', function () {
const gdprConsent = { gdprApplies: true, consentString: 'CONSENT' };
const gppConsent = { gppString: 'DBABTA~1YNN', applicableSections: [7, 8] };
expect(spec.getUserSyncs(PIXEL, [], gdprConsent, '1YNN', gppConsent, false)).to.deep.equal([{
type: 'image',
url: `${SYNC_URL}?gdpr=1&gdpr_consent=CONSENT&us_privacy=1YNN&gpp=DBABTA%7E1YNN&gpp_sid=7%2C8`,
}]);
});

it('sends gdpr=0 when GDPR does not apply and leaves gdpr out when unknown', function () {
expect(spec.getUserSyncs(PIXEL, [], { gdprApplies: false }, null, null, false)[0].url).to.equal(`${SYNC_URL}?gdpr=0`);
expect(spec.getUserSyncs(PIXEL, [], { consentString: 'CONSENT' }, null, null, false)[0].url).to.equal(`${SYNC_URL}?gdpr_consent=CONSENT`);
const query = 'gdpr=1&gdpr_consent=CONSENT&us_privacy=1YNN&gpp=DBABTA%7E1YNN&gpp_sid=7%2C8';
expect(spec.getUserSyncs(PIXEL, [], gdprConsent, '1YNN', gppConsent, false)[0].url).to.equal(`${SYNC_URL}?${query}`);
expect(spec.getUserSyncs(IFRAME, [], gdprConsent, '1YNN', gppConsent, false)[0].url).to.equal(`${SYNC_URL}?type=iframe&${query}`);
});

it('leaves out empty privacy signals', function () {
const gppConsent = { gppString: '', applicableSections: [] };
expect(spec.getUserSyncs(PIXEL, [], { consentString: '' }, '', gppConsent, false)).to.deep.equal([{ type: 'image', url: SYNC_URL }]);
it('sends gdpr=0 when GDPR does not apply and empty values for unknown signals', function () {
expect(spec.getUserSyncs(PIXEL, [], { gdprApplies: false }, null, null, false)[0].url)
.to.equal(`${SYNC_URL}?gdpr=0&gdpr_consent=&us_privacy=&gpp=&gpp_sid=`);
expect(spec.getUserSyncs(PIXEL, [], { consentString: 'CONSENT' }, '', { gppString: '', applicableSections: [] }, false)[0].url)
.to.equal(`${SYNC_URL}?gdpr=&gdpr_consent=CONSENT&us_privacy=&gpp=&gpp_sid=`);
expect(spec.getUserSyncs(PIXEL, [], null, null, { gppString: 'DBABTA~1YNN' }, false)[0].url)
.to.equal(`${SYNC_URL}?gdpr=&gdpr_consent=&us_privacy=&gpp=DBABTA%7E1YNN&gpp_sid=`);
});
});

Expand Down
Loading