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

Concert Bid Adapter: Enable support for additional userId's #9780

Merged
merged 17 commits into from
Apr 10, 2023
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
21 changes: 14 additions & 7 deletions modules/concertBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const spec = {
pageUrl: bidderRequest.refererInfo.page,
screen: [window.screen.width, window.screen.height].join('x'),
debug: debugTurnedOn(),
uid: getUid(bidderRequest),
uid: getUid(bidderRequest, validBidRequests),
optedOut: hasOptedOutOfPersonalization(),
adapterVersion: '1.1.1',
adapterVersion: '1.2.0',
uspConsent: bidderRequest.uspConsent,
gdprConsent: bidderRequest.gdprConsent,
gppConsent: bidderRequest.gppConsent,
Expand Down Expand Up @@ -158,16 +158,23 @@ export const storage = getStorageManager({bidderCode: BIDDER_CODE});
/**
* Check or generate a UID for the current user.
*/
function getUid(bidderRequest) {
function getUid(bidderRequest, validBidRequests) {
if (hasOptedOutOfPersonalization() || !consentAllowsPpid(bidderRequest)) {
return false;
}

const sharedId = deepAccess(bidderRequest, 'userId._sharedid.id');
/**
* check for shareId or pubCommonId before generating a new one
* sharedId: @see https://docs.prebid.org/dev-docs/modules/userId.html
* pubCid (no longer supported): @see https://docs.prebid.org/dev-docs/modules/pubCommonId.html#adapter-integration
*/
const sharedId =
deepAccess(validBidRequests[0], 'userId.sharedid.id') ||
deepAccess(validBidRequests[0], 'userId.pubcid')
const pubCid = deepAccess(validBidRequests[0], 'crumbs.pubcid');

if (sharedId) {
return sharedId;
}
if (sharedId) return sharedId;
if (pubCid) return pubCid;

const LEGACY_CONCERT_UID_KEY = 'c_uid';
const CONCERT_UID_KEY = 'vmconcert_uid';
Expand Down
11 changes: 3 additions & 8 deletions test/spec/modules/concertBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,10 @@ describe('ConcertAdapter', function () {

it('should use sharedid if it exists', function() {
storage.removeDataFromLocalStorage('c_nap');
const request = spec.buildRequests(bidRequests, {
...bidRequest,
userId: {
_sharedid: {
id: '123abc'
}
}
});
const bidRequestsWithSharedId = [{ ...bidRequests[0], userId: { sharedid: { id: '123abc' } } }]
const request = spec.buildRequests(bidRequestsWithSharedId, bidRequest);
const payload = JSON.parse(request.data);

expect(payload.meta.uid).to.equal('123abc');
})

Expand Down