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

Rubicon Analytics: pass along userId providers #7180

Merged
merged 1 commit into from
Jul 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ function sendMessage(auctionId, bidWonId, trigger) {
auction.serverTimeoutMillis = serverConfig.timeout;
}

if (auctionCache.userIds.length) {
auction.user = {ids: auctionCache.userIds};
}

message.auctions = [auction];

let bidsWon = Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => {
Expand Down Expand Up @@ -585,6 +589,9 @@ let rubiconAdapter = Object.assign({}, baseAdapter, {
}
cacheEntry.gdprConsent = utils.deepAccess(args, 'bidderRequests.0.gdprConsent');
cacheEntry.session = storage.localStorageIsEnabled() && updateRpaCookie();
cacheEntry.userIds = Object.keys(utils.deepAccess(args, 'bidderRequests.0.bids.0.userId', {})).map(id => {
return {provider: id, hasId: true}
});
cache.auctions[args.auctionId] = cacheEntry;
// register to listen to gpt events if not done yet
if (!cache.gpt.registered && utils.isGptPubadsDefined()) {
Expand Down
36 changes: 36 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,42 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(ANALYTICS_MESSAGE);
});

it('should pass along user ids', function () {
let auctionInit = utils.deepClone(MOCK.AUCTION_INIT);
auctionInit.bidderRequests[0].bids[0].userId = {
criteoId: 'sadfe4334',
lotamePanoramaId: 'asdf3gf4eg',
pubcid: 'dsfa4545-svgdfs5',
sharedId: {id1: 'asdf', id2: 'sadf4344'}
};

events.emit(AUCTION_INIT, auctionInit);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]);
events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]);
events.emit(BIDDER_DONE, MOCK.BIDDER_DONE);
events.emit(AUCTION_END, MOCK.AUCTION_END);

events.emit(SET_TARGETING, MOCK.SET_TARGETING);
events.emit(BID_WON, MOCK.BID_WON[0]);
events.emit(BID_WON, MOCK.BID_WON[1]);

expect(server.requests.length).to.equal(1);
let request = server.requests[0];

let message = JSON.parse(request.requestBody);
validate(message);

expect(message.auctions[0].user).to.deep.equal({
ids: [
{provider: 'criteoId', 'hasId': true},
{provider: 'lotamePanoramaId', 'hasId': true},
{provider: 'pubcid', 'hasId': true},
{provider: 'sharedId', 'hasId': true},
]
});
});

it('should handle bidResponse dimensions correctly', function () {
events.emit(AUCTION_INIT, MOCK.AUCTION_INIT);
events.emit(BID_REQUESTED, MOCK.BID_REQUESTED);
Expand Down