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

Nextmillenium bid adapter: Collection of statistics data #9265

Merged
merged 27 commits into from
Dec 12, 2022
Merged
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
31 changes: 30 additions & 1 deletion modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { getRefererInfo } from '../src/refererDetection.js';
const BIDDER_CODE = 'nextMillennium';
const ENDPOINT = 'https://pbs.nextmillmedia.com/openrtb2/auction';
const TEST_ENDPOINT = 'https://test.pbs.nextmillmedia.com/openrtb2/auction';
const REPORT_ENDPOINT = 'https://report2.hb.brainlyads.com/statistics/metric';
const SYNC_ENDPOINT = 'https://cookies.nextmillmedia.com/sync?';
const TIME_TO_LIVE = 360;
const VIDEO_PARAMS = [
Expand All @@ -31,9 +32,13 @@ const VIDEO_PARAMS = [

const EXPIRENCE_WURL = 20 * 60000;
const wurlMap = {};
cleanWurl();

events.on(CONSTANTS.EVENTS.BID_TIMEOUT, eventHandler(CONSTANTS.EVENTS.BID_TIMEOUT));
events.on(CONSTANTS.EVENTS.BID_RESPONSE, eventHandler(CONSTANTS.EVENTS.BID_RESPONSE));
events.on(CONSTANTS.EVENTS.BID_REQUESTED, eventHandler(CONSTANTS.EVENTS.BID_REQUESTED));
events.on(CONSTANTS.EVENTS.NO_BID, eventHandler(CONSTANTS.EVENTS.NO_BID));
events.on(CONSTANTS.EVENTS.BID_WON, bidWonHandler);
cleanWurl();

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -328,6 +333,30 @@ function getWurl({auctionId, requestId}) {
return wurlMap[key] && wurlMap[key].wurl;
}

function eventHandler(eventName) {
const _eventHandler = getEventHandler(eventName);
if (eventName == CONSTANTS.EVENTS.BID_TIMEOUT) {
return bids => {
if (!Array.isArray(bids)) return

for (let bid of bids) {
_eventHandler(bid);
};
}
};

return _eventHandler;
}

function getEventHandler(eventName) {
return bid => {
const bidder = bid.bidder || bid.bidderCode;
if (bidder != BIDDER_CODE) return;

triggerPixel(`${REPORT_ENDPOINT}?event=${eventName}&bidder=${bidder}&source=pbjs`);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patmmccann I corrected the code and now all tests pass. I don't know how to test this new functionality, all the added code does is set an event handler for the bidRequested, bidResponse, noBid and bidTimeout events. Internally, it generates a url and sends data to the server via the utils.triggerPixel function.
If you still insist on tests, I will try to add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patmmccann Can you please tell me what you think about it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no unit tests on this pr, we're hesitant to assign a reviewer before the pr is complete

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeking some feedback from others on how to test, will get back to you


function bidWonHandler(bid) {
const {auctionId, requestId} = bid;
const wurl = getWurl({auctionId, requestId});
Expand Down