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

PBjs Core : new event fired before add bid response #10685

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion modules/rtdModule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ const setEventsListeners = (function () {
[CONSTANTS.EVENTS.AUCTION_INIT]: ['onAuctionInitEvent'],
[CONSTANTS.EVENTS.AUCTION_END]: ['onAuctionEndEvent', getAdUnitTargeting],
[CONSTANTS.EVENTS.BID_RESPONSE]: ['onBidResponseEvent'],
[CONSTANTS.EVENTS.BID_REQUESTED]: ['onBidRequestEvent']
[CONSTANTS.EVENTS.BID_REQUESTED]: ['onBidRequestEvent'],
[CONSTANTS.EVENTS.BEFORE_ADD_BID_RESPONSE]: ['onBeforeAddBidResponseEvent']
}).forEach(([ev, [handler, preprocess]]) => {
events.on(ev, (args) => {
preprocess && preprocess(args);
Expand Down
2 changes: 1 addition & 1 deletion src/auction.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM
function acceptBidResponse(adUnitCode, bid) {
handleBidResponse(adUnitCode, bid, (done) => {
let bidResponse = getPreparedBidForAuction(bid);

events.emit(CONSTANTS.EVENTS.BEFORE_ADD_BID_RESPONSE, bidResponse);
matthieularere-msq marked this conversation as resolved.
Show resolved Hide resolved
if (FEATURES.VIDEO && bidResponse.mediaType === VIDEO) {
tryAddVideoBid(auctionInstance, bidResponse, done);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"AUCTION_DEBUG": "auctionDebug",
"BID_VIEWABLE": "bidViewable",
"STALE_RENDER": "staleRender",
"BILLABLE_EVENT": "billableEvent"
"BILLABLE_EVENT": "billableEvent",
"BEFORE_ADD_BID_RESPONSE": "beforeAddBidResponse"
},
"AD_RENDER_FAILED_REASON": {
"PREVENT_WRITING_ON_MAIN_DOCUMENT": "preventWritingOnMainDocument",
Expand Down
7 changes: 7 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,13 @@ describe('Unit: Prebid Module', function () {
events.on.restore();
});

it('should emit event EFORE_ADD_BID_RESPONSE when invoked', function () {
var callback = sinon.spy();
$$PREBID_GLOBAL$$.onEvent('beforeAddBidResponse', callback);
events.emit(CONSTANTS.EVENTS.BEFORE_ADD_BID_RESPONSE);
sinon.assert.calledOnce(callback);
});

describe('beforeRequestBids', function () {
let bidRequestedHandler;
let beforeRequestBidsHandler;
Expand Down