Skip to content

Commit a396ad2

Browse files
authored
Merge pull request #4 from greenbids/cpm_fix
fix(greenbids,analytics): cpm not passed
2 parents 87e198f + 361bed1 commit a396ad2

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

modules/greenbidsAnalyticsAdapter.js

Lines changed: 25 additions & 1 deletion
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,25 @@ 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+
cpm: (status === BIDDER_STATUS.BID ? bid.cpm : null),
138+
currency: (status === BIDDER_STATUS.BID ? bid.currency : null)
120139
};
121140
},
141+
/**
142+
* @param {*} message Greenbids API payload
143+
* @param {Bid} bid Bid to add to the payload
144+
* @param {BIDDER_STATUS} status Bidding status
145+
*/
122146
addBidResponseToMessage(message, bid, status) {
123147
const adUnitCode = bid.adUnitCode.toLowerCase();
124148
const adUnitIndex = message.adUnits.findIndex((adUnit) => {

0 commit comments

Comments
 (0)