Skip to content

Commit

Permalink
Sharethrough Bid Adapter: revise getUserSyncs method (#10556)
Browse files Browse the repository at this point in the history
* Update sharethroughBidAdapter.js

* Removing GDPR and GPP query-string params from userSync url creation as our ad-server team gets this info from the bid request sent earlier.

* Update Sharethrough bid adapter and spec

* Further updating `sharethroughBidAdapter.js` to remove now-unneeded params from `getUserSyncs()` method.
* Updating spec file to remove no-longer-necc tests for query params in getUserSync url.
  • Loading branch information
jefftmahoney authored Oct 2, 2023
1 parent c4b0aff commit 5a1ebad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 40 deletions.
21 changes: 4 additions & 17 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,26 +216,13 @@ export const sharethroughAdapterSpec = {
});
},

getUserSyncs: (syncOptions, serverResponses, gdprConsent, gppConsent) => {
getUserSyncs: (syncOptions, serverResponses) => {
const shouldCookieSync =
syncOptions.pixelEnabled && deepAccess(serverResponses, '0.body.cookieSyncUrls') !== undefined;

let syncurl = '';

// Attaching GDPR Consent Params in UserSync url
if (gdprConsent) {
syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0);
syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '');
}
if (gppConsent) {
syncurl += '&gpp=' + encodeURIComponent(gppConsent?.gppString);
syncurl += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(','));
}

return shouldCookieSync ? serverResponses[0].body.cookieSyncUrls.map((url) => (
{ type: 'image',
url: url + syncurl
})) : [];
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
27 changes: 4 additions & 23 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,12 @@ describe('sharethrough adapter spec', function () {
it('should properly attach GPP information to the request when applicable', () => {
bidderRequest.gppConsent = {
gppString: 'some-gpp-string',
applicableSections: [3, 5]
applicableSections: [3, 5],
};

const openRtbReq = spec.buildRequests(bidRequests, bidderRequest)[0].data;
expect(openRtbReq.regs.gpp).to.equal(bidderRequest.gppConsent.gppString)
expect(openRtbReq.regs.gpp_sid).to.equal(bidderRequest.gppConsent.applicableSections)
expect(openRtbReq.regs.gpp).to.equal(bidderRequest.gppConsent.gppString);
expect(openRtbReq.regs.gpp_sid).to.equal(bidderRequest.gppConsent.applicableSections);
});

it('should populate request accordingly when gpp explicitly does not apply', function () {
Expand Down Expand Up @@ -618,7 +618,7 @@ describe('sharethrough adapter spec', function () {
badv: ['domain1.com', 'domain2.com'],
regs: {
gpp: 'gpp_string',
gpp_sid: [7]
gpp_sid: [7],
},
};

Expand Down Expand Up @@ -870,25 +870,6 @@ describe('sharethrough adapter spec', function () {
const syncArray = spec.getUserSyncs({ pixelEnabled: false }, serverResponses);
expect(syncArray).to.be.an('array').that.is.empty;
});

it('returns GDPR Consent Params in UserSync url', function () {
const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, { gdprApplies: true,
consentString: 'consent' });
expect(syncArray).to.deep.equal([
{ type: 'image', url: 'cookieUrl1&gdpr=1&gdpr_consent=consent' },
{ type: 'image', url: 'cookieUrl2&gdpr=1&gdpr_consent=consent' },
{ type: 'image', url: 'cookieUrl3&gdpr=1&gdpr_consent=consent' },
]);
});

it('returns GPP Consent Params in UserSync url', function () {
const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, {}, {gppString: 'gpp-string', applicableSections: [1, 2]});
expect(syncArray).to.deep.equal([
{ type: 'image', url: 'cookieUrl1&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' },
{ type: 'image', url: 'cookieUrl2&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' },
{ type: 'image', url: 'cookieUrl3&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' },
]);
});
});
});
});

0 comments on commit 5a1ebad

Please sign in to comment.