Skip to content
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

Richaudience Bid Adapter: add new config UserSync #6523

Merged
merged 10 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions modules/richaudienceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ export const spec = {
var syncUrl = '';
var consent = '';

var raiSync = [];
msm0504 marked this conversation as resolved.
Show resolved Hide resolved

raiSync = raiGetSyncInclude(config);

if (gdprConsent && typeof gdprConsent.consentString === 'string' && typeof gdprConsent.consentString != 'undefined') {
consent = `consentString=${gdprConsent.consentString}`
}

if (syncOptions.iframeEnabled) {
if (syncOptions.iframeEnabled && raiSync.filter(e => e.raiIframe)[0].raiIframe != 'exclude') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If filter returns an empty array, this will result in a null pointer. Same issue on line 163

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved, now it is checked if it is empty.

syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand
if (consent != '') {
syncUrl += `&${consent}`
Expand All @@ -156,7 +160,7 @@ export const spec = {
});
}

if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0) {
if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.filter(e => e.raiImage)[0].raiImage != 'exclude') {
syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`;
if (consent != '') {
syncUrl += `&${consent}`
Expand Down Expand Up @@ -263,3 +267,26 @@ function raiGetResolution() {
}
return resolution;
}

function raiGetSyncInclude(config) {
try {
let raConfig = null;
let raiSync = [];
if (config.getConfig('userSync').filterSettings != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only check for null. If the value is undefined, the condition will evaluate true. Same issue on lines 277 and 282

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, now checked for undefined

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this was fixed on the other lines, but not this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved, i add undefined in this case

raConfig = config.getConfig('userSync').filterSettings
if (raConfig.iframe != null) {
if (raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*') {
raiSync.push({'raiIframe': raConfig.iframe.filter})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how raiSync is being used, this should be an object instead of an array. This would eliminate both the use of filter when getting values and the potential null pointer exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved, I modified the array and converted it into an object

}
}
if (raConfig.image != null) {
if (raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*') {
raiSync.push({'raiImage': raConfig.image.filter})
}
}
}
return raiSync;
} catch (e) {
return null;
}
}
Loading