Skip to content

Commit

Permalink
Support cdep (#10921)
Browse files Browse the repository at this point in the history
Changes to bid adapter logic and tests to support passing `cdep` along in requests to Sharethrough's adserver endpoint.
  • Loading branch information
jefftmahoney authored Jan 10, 2024
1 parent 621cedc commit cdcfe15
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
9 changes: 6 additions & 3 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const sharethroughAdapterSpec = {
dnt: navigator.doNotTrack === '1' ? 1 : 0,
h: window.screen.height,
w: window.screen.width,
ext: {},
},
regs: {
coppa: config.getConfig('coppa') === true ? 1 : 0,
Expand All @@ -63,6 +64,10 @@ export const sharethroughAdapterSpec = {
test: 0,
};

if (bidderRequest.ortb2?.device?.ext?.cdep) {
req.device.ext['cdep'] = bidderRequest.ortb2.device.ext.cdep;
}

req.user = nullish(firstPartyData.user, {});
if (!req.user.ext) req.user.ext = {};
req.user.ext.eids = bidRequests[0].userIdAsEids || [];
Expand Down Expand Up @@ -220,9 +225,7 @@ export const sharethroughAdapterSpec = {
const shouldCookieSync =
syncOptions.pixelEnabled && deepAccess(serverResponses, '0.body.cookieSyncUrls') !== undefined;

return shouldCookieSync
? serverResponses[0].body.cookieSyncUrls.map((url) => ({ type: 'image', url: url }))
: [];
return shouldCookieSync ? serverResponses[0].body.cookieSyncUrls.map((url) => ({ type: 'image', url: url })) : [];
},

// Empty implementation for prebid core to be able to find it
Expand Down
37 changes: 37 additions & 0 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,43 @@ describe('sharethrough adapter spec', function () {
});
});

describe('cookie deprecation', () => {
it('should not add cdep if we do not get it in an impression request', () => {
const builtRequests = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id',
ortb2: {
device: {
ext: {
propThatIsNotCdep: 'value-we-dont-care-about',
},
},
},
});
const noCdep = builtRequests.every((builtRequest) => {
const ourCdepValue = builtRequest.data.device?.ext?.cdep;
return ourCdepValue === undefined;
});
expect(noCdep).to.be.true;
});

it('should add cdep if we DO get it in an impression request', () => {
const builtRequests = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id',
ortb2: {
device: {
ext: {
cdep: 'cdep-value',
},
},
},
});
const cdepPresent = builtRequests.every((builtRequest) => {
return builtRequest.data.device.ext.cdep === 'cdep-value';
});
expect(cdepPresent).to.be.true;
});
});

describe('first party data', () => {
const firstPartyData = {
site: {
Expand Down

0 comments on commit cdcfe15

Please sign in to comment.