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

TL-36516: Add GPP signals to sync endpoint #80

Merged
merged 20 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
25664ce
TL-35335: Cast playbackmethod as array
patrickloughrey Mar 1, 2023
7307d1a
Merge pull request #72 from triplelift-internal/TL-35335-cast-playbac…
patrickloughrey Mar 1, 2023
ee90d99
Merge branch 'prebid:master' into master
nllerandi3lift Apr 14, 2023
3ee1e9b
Merge branch 'prebid:master' into master
patrickloughrey Apr 17, 2023
0ff06ab
Merge branch 'prebid:master' into master
patrickloughrey Apr 21, 2023
40dbe99
TL-36204: Copy tid to imp extension obj
patrickloughrey Apr 21, 2023
4291c1e
Added support for entire ortb2Imp obj
patrickloughrey Apr 24, 2023
feecf24
Only setting what exists in ortb2Imp.ext
patrickloughrey Apr 24, 2023
a709f3f
Added additional test to check copy of entire ext obj
patrickloughrey Apr 24, 2023
49ba6a9
Merge pull request #74 from triplelift-internal/TL-36204-Copy-TID
patrickloughrey Apr 25, 2023
cd65aba
Merge branch 'prebid:master' into master
patrickloughrey Apr 25, 2023
b362e3a
Revert "TL-36204: Copy tid to imp extension object"
patrickloughrey Apr 25, 2023
5574ef5
Merge pull request #75 from triplelift-internal/revert-74-TL-36204-Co…
patrickloughrey Apr 25, 2023
13ee09b
Merge branch 'master' of https://github.com/triplelift-internal/Prebi…
patrickloughrey May 2, 2023
35a7286
Merge branch 'master' of https://github.com/triplelift-internal/Prebi…
patrickloughrey Jun 5, 2023
3836830
Merge branch 'master' of https://github.com/triplelift-internal/Prebi…
patrickloughrey Jun 8, 2023
c13200c
Merge branch 'master' of https://github.com/triplelift-internal/Prebi…
patrickloughrey Jun 20, 2023
0c5d586
TL-36516: Add GPP Signals to sync endpoint
patrickloughrey Jun 20, 2023
15540f7
Added URI encoding for GPP sid
patrickloughrey Jun 22, 2023
a46248e
Optimizing filter algorithm
patrickloughrey Jun 23, 2023
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
18 changes: 17 additions & 1 deletion modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const tripleliftAdapterSpec = {
});
},

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

Expand All @@ -100,6 +100,15 @@ export const tripleliftAdapterSpec = {
syncEndpoint = tryAppendQueryString(syncEndpoint, 'us_privacy', usPrivacy);
}

if (gppConsent) {
if (gppConsent.gppString && typeof gppConsent.gppString === 'string') {
patrickloughrey marked this conversation as resolved.
Show resolved Hide resolved
syncEndpoint = tryAppendQueryString(syncEndpoint, 'gpp', gppConsent.gppString);
}
if (gppConsent.applicableSections && gppConsent.applicableSections.length !== 0) {
syncEndpoint = syncEndpoint + 'gpp_sid=' + _filterSid(gppConsent.applicableSections);

Choose a reason for hiding this comment

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

We need to url encode this so we don't end up with commas in the url
image

Copy link
Author

Choose a reason for hiding this comment

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

cc: @aikenstl see Nick's comment above - this will need to be URI encoded. I thought this may be the case - eng will need to account for this (decode this sid) in order to extract the correct gpp_sid values

}
}

return [{
type: syncType,
url: syncEndpoint
Expand All @@ -113,6 +122,13 @@ function _getSyncType(syncOptions) {
if (syncOptions.pixelEnabled) return 'image';
}

function _filterSid(sid) {
return sid.filter(element => {
return element !== null && element !== undefined;

Choose a reason for hiding this comment

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

I think we should make this
return Number.isInteger(element);
because that's all it should ever be anyway and will also exclude weird nulls/undefineds

Copy link
Author

Choose a reason for hiding this comment

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

I think I like the way I'm doing it here better. The applicableSections within the gppConsent object is an array that we need to do a join(',') on in order to transform it into a comma-separated string to append onto our sync pixel. The filter() is just to make sure the elements are valid

Choose a reason for hiding this comment

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

I meant keep the filter, but replace return element !== null && element !== undefined;
.isInteger will reject strings, etc which are also not valid, in addition to rejecting null/undefined. But this is a small suggestion so whatev you want

Copy link
Author

Choose a reason for hiding this comment

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

I misunderstood your original comment. I agree, the way you are suggesting is optimal. Pushing through.

})
.join(',');
}

function _buildPostBody(bidRequests, bidderRequest) {
let data = {};
let { schain } = bidRequests[0];
Expand Down
15 changes: 14 additions & 1 deletion test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as utils from 'src/utils.js';

const ENDPOINT = 'https://tlx.3lift.com/header/auction?';
const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY';
const GPP_CONSENT_STR = 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN'

describe('triplelift adapter', function () {
const adapter = newBidder(tripleliftAdapterSpec);
Expand Down Expand Up @@ -1506,6 +1507,7 @@ describe('triplelift adapter', function () {
describe('getUserSyncs', function() {
let expectedIframeSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&';
let expectedImageSyncUrl = 'https://eb2.3lift.com/sync?px=1&src=prebid&gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&';
let expectedGppSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&gpp=' + GPP_CONSENT_STR + '&gpp_sid=2,8';

it('returns undefined when syncing is not enabled', function() {
expect(tripleliftAdapterSpec.getUserSyncs({})).to.equal(undefined);
Expand Down Expand Up @@ -1543,8 +1545,19 @@ describe('triplelift adapter', function () {
let syncOptions = {
iframeEnabled: true
};
let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY');
let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY', null);
expect(result[0].url).to.match(/(\?|&)us_privacy=1YYY/);
});
it('returns a user sync pixel with GPP signals when available', function() {
let syncOptions = {
iframeEnabled: true
};
let gppConsent = {
'applicableSections': [2, 8],
'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN'
}
let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, null, gppConsent);
expect(result[0].url).to.equal(expectedGppSyncUrl);
});
});
});