Skip to content

Commit

Permalink
NoBid Analytics Adapter: support for multiple currencies (prebid#11171)
Browse files Browse the repository at this point in the history
* Enable supplyChain support

* Added support for COPPA

* rebuilt

* Added support for Extended User IDs.

* Added support for the "meta" attribute in bid response.

* Delete nobidBidAdapter.js.orig

* Delete a

* Delete .jsdtscope

* Delete org.eclipse.wst.jsdt.ui.superType.container

* Delete org.eclipse.wst.jsdt.ui.superType.name

* Delete .project

* Added support for multiple currencies to the NoBid Analytics adapter.

---------

Co-authored-by: Reda Guermas <reda.guermas@nobid.io>
  • Loading branch information
2 people authored and mefjush committed Mar 7, 2024
1 parent 06a7eb4 commit 392f689
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
7 changes: 4 additions & 3 deletions modules/nobidAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CONSTANTS from '../src/constants.json';
import adapterManager from '../src/adapterManager.js';
import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js';

const VERSION = '2.0.0';
const VERSION = '2.0.1';
const MODULE_NAME = 'nobidAnalyticsAdapter';
const ANALYTICS_OPT_FLUSH_TIMEOUT_SECONDS = 5 * 1000;
const RETENTION_SECONDS = 1 * 24 * 3600;
Expand Down Expand Up @@ -54,6 +54,7 @@ function sendEvent (event, eventType) {
return;
}
try {
event.version = VERSION;
const endpoint = `${resolveEndpoint()}/event/${eventType}?pubid=${nobidAnalytics.initOptions.siteId}`;
ajax(endpoint,
function (response) {
Expand Down Expand Up @@ -83,7 +84,7 @@ function cleanupObjectAttributes (obj, attributes) {
}
function sendBidWonEvent (event, eventType) {
const data = deepClone(event);
cleanupObjectAttributes(data, ['bidderCode', 'size', 'statusMessage', 'adId', 'requestId', 'mediaType', 'adUnitCode', 'cpm', 'timeToRespond']);
cleanupObjectAttributes(data, ['bidderCode', 'size', 'statusMessage', 'adId', 'requestId', 'mediaType', 'adUnitCode', 'cpm', 'currency', 'originalCpm', 'originalCurrency', 'timeToRespond']);
if (nobidAnalytics.topLocation) data.topLocation = nobidAnalytics.topLocation;
sendEvent(data, eventType);
}
Expand All @@ -95,7 +96,7 @@ function sendAuctionEndEvent (event, eventType) {

cleanupObjectAttributes(data, ['timestamp', 'timeout', 'auctionId', 'bidderRequests', 'bidsReceived']);
if (data) cleanupObjectAttributes(data.bidderRequests, ['bidderCode', 'bidderRequestId', 'bids', 'refererInfo']);
if (data) cleanupObjectAttributes(data.bidsReceived, ['bidderCode', 'width', 'height', 'adUnitCode', 'statusMessage', 'requestId', 'mediaType', 'cpm']);
if (data) cleanupObjectAttributes(data.bidsReceived, ['bidderCode', 'width', 'height', 'adUnitCode', 'statusMessage', 'requestId', 'mediaType', 'cpm', 'currency', 'originalCpm', 'originalCurrency']);
if (data) cleanupObjectAttributes(data.noBids, ['bidder', 'sizes', 'bidId']);
if (data.bidderRequests) {
data.bidderRequests.forEach(bidderRequest => {
Expand Down
67 changes: 41 additions & 26 deletions test/spec/modules/nobidAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ describe('NoBid Prebid Analytic', function () {
mediaType: 'banner',
source: 'client',
cpm: 6.4,
currency: 'EUR',
creativeId: 'TEST',
dealId: '',
currency: 'USD',
netRevenue: true,
ttl: 300,
ad: 'AD HERE',
Expand Down Expand Up @@ -167,13 +167,17 @@ describe('NoBid Prebid Analytic', function () {
]
};

const requestOutgoing = {
const expectedOutgoingRequest = {
version: nobidAnalyticsVersion,
bidderCode: 'nobid',
statusMessage: 'Bid available',
adId: '106d14b7d06b607',
requestId: '67a7f0e7ea55c4',
mediaType: 'banner',
cpm: 6.4,
currency: 'EUR',
originalCpm: 6.44,
originalCurrency: 'USD',
adUnitCode: 'leaderboard',
timeToRespond: 545,
size: '728x90',
Expand All @@ -197,16 +201,20 @@ describe('NoBid Prebid Analytic', function () {
clock.tick(5000);
expect(server.requests).to.have.length(1);
const bidWonRequest = JSON.parse(server.requests[0].requestBody);
expect(bidWonRequest).to.have.property('bidderCode', requestOutgoing.bidderCode);
expect(bidWonRequest).to.have.property('statusMessage', requestOutgoing.statusMessage);
expect(bidWonRequest).to.have.property('adId', requestOutgoing.adId);
expect(bidWonRequest).to.have.property('requestId', requestOutgoing.requestId);
expect(bidWonRequest).to.have.property('mediaType', requestOutgoing.mediaType);
expect(bidWonRequest).to.have.property('cpm', requestOutgoing.cpm);
expect(bidWonRequest).to.have.property('adUnitCode', requestOutgoing.adUnitCode);
expect(bidWonRequest).to.have.property('timeToRespond', requestOutgoing.timeToRespond);
expect(bidWonRequest).to.have.property('size', requestOutgoing.size);
expect(bidWonRequest).to.have.property('topLocation', requestOutgoing.topLocation);
expect(bidWonRequest).to.have.property('version', nobidAnalyticsVersion);
expect(bidWonRequest).to.have.property('bidderCode', expectedOutgoingRequest.bidderCode);
expect(bidWonRequest).to.have.property('statusMessage', expectedOutgoingRequest.statusMessage);
expect(bidWonRequest).to.have.property('adId', expectedOutgoingRequest.adId);
expect(bidWonRequest).to.have.property('requestId', expectedOutgoingRequest.requestId);
expect(bidWonRequest).to.have.property('mediaType', expectedOutgoingRequest.mediaType);
expect(bidWonRequest).to.have.property('cpm', expectedOutgoingRequest.cpm);
expect(bidWonRequest).to.have.property('currency', expectedOutgoingRequest.currency);
expect(bidWonRequest).to.have.property('originalCpm', expectedOutgoingRequest.originalCpm);
expect(bidWonRequest).to.have.property('originalCurrency', expectedOutgoingRequest.originalCurrency);
expect(bidWonRequest).to.have.property('adUnitCode', expectedOutgoingRequest.adUnitCode);
expect(bidWonRequest).to.have.property('timeToRespond', expectedOutgoingRequest.timeToRespond);
expect(bidWonRequest).to.have.property('size', expectedOutgoingRequest.size);
expect(bidWonRequest).to.have.property('topLocation', expectedOutgoingRequest.topLocation);
expect(bidWonRequest).to.not.have.property('pbCg');

done();
Expand Down Expand Up @@ -304,10 +312,10 @@ describe('NoBid Prebid Analytic', function () {
auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa',
mediaType: 'banner',
source: 'client',
cpm: 6.44,
cpm: 5.93,
currency: 'EUR',
creativeId: 'TEST',
dealId: '',
currency: 'USD',
netRevenue: true,
ttl: 300,
ad: '',
Expand Down Expand Up @@ -336,7 +344,7 @@ describe('NoBid Prebid Analytic', function () {
timeout: 3000
};

const requestOutgoing = {
const expectedOutgoingRequest = {
auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa',
bidderRequests: [
{
Expand Down Expand Up @@ -364,7 +372,10 @@ describe('NoBid Prebid Analytic', function () {
width: 728,
height: 90,
mediaType: 'banner',
cpm: 6.44,
cpm: 5.93,
currency: 'EUR',
originalCpm: 6.44,
originalCurrency: 'USD',
adUnitCode: 'leaderboard'
}
]
Expand All @@ -387,22 +398,26 @@ describe('NoBid Prebid Analytic', function () {
clock.tick(5000);
expect(server.requests).to.have.length(1);
const auctionEndRequest = JSON.parse(server.requests[0].requestBody);
expect(auctionEndRequest).to.have.property('auctionId', requestOutgoing.auctionId);
expect(auctionEndRequest).to.have.property('version', nobidAnalyticsVersion);
expect(auctionEndRequest).to.have.property('auctionId', expectedOutgoingRequest.auctionId);
expect(auctionEndRequest.bidderRequests).to.have.length(1);
expect(auctionEndRequest.bidderRequests[0].bidderCode).to.equal(requestOutgoing.bidderRequests[0].bidderCode);
expect(auctionEndRequest.bidderRequests[0].bidderCode).to.equal(expectedOutgoingRequest.bidderRequests[0].bidderCode);
expect(auctionEndRequest.bidderRequests[0].bids).to.have.length(1);
expect(typeof auctionEndRequest.bidderRequests[0].bids[0].bidder).to.equal('undefined');
expect(auctionEndRequest.bidderRequests[0].bids[0].adUnitCode).to.equal(requestOutgoing.bidderRequests[0].bids[0].adUnitCode);
expect(auctionEndRequest.bidderRequests[0].bids[0].adUnitCode).to.equal(expectedOutgoingRequest.bidderRequests[0].bids[0].adUnitCode);
expect(typeof auctionEndRequest.bidderRequests[0].bids[0].params).to.equal('undefined');
expect(typeof auctionEndRequest.bidderRequests[0].bids[0].src).to.equal('undefined');
expect(auctionEndRequest.bidderRequests[0].refererInfo.topmostLocation).to.equal(requestOutgoing.bidderRequests[0].refererInfo.topmostLocation);
expect(auctionEndRequest.bidderRequests[0].refererInfo.topmostLocation).to.equal(expectedOutgoingRequest.bidderRequests[0].refererInfo.topmostLocation);
expect(auctionEndRequest.bidsReceived).to.have.length(1);
expect(auctionEndRequest.bidsReceived[0].bidderCode).to.equal(requestOutgoing.bidsReceived[0].bidderCode);
expect(auctionEndRequest.bidsReceived[0].width).to.equal(requestOutgoing.bidsReceived[0].width);
expect(auctionEndRequest.bidsReceived[0].height).to.equal(requestOutgoing.bidsReceived[0].height);
expect(auctionEndRequest.bidsReceived[0].mediaType).to.equal(requestOutgoing.bidsReceived[0].mediaType);
expect(auctionEndRequest.bidsReceived[0].cpm).to.equal(requestOutgoing.bidsReceived[0].cpm);
expect(auctionEndRequest.bidsReceived[0].adUnitCode).to.equal(requestOutgoing.bidsReceived[0].adUnitCode);
expect(auctionEndRequest.bidsReceived[0].bidderCode).to.equal(expectedOutgoingRequest.bidsReceived[0].bidderCode);
expect(auctionEndRequest.bidsReceived[0].width).to.equal(expectedOutgoingRequest.bidsReceived[0].width);
expect(auctionEndRequest.bidsReceived[0].height).to.equal(expectedOutgoingRequest.bidsReceived[0].height);
expect(auctionEndRequest.bidsReceived[0].mediaType).to.equal(expectedOutgoingRequest.bidsReceived[0].mediaType);
expect(auctionEndRequest.bidsReceived[0].cpm).to.equal(expectedOutgoingRequest.bidsReceived[0].cpm);
expect(auctionEndRequest.bidsReceived[0].currency).to.equal(expectedOutgoingRequest.bidsReceived[0].currency);
expect(auctionEndRequest.bidsReceived[0].originalCpm).to.equal(expectedOutgoingRequest.bidsReceived[0].originalCpm);
expect(auctionEndRequest.bidsReceived[0].originalCurrency).to.equal(expectedOutgoingRequest.bidsReceived[0].originalCurrency);
expect(auctionEndRequest.bidsReceived[0].adUnitCode).to.equal(expectedOutgoingRequest.bidsReceived[0].adUnitCode);
expect(typeof auctionEndRequest.bidsReceived[0].source).to.equal('undefined');

done();
Expand Down

0 comments on commit 392f689

Please sign in to comment.