Skip to content

Commit

Permalink
TargetVideo Bid Adapter: Add GDPR/USP support (prebid#8589)
Browse files Browse the repository at this point in the history
* TargetVideo bid adapter

* TargetVideo bid adapter

* TargetVideo bid adapter

* TargetVideo Bid Adapter: Add GDPR/USP support

* TargetVideo Bid Adapter: Add GDPR/USP support tests
  • Loading branch information
grajzer authored and Chris Corbo committed Jul 27, 2022
1 parent 58619a9 commit 500f0fb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
18 changes: 18 additions & 0 deletions modules/targetVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ export const spec = {
},
schain: schain
};

if (bidderRequest && bidderRequest.gdprConsent) {
payload.gdpr_consent = {
consent_string: bidderRequest.gdprConsent.consentString,
consent_required: bidderRequest.gdprConsent.gdprApplies
};

if (bidderRequest.gdprConsent.addtlConsent && bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1) {
let ac = bidderRequest.gdprConsent.addtlConsent;
let acStr = ac.substring(ac.indexOf('~') + 1);
payload.gdpr_consent.addtl_consent = acStr.split('.').map(id => parseInt(id, 10));
}
}

if (bidderRequest && bidderRequest.uspConsent) {
payload.us_privacy = bidderRequest.uspConsent
}

return formatRequest(payload, bidderRequest);
},

Expand Down
43 changes: 43 additions & 0 deletions test/spec/modules/targetVideoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,47 @@ describe('TargetVideo Bid Adapter', function() {
expect(bid.ad).to.include('<script src="https://player.target-video.com/custom/targetvideo-banner.js"></script>')
expect(bid.ad).to.include('initPlayer')
});

it('Test GDPR consent information is present in the request', function () {
let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
let bidderRequest = {
'bidderCode': 'targetVideo',
'auctionId': '1d1a030790a475',
'bidderRequestId': '22edbae2733bf6',
'timeout': 3000,
'gdprConsent': {
consentString: consentString,
gdprApplies: true,
addtlConsent: '1~7.12.35.62.66.70.89.93.108'
}
};
bidderRequest.bids = bannerRequest;

const request = spec.buildRequests(bannerRequest, bidderRequest);
expect(request.options).to.deep.equal({withCredentials: true});
const payload = JSON.parse(request.data);

expect(payload.gdpr_consent).to.exist;
expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString);
expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true;
expect(payload.gdpr_consent.addtl_consent).to.exist.and.to.deep.equal([7, 12, 35, 62, 66, 70, 89, 93, 108]);
});

it('Test US Privacy string is present in the request', function() {
let consentString = '1YA-';
let bidderRequest = {
'bidderCode': 'targetVideo',
'auctionId': '1d1a030790a475',
'bidderRequestId': '22edbae2733bf6',
'timeout': 3000,
'uspConsent': consentString
};
bidderRequest.bids = bannerRequest;

const request = spec.buildRequests(bannerRequest, bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.us_privacy).to.exist;
expect(payload.us_privacy).to.exist.and.to.equal(consentString);
});
});

0 comments on commit 500f0fb

Please sign in to comment.