Skip to content

Commit

Permalink
AIDEM Bid Adapter: extended app/site parameters on win notice (#9765)
Browse files Browse the repository at this point in the history
* AIDEM Bid Adapter

* Added _spec.js

* update

* Fix Navigator in _spec.js

* Removed timeout handler.

* Added publisherId as required bidder params

* moved publisherId into site publisher object

* Added wpar to environment

* Added placementId parameter

* added unit tests for the wpar environment object

* PlacementId is now a required parameter
Added optional rateLimit parameter
Added publisherId, siteId, placementId in win notice payload
Added unit tests

* Revert to optional placementId parameter
Added missing semicolons

* Extended win notice

---------

Co-authored-by: Giovanni Sollazzo <gs@aidem.com>
Co-authored-by: darkstar <canazza@wazabit.it>
  • Loading branch information
3 people authored Apr 6, 2023
1 parent 3cb413f commit 640a4ea
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 8 deletions.
5 changes: 5 additions & 0 deletions modules/aidemBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function getPageUrl(bidderRequest) {

function buildWinNotice(bid) {
const params = bid.params[0];
const app = deepAccess(bid, 'meta.ext.app')
return {
publisherId: params.publisherId,
siteId: params.siteId,
Expand All @@ -167,6 +168,9 @@ function buildWinNotice(bid) {
ttl: bid.ttl,
requestTimestamp: bid.requestTimestamp,
responseTimestamp: bid.responseTimestamp,
mediatype: bid.mediaType,
environment: app ? 'app' : 'web',
...app
};
}

Expand Down Expand Up @@ -348,6 +352,7 @@ function getPrebidResponseBidObject(openRTBResponseBidObject) {
function setPrebidResponseBidObjectMeta(prebidResponseBidObject, openRTBResponseBidObject) {
logInfo('AIDEM Bid Adapter meta', openRTBResponseBidObject);
deepSetValue(prebidResponseBidObject, 'meta.advertiserDomains', deepAccess(openRTBResponseBidObject, 'meta.advertiserDomains'));
deepSetValue(prebidResponseBidObject, 'meta.ext', deepAccess(openRTBResponseBidObject, 'meta.ext'));
if (openRTBResponseBidObject.cat && Array.isArray(openRTBResponseBidObject.cat)) {
const primaryCatId = openRTBResponseBidObject.cat.shift();
deepSetValue(prebidResponseBidObject, 'meta.primaryCatId', primaryCatId);
Expand Down
80 changes: 72 additions & 8 deletions test/spec/modules/aidemBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ const SERVER_RESPONSE_VIDEO = {
},
}

const WIN_NOTICE = {
const WIN_NOTICE_WEB = {
'adId': '3a20ee5dc78c1e',
'adUnitCode': 'div-gpt-ad-1460505748561-0',
'creativeId': '24277955',
Expand All @@ -297,9 +297,71 @@ const WIN_NOTICE = {
'USD'
],
'mediaType': 'banner',
'advertiserDomains': [
'abc.com'
'meta': {
'advertiserDomains': [
'cloudflare.com'
],
'ext': {}
},
'size': '300x250',
'params': [
{
'placementId': '13144370',
'siteId': '23434',
'publisherId': '7689670753'
}
],
'width': 300,
'height': 250,
'status': 'rendered',
'transactionId': 'ce089116-4251-45c3-bdbb-3a03cb13816b',
'ttl': 300,
'requestTimestamp': 1666796241007,
'responseTimestamp': 1666796241021,
metrics: {
getMetrics() {
return {

}
}
}
}

const WIN_NOTICE_APP = {
'adId': '3a20ee5dc78c1e',
'adUnitCode': 'div-gpt-ad-1460505748561-0',
'creativeId': '24277955',
'cpm': 1,
'netRevenue': false,
'adserverTargeting': {
'hb_bidder': 'aidem',
'hb_adid': '3a20ee5dc78c1e',
'hb_pb': '1.00',
'hb_size': '300x250',
'hb_source': 'client',
'hb_format': 'banner',
'hb_adomain': 'example.com'
},

'auctionId': '85864730-6cbc-4e56-bc3c-a4a6596dca5b',
'currency': [
'USD'
],
'mediaType': 'banner',
'meta': {
'advertiserDomains': [
'cloudflare.com'
],
'ext': {
'app': {
'app_bundle': '{{APP_BUNDLE}}',
'app_id': '{{APP_ID}}',
'app_name': '{{APP_NAME}}',
'app_store_url': '{{APP_STORE_URL}}',
'inventory_source': '{{INVENTORY_SOURCE}}'
}
}
},
'size': '300x250',
'params': [
{
Expand Down Expand Up @@ -549,11 +611,13 @@ describe('Aidem adapter', () => {
expect(spec.onBidWon).to.exist.and.to.be.a('function')
});

it(`should send a valid bid won notice`, function () {
spec.onBidWon(WIN_NOTICE);
// server.respondWith('POST', WIN_EVENT_URL, [
// 400, {'Content-Type': 'application/json'}, )
// ]);
it(`should send a valid bid won notice from web environment`, function () {
spec.onBidWon(WIN_NOTICE_WEB);
expect(server.requests.length).to.equal(1);
});

it(`should send a valid bid won notice from app environment`, function () {
spec.onBidWon(WIN_NOTICE_APP);
expect(server.requests.length).to.equal(1);
});
});
Expand Down

0 comments on commit 640a4ea

Please sign in to comment.