Skip to content

Commit

Permalink
appnexus bid adapter - add support for setConfig pageUrl (#8266)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored Apr 11, 2022
1 parent 81bf1a9 commit 498e760
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ export const spec = {
rd_ifs: bidderRequest.refererInfo.numIframes,
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',')
}
let pubPageUrl = config.getConfig('pageUrl');
if (isStr(pubPageUrl) && pubPageUrl !== '') {
refererinfo.rd_can = pubPageUrl;
}
payload.referrer_detection = refererinfo;
}

Expand Down
36 changes: 35 additions & 1 deletion test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ describe('AppNexusAdapter', function () {
});

it('should add referer info to payload', function () {
const bidRequest = Object.assign({}, bidRequests[0])
const bidRequest = Object.assign({}, bidRequests[0]);
const bidderRequest = {
refererInfo: {
referer: 'https://example.com/page.html',
Expand All @@ -844,6 +844,40 @@ describe('AppNexusAdapter', function () {
});
});

it('if defined, should include publisher pageUrl to normal referer info in payload', function () {
const bidRequest = Object.assign({}, bidRequests[0]);
sinon
.stub(config, 'getConfig')
.withArgs('pageUrl')
.returns('https://mypub.override.com/test/page.html');

const bidderRequest = {
refererInfo: {
referer: 'https://example.com/page.html',
reachedTop: true,
numIframes: 2,
stack: [
'https://example.com/page.html',
'https://example.com/iframe1.html',
'https://example.com/iframe2.html'
]
}
}
const request = spec.buildRequests([bidRequest], bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.referrer_detection).to.exist;
expect(payload.referrer_detection).to.deep.equal({
rd_ref: 'https%3A%2F%2Fexample.com%2Fpage.html',
rd_top: true,
rd_ifs: 2,
rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(','),
rd_can: 'https://mypub.override.com/test/page.html'
});

config.getConfig.restore();
});

it('should populate schain if available', function () {
const bidRequest = Object.assign({}, bidRequests[0], {
schain: {
Expand Down

0 comments on commit 498e760

Please sign in to comment.