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

Sharethrough Bid Adapter: revise getUserSyncs method #10556

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
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' },
]);
});
});
});
});