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 9 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
26 changes: 13 additions & 13 deletions integrationExamples/gpt/gdpr_hello_world.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,37 @@
<script>
var PREBID_TIMEOUT = 700;
var FAILSAFE_TIMEOUT = 2500;

var adUnits = [{
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
sizes: [[300, 250], [300,600]]
}
},

// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]

}];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

</script>

<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
Expand All @@ -130,7 +130,7 @@
timeout: PREBID_TIMEOUT
});
});

function sendAdserverRequest() {
if (pbjs.adserverRequestSent) return;
pbjs.adserverRequestSent = true;
Expand All @@ -141,23 +141,23 @@
});
});
}

setTimeout(function() {
sendAdserverRequest();
console.log('timeout in main pbjs fired');
}, FAILSAFE_TIMEOUT);
</script>

</script>
<script>
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
Expand Down
49 changes: 46 additions & 3 deletions modules/richaudienceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const spec = {
buildRequests: function (validBidRequests, bidderRequest) {
return validBidRequests.map(bid => {
var payload = {
bidfloor: bid.params.bidfloor,
bidfloor: raiGetFloor(bid, config),
ifa: bid.params.ifa,
pid: bid.params.pid,
supplyType: bid.params.supplyType,
Expand Down 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.raiIframe != 'exclude') {
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.raiImage != 'exclude') {
syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`;
if (consent != '') {
syncUrl += `&${consent}`
Expand Down Expand Up @@ -263,3 +267,42 @@ 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 && typeof raConfig.iframe != 'undefined') {
raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raiSync.raiIframe = raConfig.iframe.filter : raiSync.raiIframe = 'exclude';
msm0504 marked this conversation as resolved.
Show resolved Hide resolved
}
if (raConfig.image != null && typeof raConfig.image != 'undefined') {
raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raiSync.raiImage = raConfig.image.filter : raiSync.raiImage = 'exclude';
}
}
return raiSync;
} catch (e) {
return null;
}
}

function raiGetFloor(bid, config) {
try {
let raiFloor;
if (bid.params.bidfloor != null) {
raiFloor = bid.params.bidfloor;
} else if (typeof bid.getFloor == 'function') {
let floorSpec = bid.getFloor({
currency: config.getConfig('currency.adServerCurrency'),
mediaType: bid.mediaType.banner ? 'banner' : 'video',
size: '*'
})

raiFloor = floorSpec.floor;
}
return raiFloor
} catch (e) {
return 0
}
}
Loading