diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 36513aeda47..b63e31266fb 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -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), @@ -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/'; @@ -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 = {}; @@ -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 @@ -176,6 +198,9 @@ export const spec = { if (consent != '') { syncUrl += `&${consent}` } + if (consentGPP != '') { + syncUrl += `&${consentGPP}` + } syncs.push({ type: 'image', url: syncUrl @@ -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 diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 20c60ca328a..d2b173f53df 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -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') @@ -916,7 +916,7 @@ 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'); @@ -924,6 +924,13 @@ describe('Richaudience adapter tests', function () { }); 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'}}} @@ -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` + }]); + }); }) });