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

fix(greenbids,analytics): send cpm on any valid bid #5

Merged
merged 2 commits into from
Aug 27, 2024
Merged
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
26 changes: 25 additions & 1 deletion modules/greenbidsAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ import { EVENTS } from '../src/constants.js';
import adapterManager from '../src/adapterManager.js';
import {deepClone, generateUUID, logError, logInfo, logWarn, getParameterByName} from '../src/utils.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
*/

/**
* @typedef {object} Message Payload message sent to the Greenbids API
*/

const analyticsType = 'endpoint';

export const ANALYTICS_VERSION = '2.3.1';
export const ANALYTICS_VERSION = '2.3.2';

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

Expand Down Expand Up @@ -97,6 +105,11 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
contentType: 'application/json'
});
},
/**
*
* @param {string} auctionId
* @returns {Message}
*/
createCommonMessage(auctionId) {
const cachedAuction = this.getCachedAuction(auctionId);
return {
Expand All @@ -111,14 +124,25 @@ export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER
adUnits: [],
};
},
/**
* @param {Bid} bid
* @param {BIDDER_STATUS} status
*/
serializeBidResponse(bid, status) {
return {
bidder: bid.bidder,
isTimeout: (status === BIDDER_STATUS.TIMEOUT),
hasBid: (status === BIDDER_STATUS.BID),
params: (bid.params && Object.keys(bid.params).length > 0) ? bid.params : {},
cpm: (status === BIDDER_STATUS.BID ? bid.cpm : null),
currency: (status === BIDDER_STATUS.BID ? bid.currency : null)
};
},
/**
* @param {*} message Greenbids API payload
* @param {Bid} bid Bid to add to the payload
* @param {BIDDER_STATUS} status Bidding status
*/
addBidResponseToMessage(message, bid, status) {
const adUnitCode = bid.adUnitCode.toLowerCase();
const adUnitIndex = message.adUnits.findIndex((adUnit) => {
Expand Down