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

Greenbids Analytics : send cpm on any valid bid #12174

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
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
28 changes: 27 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,27 @@ 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 : {},
...(status === BIDDER_STATUS.BID ? {
cpm: bid.cpm,
currency: bid.currency
} : {}),
};
},
/**
* @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
8 changes: 6 additions & 2 deletions test/spec/modules/greenbidsAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,17 @@ describe('Greenbids Prebid AnalyticsAdapter Testing', function () {
bidder: 'greenbids',
isTimeout: false,
hasBid: true,
params: {}
params: {},
cpm: 0.1,
currency: 'USD',
},
{
bidder: 'greenbidsx',
isTimeout: false,
hasBid: true,
params: {'placement ID': 12784}
params: { 'placement ID': 12784 },
cpm: 0.08,
currency: 'USD',
}
]
},
Expand Down