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

Add CCPA query param #3

Merged
merged 2 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export const tripleliftAdapterSpec = {
}
}

if (bidderRequest && bidderRequest.uspConsent) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking - I don't like how we repeat bidderRequest && so much in this file. maybe group all these if's under a single if (bidderRequest) { ... } or initialize a default value for bidderRequest if it doesn't exist. I see some other adapters in this repo using es6 so it might be simple to set a default.

tlCall = utils.tryAppendQueryString(tlCall, 'us_privacy', bidderRequest.uspConsent);
}

if (tlCall.lastIndexOf('&') === tlCall.length - 1) {
tlCall = tlCall.substring(0, tlCall.length - 1);
}
Expand All @@ -62,7 +66,7 @@ export const tripleliftAdapterSpec = {
});
},

getUserSyncs: function(syncOptions) {
getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy) {
let syncType = _getSyncType(syncOptions);
if (!syncType) return;

Expand All @@ -78,6 +82,10 @@ export const tripleliftAdapterSpec = {
syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'cmp_cs', consentString);
}

if (typeof usPrivacy === 'string' && usPrivacy.length > 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have an example value for this usPrivacy argument? I'm reading the prebid docs and it says this may be an object instead of a string?
The usPrivacy object is also available when registering userSync pixels. The object can be accessed by including it as an argument in the getUserSyncs function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very confusing, but they appear to be just passing along the string value from the bidderRequest object (the uspConsent property): https://github.com/prebid/Prebid.js/blob/master/src/adapters/bidderFactory.js#L336. Pubmatic and Rubicon seem to be making the same assumption (sort of), but I'll adjust this to be more similar to their implementation.

syncEndpoint = utils.tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy);
}

return [{
type: syncType,
url: syncEndpoint
Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ describe('triplelift adapter', function () {
expect(url).to.match(new RegExp('(?:' + prebid.version + ')'))
expect(url).to.match(/(?:referrer)/);
});
it('should return us_privacy param when CCPA info is available', function() {
bidderRequest.uspConsent = '1YYY';
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const url = request.url;
expect(url).to.match(/(\?|&)us_privacy=1YYY/);
});
it('should return schain when present', function() {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const { data: payload } = request;
Expand Down Expand Up @@ -401,5 +407,12 @@ describe('triplelift adapter', function () {
expect(result[0].type).to.equal('iframe');
expect(result[0].url).to.equal(expectedIframeSyncUrl);
});
it('sends us_privacy param when info is available', function() {
let syncOptions = {
iframeEnabled: true
};
let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY');
expect(result[0].url).to.match(/(\?|&)us_privacy=1YYY/);
});
});
});