Skip to content

Commit

Permalink
Sharethrough GDPR updates (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscpan authored and jaiminpanchal27 committed May 23, 2018
1 parent a637b4b commit 74d04b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 8 additions & 4 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ export const sharethroughAdapterSpec = {
placement_key: bid.params.pkey,
hbVersion: '$prebid.version$',
strVersion: VERSION,
hbSource: 'prebid'
hbSource: 'prebid',
consent_required: false
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) {
query.consent_string = bidderRequest.gdprConsent.consentString;
query.consent_required = bidderRequest.gdprConsent.gdprApplies;
}

if (bidderRequest && bidderRequest.gdprConsent) {
query.consent_required = !!bidderRequest.gdprConsent.gdprApplies;
}

return {
Expand Down Expand Up @@ -51,7 +55,7 @@ export const sharethroughAdapterSpec = {
},
getUserSyncs: (syncOptions, serverResponses) => {
const syncs = [];
if (syncOptions.pixelEnabled && serverResponses.length > 0) {
if (syncOptions.pixelEnabled && serverResponses.length > 0 && serverResponses[0].body) {
serverResponses[0].body.cookieSyncUrls.forEach(url => {
syncs.push({ type: 'image', url: url });
});
Expand Down
14 changes: 13 additions & 1 deletion test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@ describe('sharethrough adapter spec', () => {
const gdprConsent = { consentString: 'consent_string123', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidderRequest, fakeBidRequest)[0];
expect(bidRequest.data.consent_string).to.eq('consent_string123');
expect(bidRequest.data.consent_required).to.eq(true);
expect(bidRequest.data.consent_string).to.eq('consent_string123');
});

it('should handle gdprConsent is present but values are undefined case', () => {
const gdprConsent = { consent_string: undefined, gdprApplies: undefined };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidderRequest, fakeBidRequest)[0];
expect(bidRequest.data).to.not.include.any.keys('consent_string')
});
});

Expand Down Expand Up @@ -171,6 +178,11 @@ describe('sharethrough adapter spec', () => {
);
});

it('returns an empty array if the body is null', () => {
const syncArray = spec.getUserSyncs({ pixelEnabled: true }, [{ body: null }]);
expect(syncArray).to.be.an('array').that.is.empty;
});

it('returns an empty array if pixels are not enabled', () => {
const syncArray = spec.getUserSyncs({ pixelEnabled: false }, serverResponses);
expect(syncArray).to.be.an('array').that.is.empty;
Expand Down

0 comments on commit 74d04b2

Please sign in to comment.