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 - initial support for image userSync #12271

Merged
merged 1 commit into from
Sep 27, 2024
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
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whopps

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - sorry about that. Finally caught it.

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;
});
});
});
});