Skip to content

Commit

Permalink
support userId module (#3675)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HolzAndrew authored and jaiminpanchal27 committed Mar 26, 2019
1 parent 876a714 commit cc80fe3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
16 changes: 16 additions & 0 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ export const spec = {
w: localWindow.innerWidth,
h: localWindow.innerHeight
};

bidRequests.forEach((request) => {
serverRequest.p.push(addPlacement(request));
const userId = getUserId(request)
if (userId) {
const pubcid = userId.pubcid;
serverRequest.pubcid = pubcid;
} else {
serverRequest.pubcid = request.crumbs.pubcid;
}
});
serverRequest.p = '[' + serverRequest.p.toString() + ']';
return {
Expand Down Expand Up @@ -302,3 +310,11 @@ function isSuperSandboxedIframe() {
function isMraid() {
return !!(window.mraid);
}

function getUserId(request) {
let userId;
if (request && request.userId && typeof request.userId === 'object') {
userId = request.userId;
}
return userId;
}
28 changes: 26 additions & 2 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ describe('YieldmoAdapter', function () {
sizes: [[300, 250], [300, 600]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475'
auctionId: '1d1a030790a475',
crumbs: {
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da'
}
};
let bidArray = [bid];

Expand Down Expand Up @@ -58,7 +61,11 @@ describe('YieldmoAdapter', function () {
sizes: [[300, 250], [300, 600]],
bidId: '123456789',
bidderRequestId: '987654321',
auctionId: '0246810'
auctionId: '0246810',
crumbs: {
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da'
}

});

// multiple placements
Expand Down Expand Up @@ -91,6 +98,23 @@ describe('YieldmoAdapter', function () {
expect(data.hasOwnProperty('h')).to.be.true;
expect(data.hasOwnProperty('w')).to.be.true;
})

it('should add pubcid as parameter of request', function () {
const pubcidBid = {
bidder: 'yieldmo',
params: {},
adUnitCode: 'adunit-code',
sizes: [[300, 250], [300, 600]],
bidId: '30b31c1838de1e',
bidderRequestId: '22edbae2733bf6',
auctionId: '1d1a030790a475',
userId: {
pubcid: 'c604130c-0144-4b63-9bf2-c2bd8c8d86da2'
}
};
const data = spec.buildRequests([pubcidBid]).data;
expect(data.pubcid).to.deep.equal('c604130c-0144-4b63-9bf2-c2bd8c8d86da2');
})
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit cc80fe3

Please sign in to comment.