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

Adagio Analytics Adapter: add bidders code #12188

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
10 changes: 7 additions & 3 deletions modules/adagioAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,16 @@ function handlerAuctionInit(event) {
bannerSize => bannerSize
).sort();

const sortedBidderCodes = bidders.sort()
const sortedBidderNames = bidders.sort();

const bidSrcMapper = (bidder) => {
// bidderCode in the context of the bidderRequest is the name given to the bidder in the adunit.
// It is not always the "true" bidder code, it can also be its alias
const request = event.bidderRequests.find(br => br.bidderCode === bidder)
return request ? request.bids[0].src : null
}
const biddersSrc = sortedBidderCodes.map(bidSrcMapper).join(',');
const biddersSrc = sortedBidderNames.map(bidSrcMapper).join(',');
const biddersCode = sortedBidderNames.map(bidder => adapterManager.resolveAlias(bidder)).join(',');

// if adagio was involved in the auction we identified it with rtdUid, if not use the prebid auctionId
const auctionId = rtdUid || prebidAuctionId;
Expand All @@ -238,14 +241,15 @@ function handlerAuctionInit(event) {
url_dmn: w.location.hostname,
mts: mediaTypesKeys.join(','),
ban_szs: bannerSizes.join(','),
bdrs: sortedBidderCodes.join(','),
bdrs: sortedBidderNames.join(','),
pgtyp: deepAccess(event.bidderRequests[0], 'ortb2.site.ext.data.pagetype', null),
plcmt: deepAccess(adUnits[0], 'ortb2Imp.ext.data.placement', null),
t_n: adgRtdSession.testName || null,
t_v: adgRtdSession.testVersion || null,
s_id: adgRtdSession.id || null,
s_new: adgRtdSession.new || null,
bdrs_src: biddersSrc,
bdrs_code: biddersCode,
};

if (adagioBidRequest && adagioBidRequest.bids) {
Expand Down
47 changes: 38 additions & 9 deletions test/spec/modules/adagioAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ const AUCTION_INIT_ANOTHER = {
'params': {
...PARAMS_ADG
},
}, {
'bidder': 'anotherWithAlias',
'params': {
'publisherId': '1001'
},
}, ],
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'ortb2Imp': {
Expand Down Expand Up @@ -340,7 +345,25 @@ const AUCTION_INIT_ANOTHER = {
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
}
}, {
'bidder': 'anotherWithAlias',
'params': {
'publisherId': '1001',
},
'mediaTypes': {
'banner': {
'sizes': [[640, 480]]
}
},
'adUnitCode': '/19968336/header-bid-tag-1',
'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014',
'sizes': [[640, 480]],
'bidId': '2ecff0db240757',
'bidderRequestId': '1be65d7958826a',
'auctionId': AUCTION_ID,
'src': 'client',
'bidRequestsCount': 1
},
],
'timeout': 3000,
'refererInfo': {
Expand Down Expand Up @@ -682,10 +705,12 @@ describe('adagio analytics adapter', () => {
site: 'test-com',
}
});
adapterManager.aliasRegistry['anotherWithAlias'] = 'another';
});

afterEach(() => {
adagioAnalyticsAdapter.disableAnalytics();
delete adapterManager.aliasRegistry['anotherWithAlias'];
});

it('builds and sends auction data', () => {
Expand Down Expand Up @@ -715,7 +740,8 @@ describe('adagio analytics adapter', () => {
expect(search.plcmt).to.equal('pave_top');
expect(search.mts).to.equal('ban');
expect(search.ban_szs).to.equal('640x100,640x480');
expect(search.bdrs).to.equal('adagio,another,nobid');
expect(search.bdrs).to.equal('adagio,another,anotherWithAlias,nobid');
expect(search.bdrs_code).to.equal('adagio,another,another,nobid');
expect(search.adg_mts).to.equal('ban');
}

Expand All @@ -736,8 +762,8 @@ describe('adagio analytics adapter', () => {
expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
expect(search.e_sid).to.equal('42');
expect(search.e_pba_test).to.equal('true');
expect(search.bdrs_bid).to.equal('1,1,0');
expect(search.bdrs_cpm).to.equal('1.42,2.052,');
expect(search.bdrs_bid).to.equal('1,1,0,0');
expect(search.bdrs_cpm).to.equal('1.42,2.052,,');
}

{
Expand Down Expand Up @@ -796,6 +822,7 @@ describe('adagio analytics adapter', () => {
expect(search.mts).to.equal('ban');
expect(search.ban_szs).to.equal('640x100,640x480');
expect(search.bdrs).to.equal('adagio,another');
expect(search.bdrs_code).to.equal('adagio,another');
expect(search.adg_mts).to.equal('ban');
expect(search.t_n).to.equal('test');
expect(search.t_v).to.equal('version');
Expand All @@ -819,6 +846,7 @@ describe('adagio analytics adapter', () => {
expect(search.mts).to.equal('ban');
expect(search.ban_szs).to.equal('640x480');
expect(search.bdrs).to.equal('another');
expect(search.bdrs_code).to.equal('another');
expect(search.adg_mts).to.not.exist;
}

Expand All @@ -839,7 +867,8 @@ describe('adagio analytics adapter', () => {
expect(search.plcmt).to.equal('pave_top');
expect(search.mts).to.equal('ban');
expect(search.ban_szs).to.equal('640x100,640x480');
expect(search.bdrs).to.equal('adagio,another,nobid');
expect(search.bdrs).to.equal('adagio,another,anotherWithAlias,nobid');
expect(search.bdrs_code).to.equal('adagio,another,another,nobid');
expect(search.adg_mts).to.equal('ban');
}

Expand All @@ -864,8 +893,8 @@ describe('adagio analytics adapter', () => {
expect(search.adu_code).to.equal('/19968336/header-bid-tag-1');
expect(search.e_sid).to.equal('42');
expect(search.e_pba_test).to.equal('true');
expect(search.bdrs_bid).to.equal('0,0,0');
expect(search.bdrs_cpm).to.equal(',,');
expect(search.bdrs_bid).to.equal('0,0,0,0');
expect(search.bdrs_cpm).to.equal(',,,');
}

{
Expand Down Expand Up @@ -939,8 +968,8 @@ describe('adagio analytics adapter', () => {
expect(search.v).to.equal('2');
expect(search.e_sid).to.equal('42');
expect(search.e_pba_test).to.equal('true');
expect(search.bdrs_bid).to.equal('1,1,0');
expect(search.bdrs_cpm).to.equal('1.42,,');
expect(search.bdrs_bid).to.equal('1,1,0,0');
expect(search.bdrs_cpm).to.equal('1.42,,,');
}
});
});
Expand Down