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 GDPR updates #2563

Merged
merged 1 commit into from
May 23, 2018
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
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