-
Notifications
You must be signed in to change notification settings - Fork 2.2k
BidViewability: Refactored the init function #13141
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
BidViewability: Refactored the init function #13141
Conversation
Tread carefully! This PR adds 1 linter error (possibly disabled through directives):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the module initialization for BidViewability by replacing the AUCTION_INIT event listener with a configuration callback.
- Replaces event-driven initialization with a config.getConfig callback.
- Updates the handling of the global module configuration during initialization.
Comments suppressed due to low confidence (1)
modules/bidViewability.js:93
- The callback from config.getConfig does not provide an event object, causing a reference error when accessing 'event'. Remove or replace the use of 'event' based on the intended behavior.
impressionViewableHandler(globalModuleConfig, event.slot, event);
// do nothing if module-config.enabled is not set to true | ||
// this way we are adding a way for bidders to know (using pbjs.getConfig('bidViewability').enabled === true) whether this module is added in build and is enabled | ||
if (globalModuleConfig[CONFIG_ENABLED] !== true) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OP does not call this a bugfix, but I think the previous version would attach duplicate GPT event listeners on every auction. This fix, to be complete, should detach it here (when the module is turned off) IMO.
https://developers.google.com/publisher-tag/reference#googletag.Service.removeEventListener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the changes as per the GPT document. where we are removing the listener before firing the handler.
Also consumed the event object to extract the slot to handle Co-pilot's suggestion.
@dgirardi Can you please check this |
Type of change
Description of change
Previously, the module was initialized by adding a listener to the AUCTION_INIT event. With this refactor, the listener is registered during module initialization, improving efficiency and aligning with standard initialization practices.