Skip to content

Commit cc80fe3

Browse files
HolzAndrewjaiminpanchal27
authored andcommitted
support userId module (#3675)
* use unit id being sent instead of hard coded auid * make multiple requests * removes commented out code. adds aus param back * hardcodes vht, vwd, aus * arrays should have commas * adds aus check to test * updates md file with new sizes syntax * updates md file with new sizes syntax * adds note on md about size option * size updates * adds prebid consortium id
1 parent 876a714 commit cc80fe3

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

modules/yieldmoBidAdapter.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ export const spec = {
4040
w: localWindow.innerWidth,
4141
h: localWindow.innerHeight
4242
};
43+
4344
bidRequests.forEach((request) => {
4445
serverRequest.p.push(addPlacement(request));
46+
const userId = getUserId(request)
47+
if (userId) {
48+
const pubcid = userId.pubcid;
49+
serverRequest.pubcid = pubcid;
50+
} else {
51+
serverRequest.pubcid = request.crumbs.pubcid;
52+
}
4553
});
4654
serverRequest.p = '[' + serverRequest.p.toString() + ']';
4755
return {
@@ -302,3 +310,11 @@ function isSuperSandboxedIframe() {
302310
function isMraid() {
303311
return !!(window.mraid);
304312
}
313+
314+
function getUserId(request) {
315+
let userId;
316+
if (request && request.userId && typeof request.userId === 'object') {
317+
userId = request.userId;
318+
}
319+
return userId;
320+
}

test/spec/modules/yieldmoBidAdapter_spec.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ describe('YieldmoAdapter', function () {
1414
sizes: [[300, 250], [300, 600]],
1515
bidId: '30b31c1838de1e',
1616
bidderRequestId: '22edbae2733bf6',
17-
auctionId: '1d1a030790a475'
17+
auctionId: '1d1a030790a475',
18+
crumbs: {
19+
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da'
20+
}
1821
};
1922
let bidArray = [bid];
2023

@@ -58,7 +61,11 @@ describe('YieldmoAdapter', function () {
5861
sizes: [[300, 250], [300, 600]],
5962
bidId: '123456789',
6063
bidderRequestId: '987654321',
61-
auctionId: '0246810'
64+
auctionId: '0246810',
65+
crumbs: {
66+
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da'
67+
}
68+
6269
});
6370

6471
// multiple placements
@@ -91,6 +98,23 @@ describe('YieldmoAdapter', function () {
9198
expect(data.hasOwnProperty('h')).to.be.true;
9299
expect(data.hasOwnProperty('w')).to.be.true;
93100
})
101+
102+
it('should add pubcid as parameter of request', function () {
103+
const pubcidBid = {
104+
bidder: 'yieldmo',
105+
params: {},
106+
adUnitCode: 'adunit-code',
107+
sizes: [[300, 250], [300, 600]],
108+
bidId: '30b31c1838de1e',
109+
bidderRequestId: '22edbae2733bf6',
110+
auctionId: '1d1a030790a475',
111+
userId: {
112+
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2'
113+
}
114+
};
115+
const data = spec.buildRequests([pubcidBid]).data;
116+
expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2');
117+
})
94118
});
95119

96120
describe('interpretResponse', function () {

0 commit comments

Comments
 (0)