-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Data Controller Module: initial release #8484
Changes from 1 commit
fcf32fb
4a08291
5aecd26
5332b4c
9f7622b
217c366
1d49b72
b4f7174
798b918
f5b14be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/** | ||
* This module sets filters the data(userEIDs and SDA) based on the configuration. | ||
* @module modules/dataController | ||
*/ | ||
|
||
/** | ||
* @interface dataControllerModule | ||
*/ | ||
|
||
/** | ||
* @function? | ||
* @summary return real time data | ||
* @name dataControllerModule#filterEIDs | ||
* @param {Object} bidRequest | ||
*/ | ||
|
||
/** | ||
* @function? | ||
* @summary return real time data | ||
* @name dataControllerModule#filterSDA | ||
* @param {Object} bidRequest | ||
*/ | ||
|
||
import {config} from '../../src/config.js'; | ||
import {module, getHook} from '../../src/hook.js'; | ||
import {processBidderRequests} from '../../src/adapters/bidderFactory.js'; | ||
|
||
let submodules = []; | ||
const MODULE_NAME = 'dataController'; | ||
let dataControllerConfig; | ||
|
||
/** | ||
* enable submodule in data Controller Module | ||
* @param {dataController} submodule | ||
*/ | ||
export function registerSubmodules(submodule) { | ||
submodules.push(submodule); | ||
} | ||
|
||
export function init(bidderRequests) { | ||
submodules.forEach(submodule => { | ||
filterData(submodule, bidderRequests) | ||
}); | ||
} | ||
|
||
export function filterData(submodule, bidRequest) { | ||
dataControllerConfig = config.getConfig(MODULE_NAME); | ||
|
||
if (!dataControllerConfig) { | ||
processBidderRequests.getHooks({hook: processBidderRequestHook}).remove(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to keep configuration and business logic separate - this will get confusing fast as complexity increases. (IMO it makes more sense to turn the module off from the same place you turn it on). |
||
return; | ||
} | ||
|
||
if (dataControllerConfig.filterEIDwhenSDA && dataControllerConfig.filterSADwhenEID) { | ||
processBidderRequests.getHooks({hook: processBidderRequestHook}).remove(); | ||
return; | ||
} | ||
if (dataControllerConfig.filterEIDwhenSDA) { | ||
let filterEIDs = submodule.filterEIDs(bidRequest) | ||
if(filterEIDs) { | ||
config.setConfig({'dcUsersAsEids': filterEIDs}); | ||
} | ||
} else if (dataControllerConfig.filterSADwhenEID) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @patmmccann do we want to have the param as "supressSDAwhenEID"/"supressEIDwhenSDA"? Filter would be more generic rather than suppress. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All references to SAD should be changed to SDA There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||
let bidderConfig = submodule.filterSDA(bidRequest); | ||
if (bidderConfig) { | ||
config.setBidderConfig(bidderConfig); | ||
} | ||
} | ||
processBidderRequests.getHooks({hook: processBidderRequestHook}).remove(); | ||
} | ||
|
||
/** | ||
* BidderRequests hook to intiate module and reset data object. | ||
*/ | ||
function processBidderRequestHook(fn, specDetails, bidRequest) { | ||
init(bidRequest); | ||
// Removes hook after run | ||
processBidderRequests.getHooks({hook: processBidderRequestHook}).remove(); | ||
} | ||
|
||
/** | ||
* Sets bidderRequests hook | ||
*/ | ||
function setupHook() { | ||
getHook('processBidderRequests').before(processBidderRequestHook); | ||
} | ||
|
||
setupHook(); | ||
|
||
module(MODULE_NAME, registerSubmodules); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Overview | ||
|
||
``` | ||
Module Name: Data Controller Module | ||
``` | ||
|
||
# Description | ||
|
||
This module will filter EIDs and SDA based on the configurations. | ||
The filtered EIDs are stored in 'dcUsersAsEids' configuration and filtered SDA are updated in bidder configuration. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this detail no longer relevant? I am not seeing any of this stored any longer, so if that is the case, can this be removed |
||
|
||
Sub module object with the following keys: | ||
|
||
| param name | type | Scope | Description | Params | | ||
| :------------ | :------------ | :------ | :------ | :------ | | ||
| filterEIDwhenSDA | function | optional | Filters user EIDs based on SDA | bidrequest | | ||
| filterSADwhenEID | function | optional | Filters SDA based on configured EIDs | bidrequest | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
|
||
# Module Control Configuration | ||
|
||
``` | ||
|
||
pbjs.setConfig({ | ||
dataController: { | ||
filterEIDwhenSDA: ['*'] | ||
filterSADwhenEID: ['id5-sync.com'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
} | ||
}); | ||
|
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,6 +296,14 @@ export function newBidder(spec) { | |
* @param onCompletion {function()} invoked once when all bid requests have been processed | ||
*/ | ||
export const processBidderRequests = hook('sync', function (spec, bids, bidderRequest, ajax, wrapCallback, {onRequest, onResponse, onError, onBid, onCompletion}) { | ||
|
||
let updatedUserAsEids = config.getConfig('dcUsersAsEids'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it's using Why not do this directly from the hook added by the module? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dgirardi I have update this module to be self contained. |
||
if (updatedUserAsEids && updatedUserAsEids[bidderRequest.bidderCode]) { | ||
bids.forEach(bid => { | ||
bid.userIdAsEids = updatedUserAsEids[bidderRequest.bidderCode]; | ||
}) | ||
}; | ||
|
||
let requests = spec.buildRequests(bids, bidderRequest); | ||
if (!requests || requests.length === 0) { | ||
onCompletion(); | ||
|
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.
why is this planning for submodules? I'm not sure I understand the scope of the feature - going by this proposal it seems self-contained to me.
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.
@dgirardi The proposal mentions about Publisher having ability to define the rules to filter EID and SDA hence providing submodule.
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.
I don't understand - publishers do not have access to the module system and they wouldn't be able to add a submodule (they would have to fork the repo).
I would expect them to define the rules with
setConfig
, and I don't see the need multiple submodules to read that config unless it makes sense to want only part of that proposal - but I don't see anything in it that suggests that.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.
Will take a look