-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adding schain info #26
Changes from 2 commits
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 |
---|---|---|
|
@@ -125,7 +125,11 @@ function _createServerRequest(bidRequest, gdprConsent = {}, uspConsent, pageUrl) | |
} ] | ||
} | ||
}; | ||
|
||
|
||
if(bidRequest.schain) { | ||
ttxRequest.source = _getSchainInfo(bidRequest.schain); | ||
} | ||
|
||
// Finally, set the openRTB 'test' param if this is to be a test bid | ||
if (params.test === 1) { | ||
ttxRequest.test = 1; | ||
|
@@ -152,6 +156,42 @@ function _createServerRequest(bidRequest, gdprConsent = {}, uspConsent, pageUrl) | |
} | ||
} | ||
|
||
function _getSchainInfo(schain) { | ||
if(_isValidSchain(schain)) { | ||
return { | ||
ext: { schain } | ||
} | ||
} else { | ||
utils.logWarn('[33Across Adapter] Invalid schain info passed'); | ||
return null; | ||
} | ||
} | ||
|
||
// We validate schain as follows: | ||
// - Complete status must be 0|1 | ||
// - Nodes must be defined and non-empty array | ||
// - Each node must contain all the required fields | ||
// The entire schain schain object is marked as invalid i.e. return false if any | ||
// of the above conditions fail. | ||
function _isValidSchain(schain) { | ||
//Check of nodes are valid | ||
if(!schain.nodes || !(schain.nodes.length > 0)) { | ||
return false; | ||
} | ||
|
||
//Check is complete status is valid | ||
if(schain.complete !== 0 && schain.complete !== 1) { | ||
return false; | ||
} | ||
|
||
// Check for required fields in nodes | ||
const requiredFields = ['asi', 'sid', 'hp']; | ||
|
||
return schain.nodes.every((node)=> { | ||
return requiredFields.every((field)=> node[field]); | ||
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. does empty string and 0 fail this check? 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. It should yes. The values of 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. Here's what the validation is based on https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md#openrtb-object-supplychain Too strict? 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 see, that make sense 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 am not sure how strictly we want to validate here. But this would pass if 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. Right that is true (no pun intended). Hmm I guess this only checks for truthy values. Should we enforce proper validation here? |
||
}); | ||
} | ||
|
||
// Sync object will always be of type iframe for TTX | ||
function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConsent }) { | ||
const ttxSettings = config.getConfig('ttxSettings'); | ||
|
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.
This is interesting. I wonder if we need to add this to our validation too for schain nodes.