Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Between Bid Adapter: add sharedid for Prebid 5.0 #7222

Merged
merged 4 commits into from
Aug 10, 2021
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
13 changes: 12 additions & 1 deletion modules/betweenBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { getAdUnitSizes, parseSizesInput } from '../src/utils.js';
import { getAdUnitSizes, parseSizesInput, deepAccess } from '../src/utils.js';
import { getRefererInfo } from '../src/refererDetection.js';

const BIDDER_CODE = 'between';
Expand Down Expand Up @@ -37,6 +37,8 @@ export const spec = {
tz: getTz(),
fl: getFl(),
rr: getRr(),
shid: getSharedId(i)('id'),
shid3: getSharedId(i)('third'),
s: i.params.s,
bidid: i.bidId,
transactionid: i.transactionId,
Expand Down Expand Up @@ -147,6 +149,15 @@ export const spec = {
}
}

function getSharedId(bid) {
const id = deepAccess(bid, 'userId.sharedid.id');
const third = deepAccess(bid, 'userId.sharedid.third');
return function(kind) {
if (kind === 'id') return id || '';
return third || '';
}
}

function getRr() {
try {
var td = top.document;
Expand Down
47 changes: 47 additions & 0 deletions test/spec/modules/betweenBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,53 @@ describe('betweenBidAdapterTests', function () {
expect(req_data.sizes).to.deep.equal(['970x250', '240x400', '728x90'])
});

it('check sharedId with id and third', function() {
const bidRequestData = [{
bidId: 'bid123',
bidder: 'between',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
s: 1112,
},
userId: {
sharedid: {
id: '01EXQE7JKNDRDDVATB0S2GX1NT',
third: '01EXQE7JKNDRDDVATB0S2GX1NT'
}
}
}];
const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid;
const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3;
expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT');
});

it('check sharedId with only id', function() {
const bidRequestData = [{
bidId: 'bid123',
bidder: 'between',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
s: 1112,
},
userId: {
sharedid: {
id: '01EXQE7JKNDRDDVATB0S2GX1NT',
}
}
}];
const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid;
const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3;
expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal('');
});

it('check adomain', function() {
const serverResponse = {
body: [{
Expand Down