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

Appnexus Bid Adapter : add support for setConfig pageUrl #8266

Merged
merged 1 commit into from
Apr 11, 2022
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
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