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

Rubicon: Fix position on SRA requests #4337

Merged
merged 1 commit into from
Oct 22, 2019
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
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