Skip to content

Commit

Permalink
fixing SRA p_pos (prebid#4337)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertrmartinez authored and sa1omon committed Nov 28, 2019
1 parent 2e7cde2 commit fe73e5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,8 @@ export const spec = {
};

// add p_pos only if specified and valid
if (params.position === 'atf' || params.position === 'btf') {
data['p_pos'] = params.position;
}
// For SRA we need to explicitly put empty semi colons so AE treats it as empty, instead of copying the latter value
data['p_pos'] = (params.position === 'atf' || params.position === 'btf') ? params.position : '';

if ((bidRequest.userId || {}).tdid) {
data['tpid_tdid'] = bidRequest.userId.tdid;
Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,42 @@ describe('the rubicon adapter', function () {
expect(data['p_pos']).to.equal(undefined);
});

it('should correctly send p_pos in sra fashion', function() {
sandbox.stub(config, 'getConfig').callsFake((key) => {
const config = {
'rubicon.singleRequest': true
};
return config[key];
});
// first one is atf
var sraPosRequest = utils.deepClone(bidderRequest);

// second is not present
const bidCopy = utils.deepClone(sraPosRequest.bids[0]);
delete bidCopy.params.position;
sraPosRequest.bids.push(bidCopy);

// third is btf
const bidCopy1 = utils.deepClone(sraPosRequest.bids[0]);
bidCopy1.params.position = 'btf';
sraPosRequest.bids.push(bidCopy1);

// fourth is invalid (aka not atf or btf)
const bidCopy2 = utils.deepClone(sraPosRequest.bids[0]);
bidCopy2.params.position = 'unknown';
sraPosRequest.bids.push(bidCopy2);

// fifth is not present
const bidCopy3 = utils.deepClone(sraPosRequest.bids[0]);
delete bidCopy3.params.position;
sraPosRequest.bids.push(bidCopy3);

let [request] = spec.buildRequests(sraPosRequest.bids, sraPosRequest);
let data = parseQuery(request.data);

expect(data['p_pos']).to.equal('atf;;btf;;');
});

it('ad engine query params should be ordered correctly', function () {
sandbox.stub(Math, 'random').callsFake(() => 0.1);
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
Expand Down

0 comments on commit fe73e5d

Please sign in to comment.