Skip to content

Commit 360c3ea

Browse files
authored
Greenbids Analytics : send cpm on any valid bid (prebid#12174)
* fix(greenbids,analytics): send cpm on any valid bid (#5) * fix(greenbids,analytics): cpm not passed * bump version number * fix unit tests
1 parent b7efc5a commit 360c3ea

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

modules/greenbidsAnalyticsAdapter.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ import { EVENTS } from '../src/constants.js';
44
import adapterManager from '../src/adapterManager.js';
55
import {deepClone, generateUUID, logError, logInfo, logWarn, getParameterByName} from '../src/utils.js';
66

7+
/**
8+
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
9+
*/
10+
11+
/**
12+
* @typedef {object} Message Payload message sent to the Greenbids API
13+
*/
14+
715
const analyticsType = 'endpoint';
816

9-
export const ANALYTICS_VERSION = '2.3.1';
17+
export const ANALYTICS_VERSION = '2.3.2';
1018

1119
const ANALYTICS_SERVER = 'https://a.greenbids.ai';
1220

@@ -97,6 +105,11 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
97105
contentType: 'application/json'
98106
});
99107
},
108+
/**
109+
*
110+
* @param {string} auctionId
111+
* @returns {Message}
112+
*/
100113
createCommonMessage(auctionId) {
101114
const cachedAuction = this.getCachedAuction(auctionId);
102115
return {
@@ -111,14 +124,27 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
111124
adUnits: [],
112125
};
113126
},
127+
/**
128+
* @param {Bid} bid
129+
* @param {BIDDER_STATUS} status
130+
*/
114131
serializeBidResponse(bid, status) {
115132
return {
116133
bidder: bid.bidder,
117134
isTimeout: (status === BIDDER_STATUS.TIMEOUT),
118135
hasBid: (status === BIDDER_STATUS.BID),
119136
params: (bid.params && Object.keys(bid.params).length > 0) ? bid.params : {},
137+
...(status === BIDDER_STATUS.BID ? {
138+
cpm: bid.cpm,
139+
currency: bid.currency
140+
} : {}),
120141
};
121142
},
143+
/**
144+
* @param {*} message Greenbids API payload
145+
* @param {Bid} bid Bid to add to the payload
146+
* @param {BIDDER_STATUS} status Bidding status
147+
*/
122148
addBidResponseToMessage(message, bid, status) {
123149
const adUnitCode = bid.adUnitCode.toLowerCase();
124150
const adUnitIndex = message.adUnits.findIndex((adUnit) => {

test/spec/modules/greenbidsAnalyticsAdapter_spec.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,17 @@ describe('Greenbids Prebid AnalyticsAdapter Testing', function () {
280280
bidder: 'greenbids',
281281
isTimeout: false,
282282
hasBid: true,
283-
params: {}
283+
params: {},
284+
cpm: 0.1,
285+
currency: 'USD',
284286
},
285287
{
286288
bidder: 'greenbidsx',
287289
isTimeout: false,
288290
hasBid: true,
289-
params: {'placement ID': 12784}
291+
params: { 'placement ID': 12784 },
292+
cpm: 0.08,
293+
currency: 'USD',
290294
}
291295
]
292296
},

0 commit comments

Comments
 (0)