cleanup
Interfaces
ICleanupModule
Cleanup Module
Cleans up special formats if enabled (on user navigation and ad reload), especially developed for SPAs.
The configs can either provide CSS selectors of the html elements that are part of the special/out-of-page formats and should be deleted or JS as single strings that contain the logic to remove the special format.
Please note: if you want to execute more than one statement/line of JS, please provide each line as separate string in the array. Like this we make sure that each line is tried to be executed and if one fails, the next one is still executed. Only global variables can be accessed in the JS strings!
Integration
In your index.ts import the Cleanup module and register the module.
moli.registerModule(createCleanup());
Dspx Skin
The dspx wallpaper can be cleaned as shown in the example above. The dspx_start_called.dspxPageSkin.unload() function is called to remove the wallpaper from the page.
Dspx itself also sets a global variable dspx_start_called.counter on the window object. This variable is used to count the number of times the skin has been loaded.
Dspx unloads the skin itself, if the counter holds a value greater than 1 in order to prevent multiple loads on the page.
In SPAs, a value greater than 1 can happen as soon as a user navigates to a sub-page where the wallpaper ad slot is available and refreshed. If we try to unload() a second time, the dspx script crashes. Therefore we have to reset the counter to 0 after each clean-up.
Extends
IModule
Properties
description
readonlydescription:string
Inherited from
IModule.description
moduleType
readonlymoduleType:string
Inherited from
IModule.moduleType
name
readonlyname:string
Inherited from
IModule.name
Methods
cleanUp()
cleanUp(
context,configs):void
Parameters
• context: AdPipelineContext
• configs: CleanupConfig[]
Returns
void
config__()
config__():
null|Object
If the module has some sort of configuration this can be fetched with this method
Returns
null | Object
Inherited from
IModule.config__
configureSteps__()
configureSteps__():
ConfigureStep[]
Returns a list of steps that should be executed in the ad pipeline.
Returns
ConfigureStep[]
Inherited from
IModule.configureSteps__
configure__()
configure__(
moduleConfig?):void
Initialize the module with the given module configuration. Depending on the configuration the module may become active or inactive.
Parameters
• moduleConfig?: ModulesConfig
Returns
void
Inherited from
IModule.configure__
initSteps__()
initSteps__():
InitStep[]
Returns a list of steps that should be executed in the ad pipeline.
Returns
InitStep[]
Inherited from
IModule.initSteps__
prebidBidsBackHandler__()?
optionalprebidBidsBackHandler__():PrebidBidsBackHandler[]
This method is called in the bidsBackHandler of prebid.
A module may provide those callbacks if it needs to alter the requests send to the ad server.
The auctionEnd event cannot be used for this, as there's no guarantee the event handler
will run before the requestAds step.
Note: Amazon TAM (A9) also has a callback that could be used for similar things. Unfortunately
does the callback not provide the necessary information to implement any meaningful
business logic. Especially the cpm parameter and bidder
The callback receives additional information coming from the ad pipeline run.
Note: These callbacks should not perform any initialization code or only be created once as this array will be accessed on every pbjs.requestBids() callback.
Use cases
The generic-skin module provides prebid bids back handlers to block certain ad units from
being requested.
Returns
PrebidBidsBackHandler[]
See
- https://docs.prebid.org/dev-docs/publisher-api-reference/requestBids.html
- https://ams.amazon.com/webpublisher/uam/docs/web-integration-documentation/integration-guide/javascript-guide/api-reference.html#apstagfetchbids
Inherited from
IModule.prebidBidsBackHandler__
prepareRequestAdsSteps__()
prepareRequestAdsSteps__():
PrepareRequestAdsStep[]
Returns a list of steps that should be executed in the ad pipeline.
Returns
PrepareRequestAdsStep[]
Inherited from
IModule.prepareRequestAdsSteps__
requestBidsSteps__()?
optionalrequestBidsSteps__():RequestBidsStep[]
Returns a list of steps that should be executed in the ad pipeline.
This step is optional, as should have been all steps to reduce implementation complexity of modules.
Note: prebid and amazon tam (a9) maybe implemented as modules in the future as they add those steps to the ad pipeline.
Returns
RequestBidsStep[]
Inherited from
IModule.requestBidsSteps__
Functions
createCleanup()
createCleanup():
ICleanupModule