Skip to content

Commit

Permalink
11071 Prevent Events system import in bidders (#11548)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Komorski <marcinkomorski@Marcins-MacBook-Pro.local>
  • Loading branch information
mkomorski and Marcin Komorski authored May 29, 2024
1 parent a72ef9f commit aaa6d37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,15 @@ module.exports = {
// code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain.
files: 'plugins/*/**/*.js',
parser: 'esprima'
},
{
files: '**BidAdapter.js',
rules: {
'no-restricted-imports': [
'error', {
patterns: ["**/src/events.js"]
}
]
}
}])
};
22 changes: 9 additions & 13 deletions modules/holidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
logMessage,
triggerPixel,
} from '../src/utils.js';
import * as events from '../src/events.js';
import { EVENTS } from '../src/constants.js';
import {BANNER} from '../src/mediaTypes.js';

import {registerBidder} from '../src/adapters/bidderFactory.js';
Expand All @@ -19,8 +17,6 @@ const TIME_TO_LIVE = 300
const TMAX = 500
let wurlMap = {}

events.on(EVENTS.BID_WON, bidWonHandler)

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
Expand Down Expand Up @@ -120,6 +116,15 @@ export const spec = {

return syncs
},

onBidWon(bid) {
const wurl = getWurl(bid.requestId)
if (wurl) {
logMessage(`Invoking image pixel for wurl on BID_WIN: "${wurl}"`)
triggerPixel(wurl)
removeWurl(bid.requestId)
}
}
}

function getImp(bid) {
Expand Down Expand Up @@ -176,13 +181,4 @@ function getWurl(requestId) {
}
}

function bidWonHandler(bid) {
const wurl = getWurl(bid.requestId)
if (wurl) {
logMessage(`Invoking image pixel for wurl on BID_WIN: "${wurl}"`)
triggerPixel(wurl)
removeWurl(bid.requestId)
}
}

registerBidder(spec)

0 comments on commit aaa6d37

Please sign in to comment.