Skip to content

Commit

Permalink
Undertone Bid Adapter : added GPP and video placements (#10016)
Browse files Browse the repository at this point in the history
* * Update undertone adapter - change parameters - placementId parameter is now optional and not mandatory - undertoneBidAdapter.js

* Updated undertone bid adapter tests accordingly - undertoneBidAdapter_spec.js

* * Update undertone adapter - change parameters - placementId parameter is now optional and not mandatory - undertoneBidAdapter.js

 * Updated undertone bid adapter tests accordingly - undertoneBidAdapter_spec.js

* fix lint issue in undertone adapter spec

* added user sync function to undertone adapter

* * Update undertone adapter - change parameters - placementId parameter is now optional and not mandatory - undertoneBidAdapter.js

* Updated undertone bid adapter tests accordingly - undertoneBidAdapter_spec.js

* added user sync function to undertone adapter

* added user sync function to undertone adapter

* revert package-lock.json

* added user sync function to undertone adapter

* Update undertoneBidAdapter.js

* Update browsers.json

* Undertone: added GPP support and video plcmt

* Fix lint issues

---------

Co-authored-by: omerko <omer.koren@perion.com>
Co-authored-by: Omer Koren <omerko@users.noreply.github.com>
Co-authored-by: AnnaPerion <annat@perion.com>
Co-authored-by: Oran Hollaender <oran@perion.com>
Co-authored-by: tamirnPerion <44399211+tamirnPerion@users.noreply.github.com>
Co-authored-by: tamarm <tamarm@perion.com>
Co-authored-by: tamarm <40788385+tamarm-perion@users.noreply.github.com>
  • Loading branch information
8 people authored Jun 1, 2023
1 parent d0c1d08 commit 992f129
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
10 changes: 9 additions & 1 deletion modules/undertoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export const spec = {
reqUrl += `&ccpa=${bidderRequest.uspConsent}`;
}

if (bidderRequest.gppConsent) {
const gppString = bidderRequest.gppConsent.gppString ?? '';
const ggpSid = bidderRequest.gppConsent.applicableSections ?? '';
reqUrl += `&gpp=${gppString}&gpp_sid=${ggpSid}`;
}

validBidRequests.map(bidReq => {
const bid = {
bidRequestId: bidReq.bidId,
Expand All @@ -146,7 +152,9 @@ export const spec = {
streamType: deepAccess(bidReq, 'mediaTypes.video.context') || null,
playbackMethod: deepAccess(bidReq, 'params.video.playbackMethod') || null,
maxDuration: deepAccess(bidReq, 'params.video.maxDuration') || null,
skippable: deepAccess(bidReq, 'params.video.skippable') || null
skippable: deepAccess(bidReq, 'params.video.skippable') || null,
placement: deepAccess(bidReq, 'mediaTypes.video.placement') || null,
plcmt: deepAccess(bidReq, 'mediaTypes.video.plcmt') || null
};
}
payload['x-ut-hb-params'].push(bid);
Expand Down
58 changes: 57 additions & 1 deletion test/spec/modules/undertoneBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const videoBidReq = [{
},
mediaTypes: {video: {
context: 'outstream',
playerSize: [640, 480]
playerSize: [640, 480],
placement: 1,
plcmt: 1
}},
sizes: [[300, 250], [300, 600]],
bidId: '263be71e91dd9d',
Expand Down Expand Up @@ -184,6 +186,31 @@ const bidderReqCcpaAndGdpr = {
uspConsent: 'NY12'
};

const bidderReqGpp = {
refererInfo: {
topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html'
},
gppConsent: {
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
applicableSections: [7]
}
};

const bidderReqFullGppCcpaGdpr = {
refererInfo: {
topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html'
},
gppConsent: {
gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN',
applicableSections: [7]
},
gdprConsent: {
gdprApplies: true,
consentString: 'gdprConsent'
},
uspConsent: '1YNN'
};

const validBidRes = {
ad: '<div>Hello</div>',
publisherId: 12345,
Expand Down Expand Up @@ -381,6 +408,31 @@ describe('Undertone Adapter', () => {
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it(`should have gppConsent fields`, function () {
const request = spec.buildRequests(bidReq, bidderReqGpp);
const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//');
const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2);
const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd);
const gppStr = bidderReqGpp.gppConsent.gppString;
const gppSid = bidderReqGpp.gppConsent.applicableSections;
const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gpp=${gppStr}&gpp_sid=${gppSid}`;
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it(`should have gpp, ccpa and gdpr fields`, function () {
const request = spec.buildRequests(bidReq, bidderReqFullGppCcpaGdpr);
const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//');
const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2);
const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd);
const gppStr = bidderReqFullGppCcpaGdpr.gppConsent.gppString;
const gppSid = bidderReqFullGppCcpaGdpr.gppConsent.applicableSections;
const ccpa = bidderReqFullGppCcpaGdpr.uspConsent;
const gdpr = bidderReqFullGppCcpaGdpr.gdprConsent.gdprApplies ? 1 : 0;
const gdprStr = bidderReqFullGppCcpaGdpr.gdprConsent.consentString;
const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gdpr=${gdpr}&gdprstr=${gdprStr}&ccpa=${ccpa}&gpp=${gppStr}&gpp_sid=${gppSid}`;
expect(request.url).to.equal(REQ_URL);
expect(request.method).to.equal('POST');
});
it('should have all relevant fields', function () {
const request = spec.buildRequests(bidReq, bidderReq);
const bid1 = JSON.parse(request.data)['x-ut-hb-params'][0];
Expand Down Expand Up @@ -409,10 +461,14 @@ describe('Undertone Adapter', () => {
expect(bidVideo.video.playbackMethod).to.equal(2);
expect(bidVideo.video.maxDuration).to.equal(30);
expect(bidVideo.video.skippable).to.equal(true);
expect(bidVideo.video.placement).to.equal(1);
expect(bidVideo.video.plcmt).to.equal(1);

expect(bidVideo2.video.skippable).to.equal(null);
expect(bidVideo2.video.maxDuration).to.equal(null);
expect(bidVideo2.video.playbackMethod).to.equal(null);
expect(bidVideo2.video.placement).to.equal(null);
expect(bidVideo2.video.plcmt).to.equal(null);
});
it('should send all userIds data to server', function () {
const request = spec.buildRequests(bidReqUserIds, bidderReq);
Expand Down

0 comments on commit 992f129

Please sign in to comment.