From 498e7605d2874e421bd0f82a6438f3ead08c4b4d Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Mon, 11 Apr 2022 12:23:35 -0400 Subject: [PATCH] appnexus bid adapter - add support for setConfig pageUrl (#8266) --- modules/appnexusBidAdapter.js | 4 +++ test/spec/modules/appnexusBidAdapter_spec.js | 36 +++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 2758fc2d03a..cdbf3a2785e 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -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; } diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 11e92a1af2e..d978604e93f 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -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', @@ -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: {