Skip to content

Commit

Permalink
appnexus bid adapter - initial support for pixel userSync
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker committed Sep 25, 2024
1 parent 1536afc commit 54a1bb6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 57 deletions.
16 changes: 10 additions & 6 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
}
}
};

Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/anPspParamsConverter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe('anPspParamsConverter', function () {

const testBidderRequests = deepClone(bidderRequests);

debugger; //eslint-disable-line
convertAnParams(function () {
didHookRun = true;
}, testBidderRequests);
Expand Down
119 changes: 69 additions & 50 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
});
});

0 comments on commit 54a1bb6

Please sign in to comment.