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 compatibility to GPP #11022

Merged
merged 18 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 28 additions & 3 deletions modules/richaudienceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const spec = {
referer: (typeof bidderRequest.refererInfo.page != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.page) : null),
numIframes: (typeof bidderRequest.refererInfo.numIframes != 'undefined' ? bidderRequest.refererInfo.numIframes : null),
transactionId: bid.ortb2Imp?.ext?.tid,
timeout: config.getConfig('bidderTimeout'),
timeout: bidderRequest.timeout || 600,
user: raiSetEids(bid),
demand: raiGetDemandType(bid),
videoData: raiGetVideoInfo(bid),
Expand All @@ -75,6 +75,18 @@ export const spec = {
}
}

if (bidderRequest?.gppConsent) {
payload.privacy = {
gpp: bidderRequest.gppConsent.gppString,
gpp_sid: bidderRequest.gppConsent.applicableSections
}
} else if (bidderRequest?.ortb2?.regs?.gpp) {
payload.privacy = {
gpp: bidderRequest.ortb2.regs.gpp,
gpp_sid: bidderRequest.ortb2.regs.gpp_sid
}
}

var payloadString = JSON.stringify(payload);

var endpoint = 'https://shb.richaudience.com/hb/';
Expand Down Expand Up @@ -145,12 +157,13 @@ export const spec = {
* @param {gdprConsent} GPDR consent object
* @returns {Array}
*/
getUserSyncs: function (syncOptions, serverResponses, gdprConsent) {
getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) {
const syncs = [];

var rand = Math.floor(Math.random() * 9999999999);
var syncUrl = '';
var consent = '';
var consentGPP = '';

var raiSync = {};

Expand All @@ -160,11 +173,20 @@ export const spec = {
consent = `consentString=${gdprConsent.consentString}`
}

// GPP Consent
if (gppConsent?.gppString && gppConsent?.applicableSections?.length) {
consentGPP = 'gpp=' + encodeURIComponent(gppConsent.gppString);
consentGPP += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(','));
}

if (syncOptions.iframeEnabled && raiSync.raiIframe != 'exclude') {
syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand
if (consent != '') {
syncUrl += `&${consent}`
}
if (consentGPP != '') {
syncUrl += `&${consentGPP}`
}
syncs.push({
type: 'iframe',
url: syncUrl
Expand All @@ -176,6 +198,9 @@ export const spec = {
if (consent != '') {
syncUrl += `&${consent}`
}
if (consentGPP != '') {
syncUrl += `&${consentGPP}`
}
syncs.push({
type: 'image',
url: syncUrl
Expand Down Expand Up @@ -346,7 +371,7 @@ function raiGetTimeoutURL(data) {

url = url.replace('[timeout_publisher]', timeout)
url = url.replace('[placement_hash]', params[0].pid)
if (REFERER != null) {
if (document.location.host != null) {
url = url.replace('[domain]', document.location.host)
}
return url
Expand Down
43 changes: 41 additions & 2 deletions test/spec/modules/richaudienceBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe('Richaudience adapter tests', function () {
expect(requestContent.sizes[3]).to.have.property('w').and.to.equal(970);
expect(requestContent.sizes[3]).to.have.property('h').and.to.equal(250);
expect(requestContent).to.have.property('transactionId').and.to.equal('29df2112-348b-4961-8863-1b33684d95e6');
expect(requestContent).to.have.property('timeout').and.to.equal(3000);
expect(requestContent).to.have.property('timeout').and.to.equal(600);
expect(requestContent).to.have.property('numIframes').and.to.equal(0);
expect(typeof requestContent.scr_rsl === 'string')
expect(typeof requestContent.cpuc === 'number')
Expand Down Expand Up @@ -916,14 +916,21 @@ describe('Richaudience adapter tests', function () {
it('onTimeout exist as a function', () => {
expect(spec.onTimeout).to.exist.and.to.be.a('function');
});
it('should send timeout', function () {
it('should send timeouts', function () {
spec.onTimeout(DEFAULT_PARAMS_VIDEO_TIMEOUT);
expect(utils.triggerPixel.called).to.equal(true);
expect(utils.triggerPixel.firstCall.args[0]).to.equal('https://s.richaudience.com/err/?ec=6&ev=3000&pla=ADb1f40rmi&int=PREBID&pltfm=&node=&dm=localhost:9876');
});
});

describe('userSync', function () {
let sandbox;
beforeEach(function () {
sandbox = sinon.sandbox.create();
});
afterEach(function() {
sandbox.restore();
});
it('Verifies user syncs iframe include', function () {
config.setConfig({
'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}}}
Expand Down Expand Up @@ -1261,5 +1268,37 @@ describe('Richaudience adapter tests', function () {
}, [], {consentString: '', gdprApplies: true});
expect(syncs).to.have.lengthOf(0);
});

it('Verifies user syncs iframe/image include with GPP', function () {
config.setConfig({
'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}}}
})

var syncs = spec.getUserSyncs({iframeEnabled: true}, [BID_RESPONSE], {
gppString: 'DBABL~BVVqAAEABgA.QA',
applicableSections: [7]},
);
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('iframe');

config.setConfig({
'userSync': {filterSettings: {image: {bidders: '*', filter: 'include'}}}
})

var syncs = spec.getUserSyncs({pixelEnabled: true}, [BID_RESPONSE], {
gppString: 'DBABL~BVVqAAEABgA.QA',
applicableSections: [7, 5]},
);
expect(syncs).to.have.lengthOf(1);
expect(syncs[0].type).to.equal('image');
});

it('Verifies user syncs URL image include with GPP', function () {
const gppConsent = { gppString: 'DBACMYA~CP5P4cAP5P4cAPoABAESAlEAAAAAAAAAAAAAA2QAQA2ADZABADYAAAAA.QA2QAQA2AAAA.IA2QAQA2AAAA~BP5P4cAP5P4cAPoABABGBACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA', applicableSections: [0] };
const result = spec.getUserSyncs({pixelEnabled: true}, undefined, undefined, undefined, gppConsent);
expect(result).to.deep.equal([{
type: 'image', url: `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=http%3A%2F%2Fdomain.com&gpp=DBACMYA~CP5P4cAP5P4cAPoABAESAlEAAAAAAAAAAAAAA2QAQA2ADZABADYAAAAA.QA2QAQA2AAAA.IA2QAQA2AAAA~BP5P4cAP5P4cAPoABABGBACAAAAAAAAAAAAAAAAAAA.YAAAAAAAAAA&gpp_sid=0`
}]);
});
})
});