From 54a1bb6254b55c89ed13e4b5c253b88157e4df3a Mon Sep 17 00:00:00 2001 From: Jason Snellbaker Date: Wed, 25 Sep 2024 10:06:37 -0400 Subject: [PATCH] appnexus bid adapter - initial support for pixel userSync --- modules/appnexusBidAdapter.js | 16 ++- .../spec/modules/anPspParamsConverter_spec.js | 1 - test/spec/modules/appnexusBidAdapter_spec.js | 119 ++++++++++-------- 3 files changed, 79 insertions(+), 57 deletions(-) diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 4935158d21c..0049d3a529c 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -452,17 +452,21 @@ export const spec = { }, getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { - function checkGppStatus(gppConsent) { - // user sync suppression for adapters is handled in activity controls and not needed in adapters - return true; - } - - if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent) && checkGppStatus(gppConsent)) { + if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent)) { return [{ type: 'iframe', url: 'https://acdn.adnxs.com/dmp/async_usersync.html' }]; } + + if (syncOptions.pixelEnabled) { + // first attempt using static list + const imgList = ['https://px.ads.linkedin.com/setuid?partner=appNexus']; + return imgList.map(url => ({ + type: 'image', + url + })); + } } }; diff --git a/test/spec/modules/anPspParamsConverter_spec.js b/test/spec/modules/anPspParamsConverter_spec.js index 0d01d0e78a9..a96730088b8 100644 --- a/test/spec/modules/anPspParamsConverter_spec.js +++ b/test/spec/modules/anPspParamsConverter_spec.js @@ -51,7 +51,6 @@ describe('anPspParamsConverter', function () { const testBidderRequests = deepClone(bidderRequests); - debugger; //eslint-disable-line convertAnParams(function () { didHookRun = true; }, testBidderRequests); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 7fca35249b8..114aa8f2a13 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -2186,54 +2186,73 @@ describe('AppNexusAdapter', function () { }); }); - // describe('transformBidParams', function () { - // let gcStub; - // let adUnit = { bids: [{ bidder: 'appnexus' }] }; ; - - // before(function () { - // gcStub = sinon.stub(config, 'getConfig'); - // }); - - // after(function () { - // gcStub.restore(); - // }); - - // it('convert keywords param differently for psp endpoint with single s2sConfig', function () { - // gcStub.withArgs('s2sConfig').returns({ - // bidders: ['appnexus'], - // endpoint: { - // p1Consent: 'https://ib.adnxs.com/openrtb2/prebid' - // } - // }); - - // const oldParams = { - // keywords: { - // genre: ['rock', 'pop'], - // pets: 'dog' - // } - // }; - - // const newParams = spec.transformBidParams(oldParams, true, adUnit); - // expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog'); - // }); - - // it('convert keywords param differently for psp endpoint with array s2sConfig', function () { - // gcStub.withArgs('s2sConfig').returns([{ - // bidders: ['appnexus'], - // endpoint: { - // p1Consent: 'https://ib.adnxs.com/openrtb2/prebid' - // } - // }]); - - // const oldParams = { - // keywords: { - // genre: ['rock', 'pop'], - // pets: 'dog' - // } - // }; - - // const newParams = spec.transformBidParams(oldParams, true, adUnit); - // expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog'); - // }); - // }); + describe('getUserSyncs', function() { + let syncOptions, gdprConsent; + + beforeEach(() => { + gdprConsent = { + gdprApplies: true, + consentString: 'CPJl4C8PJl4C8OoAAAENAwCMAP_AAH_AAAAAAPgAAAAIAPgAAAAIAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g', + vendorData: { + purpose: { + consents: { + '1': true + } + } + } + } + }); + + describe('pixel', function () { + beforeEach(() => { + syncOptions = { pixelEnabled: true }; + }); + + it('pixelEnabled on', function () { + const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null); + expect(result).to.have.length(1); + expect(result[0].type).to.equal('image'); + expect(result[0].url).to.equal('https://px.ads.linkedin.com/setuid?partner=appNexus'); + }); + + it('pixelEnabled off', function () { + syncOptions.pixelEnabled = false; + const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null); + expect(result).to.be.undefined; + }); + }); + + describe('iframe', function () { + beforeEach(() => { + syncOptions = { iframeEnabled: true }; + }); + + it('iframeEnabled on with gdpr purpose 1 on', function () { + const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null); + expect(result).to.have.length(1); + expect(result[0].type).to.equal('iframe'); + expect(result[0].url).to.equal('https://acdn.adnxs.com/dmp/async_usersync.html'); + }); + + it('iframeEnabled on with gdpr purpose1 off', function () { + gdprConsent.vendorData.purpose.consents['1'] = false + + const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null); + expect(result).to.be.undefined; + }); + + it('iframeEnabled on without gdpr', function () { + const result = spec.getUserSyncs(syncOptions, [], null, null); + expect(result).to.have.length(1); + expect(result[0].type).to.equal('iframe'); + expect(result[0].url).to.equal('https://acdn.adnxs.com/dmp/async_usersync.html'); + }); + + it('iframeEnabled off', function () { + syncOptions.iframeEnabled = false; + const result = spec.getUserSyncs(syncOptions, [], gdprConsent, null); + expect(result).to.be.undefined; + }); + }); + }); });