Skip to content

Apex 1538 change createiveid #2583

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

Merged
merged 5 commits into from
May 30, 2018
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
18 changes: 16 additions & 2 deletions modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var SonobiAdapter = function SonobiAdapter() {
var trinity = 'https://apex.go.sonobi.com/trinity.js?key_maker=';
var adSlots = request.bids || [];
var bidderRequestId = request.bidderRequestId;
var ref = '&ref=' + encodeURI(utils.getTopWindowLocation().host);
var ref = '&ref=' + _getReferrer(adSlots)
var libName = '&lib_name=prebid';
var libVersion = '&lib_v=$prebid.version$';
var vp = '&vp=' + _getPlatform();
Expand Down Expand Up @@ -94,6 +94,7 @@ var SonobiAdapter = function SonobiAdapter() {
}
goodBid.bidderCode = 'sonobi';
goodBid.ad = _creative(sbi_dc, bid.sbi_aid);
goodBid.creativeId = bid.sbi_crid || bid.aid;
goodBid.cpm = Number(bid.sbi_mouse);
goodBid.width = Number(bid.sbi_size.split('x')[0]) || 1;
goodBid.height = Number(bid.sbi_size.split('x')[1]) || 1;
Expand Down Expand Up @@ -141,6 +142,18 @@ var SonobiAdapter = function SonobiAdapter() {
return 'desktop';
}

function _getReferrer(bids) {
let ref = encodeURI(utils.getTopWindowLocation().host);
try {
if (bids[0].params.referrer) {
ref = bids[0].params.referrer
}
} catch (e) {
utils.logError(e)
}
return ref;
}

return {
callBids: _phone_in,
formRequest: _keymaker,
Expand All @@ -149,7 +162,8 @@ var SonobiAdapter = function SonobiAdapter() {
failure: _failure,
// export helper functions for testing purposes
_isInBounds: _isInBounds,
_getPlatform: _getPlatform
_getPlatform: _getPlatform,
_getReferrer: _getReferrer
};
};

Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/sonobiBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ describe('Sonobi adapter tests', () => {
{
'sbi_size': '300x250',
'sbi_apoc': 'premium',
'sbi_crid': 'abcd1234',
'sbi_aid': '159.60.7533347',
'sbi_mouse': 4.20
}
Expand Down Expand Up @@ -416,4 +417,23 @@ describe('Sonobi adapter tests', () => {
expect(adapter._getPlatform({innerWidth: 1000})).to.equal('desktop')
})
})
describe('_getReferrer', () => {
it('should return the referrer from the adunit params', () => {
const adapter = new Adapter();
const adunit = {
bidderCode: 'sonobi',
bids: [{
bidId: 'testbid',
bidder: 'sonobi',
placementCode: 'adUnit_p',
sizes: [[300, 250], [300, 600]],
params: {
placement_id: '1a2b3c4d5e6f1a2b3c4d',
referrer: 'test'
}
}]
};
expect(adapter._getReferrer(adunit.bids)).to.equal('test');
})
})
});