Skip to content

Commit

Permalink
Update getUid function to check for pubcid and sharedid
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettBlox committed Apr 4, 2023
1 parent 4a43497 commit fcfdf75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
19 changes: 13 additions & 6 deletions modules/concertBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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',
uspConsent: bidderRequest.uspConsent,
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

0 comments on commit fcfdf75

Please sign in to comment.