From 08298ad10a6953a6b1462d32e2d4ecb58218ac36 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 5 Apr 2021 11:53:13 +0200 Subject: [PATCH 01/10] Add new config UserSync --- modules/richaudienceBidAdapter.js | 31 +- .../modules/richaudienceBidAdapter_spec.js | 400 +++++++++++++++--- 2 files changed, 366 insertions(+), 65 deletions(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 37a9554e9a4..d132da340bf 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -141,11 +141,15 @@ export const spec = { var syncUrl = ''; var consent = ''; + var raiSync = []; + + 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') { syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand if (consent != '') { syncUrl += `&${consent}` @@ -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}` @@ -263,3 +267,26 @@ function raiGetResolution() { } return resolution; } + +function raiGetSyncInclude(config) { + try { + let raConfig = null; + let raiSync = []; + if (config.getConfig('userSync').filterSettings != null) { + raConfig = config.getConfig('userSync').filterSettings + if (raConfig.iframe != null) { + if (raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*') { + raiSync.push({'raiIframe': raConfig.iframe.filter}) + } + } + if (raConfig.image != null) { + if (raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*') { + raiSync.push({'raiImage': raConfig.image.filter}) + } + } + } + return raiSync; + } catch (e) { + return null; + } +} diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 5deb2463523..24c6f4eefa1 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -788,76 +788,350 @@ describe('Richaudience adapter tests', function () { })).to.equal(true); }); - it('Verifies user syncs iframe', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true + describe('userSync', function (){ + it('Verifies user syncs iframe include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true + it('Verifies user syncs iframe exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + }); - expect(syncs).to.have.lengthOf(0); - syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [], {consentString: '', gdprApplies: false}); - expect(syncs).to.have.lengthOf(1); + it('Verifies user syncs image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {image:{bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); - syncs = spec.getUserSyncs({ - iframeEnabled: false - }, [], {consentString: '', gdprApplies: true}); - expect(syncs).to.have.lengthOf(0); + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); - config.setConfig({ - consentManagement: { - cmpApi: 'iab', - timeout: 5000, - allowAuctionWithoutConsent: true, + syncs = spec.getUserSyncs({ + iframeEnabled: false, pixelEnabled: true - } + }, [], { + consentString: null, + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); }); - }); - it('Verifies user syncs image', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: '', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [], { - consentString: null, - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - }); + it('Verifies user syncs image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {image:{bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: '', + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: true + }, [], { + consentString: null, + referer: 'http://domain.com', + gdprApplies: true + }) + expect(syncs).to.have.lengthOf(0); + }); + + it('Verifies user syncs iframe/image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'},image:{bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + + }); + + it('Verifies user syncs iframe/image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'},image:{bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + + }); + + it('Verifies user syncs iframe exclude / image include', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'},image:{bidders: '*', filter: 'include'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('image'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + + }); + + it('Verifies user syncs iframe include / image exclude', function () { + config.setConfig({ + 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'},image:{bidders: '*', filter: 'exclude'}}} + }) + + var syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, + ); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true, + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }); + expect(syncs).to.have.lengthOf(0); + + syncs = spec.getUserSyncs({ + iframeEnabled: true, + pixelEnabled: true + }, [], {consentString: '', gdprApplies: false}); + expect(syncs).to.have.lengthOf(1); + + syncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, [], {consentString: '', gdprApplies: true}); + expect(syncs).to.have.lengthOf(0); + + }); + }) }); From 3380e52263d18459ba8959545a35f2df6ad7c337 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 5 Apr 2021 12:12:52 +0200 Subject: [PATCH 02/10] Solved lint errors --- .../modules/richaudienceBidAdapter_spec.js | 77 +++++++++---------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 24c6f4eefa1..95d7e4e0836 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -788,17 +788,17 @@ describe('Richaudience adapter tests', function () { })).to.equal(true); }); - describe('userSync', function (){ + describe('userSync', function () { it('Verifies user syncs iframe include', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ - iframeEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + iframeEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('iframe'); @@ -828,18 +828,16 @@ describe('Richaudience adapter tests', function () { iframeEnabled: false, }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); - it('Verifies user syncs iframe exclude', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ iframeEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', gdprApplies: true}, ); expect(syncs).to.have.lengthOf(0); @@ -869,12 +867,11 @@ describe('Richaudience adapter tests', function () { iframeEnabled: false, }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); it('Verifies user syncs image include', function () { config.setConfig({ - 'userSync': {filterSettings: {image:{bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: { image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -913,7 +910,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: {image:{bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: { image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -949,15 +946,15 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe/image include', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'},image:{bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('iframe'); @@ -991,20 +988,19 @@ describe('Richaudience adapter tests', function () { pixelEnabled: false }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); it('Verifies user syncs iframe/image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'},image:{bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(0); @@ -1037,20 +1033,19 @@ describe('Richaudience adapter tests', function () { pixelEnabled: false }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); it('Verifies user syncs iframe exclude / image include', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'exclude'},image:{bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('image'); @@ -1084,20 +1079,19 @@ describe('Richaudience adapter tests', function () { pixelEnabled: false }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); it('Verifies user syncs iframe include / image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: {iframe:{bidders: '*', filter: 'include'},image:{bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ - iframeEnabled: true, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + iframeEnabled: true, + pixelEnabled: true + }, [BID_RESPONSE], { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(1); expect(syncs[0].type).to.equal('iframe'); @@ -1131,7 +1125,6 @@ describe('Richaudience adapter tests', function () { pixelEnabled: false }, [], {consentString: '', gdprApplies: true}); expect(syncs).to.have.lengthOf(0); - }); }) }); From c36df4de036242109367ea0a5991318b80fd1d49 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 5 Apr 2021 12:27:41 +0200 Subject: [PATCH 03/10] Solved lint errors 2 --- .../modules/richaudienceBidAdapter_spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 95d7e4e0836..8f8912d90e2 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -791,7 +791,7 @@ describe('Richaudience adapter tests', function () { describe('userSync', function () { it('Verifies user syncs iframe include', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -835,10 +835,10 @@ describe('Richaudience adapter tests', function () { }) var syncs = spec.getUserSyncs({ - iframeEnabled: true + iframeEnabled: true }, [BID_RESPONSE], { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true}, + gdprApplies: true}, ); expect(syncs).to.have.lengthOf(0); @@ -871,7 +871,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs image include', function () { config.setConfig({ - 'userSync': {filterSettings: { image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings:{ image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -910,7 +910,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: { image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings:{ image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -946,7 +946,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe/image include', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -992,7 +992,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe/image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -1037,7 +1037,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe exclude / image include', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -1083,7 +1083,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe include / image exclude', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ From 041dc9d4bd0a244cdeceb807ac4fabba1ac7acac Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 5 Apr 2021 12:31:16 +0200 Subject: [PATCH 04/10] Solved lint errors 3 --- test/spec/modules/richaudienceBidAdapter_spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 8f8912d90e2..72410b71fb2 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -791,7 +791,7 @@ describe('Richaudience adapter tests', function () { describe('userSync', function () { it('Verifies user syncs iframe include', function () { config.setConfig({ - 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -831,7 +831,7 @@ describe('Richaudience adapter tests', function () { }); it('Verifies user syncs iframe exclude', function () { config.setConfig({ - 'userSync': {filterSettings: { iframe: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -871,7 +871,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs image include', function () { config.setConfig({ - 'userSync': {filterSettings:{ image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: {image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -910,7 +910,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs image exclude', function () { config.setConfig({ - 'userSync': {filterSettings:{ image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: {image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -946,7 +946,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe/image include', function () { config.setConfig({ - 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -992,7 +992,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe/image exclude', function () { config.setConfig({ - 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ @@ -1037,7 +1037,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe exclude / image include', function () { config.setConfig({ - 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}, image: {bidders: '*', filter: 'include'}}} }) var syncs = spec.getUserSyncs({ @@ -1083,7 +1083,7 @@ describe('Richaudience adapter tests', function () { it('Verifies user syncs iframe include / image exclude', function () { config.setConfig({ - 'userSync': {filterSettings:{ iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} + 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'include'}, image: {bidders: '*', filter: 'exclude'}}} }) var syncs = spec.getUserSyncs({ From 9f3da46d418ad952c1116d959939fef60f747dc8 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 12 Apr 2021 12:02:00 +0200 Subject: [PATCH 05/10] Add changes --- integrationExamples/gpt/gdpr_hello_world.html | 26 ++++++------ modules/richaudienceBidAdapter.js | 40 +++++++++++++------ 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/integrationExamples/gpt/gdpr_hello_world.html b/integrationExamples/gpt/gdpr_hello_world.html index de0630178f1..2d70af8d34f 100644 --- a/integrationExamples/gpt/gdpr_hello_world.html +++ b/integrationExamples/gpt/gdpr_hello_world.html @@ -82,7 +82,7 @@ - + + + - +

Prebid.js Test

Div-1
diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index d132da340bf..5f672f0faa6 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -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, @@ -149,7 +149,7 @@ export const spec = { consent = `consentString=${gdprConsent.consentString}` } - if (syncOptions.iframeEnabled && raiSync.filter(e => e.raiIframe)[0].raiIframe != 'exclude') { + if (syncOptions.iframeEnabled && raiSync.raiIframe != 'exclude') { syncUrl = 'https://sync.richaudience.com/dcf3528a0b8aa83634892d50e91c306e/?ord=' + rand if (consent != '') { syncUrl += `&${consent}` @@ -160,7 +160,7 @@ export const spec = { }); } - if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.filter(e => e.raiImage)[0].raiImage != 'exclude') { + if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.raiImage != 'exclude') { syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`; if (consent != '') { syncUrl += `&${consent}` @@ -271,18 +271,14 @@ function raiGetResolution() { function raiGetSyncInclude(config) { try { let raConfig = null; - let raiSync = []; + let raiSync = {}; if (config.getConfig('userSync').filterSettings != null) { raConfig = config.getConfig('userSync').filterSettings - if (raConfig.iframe != null) { - if (raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*') { - raiSync.push({'raiIframe': raConfig.iframe.filter}) - } + if (raConfig.iframe != null && typeof raConfig.iframe != 'undefined') { + raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raiSync.raiIframe = raConfig.iframe.filter : raiSync.raiIframe = 'exclude'; } - if (raConfig.image != null) { - if (raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*') { - raiSync.push({'raiImage': raConfig.image.filter}) - } + 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; @@ -290,3 +286,23 @@ function raiGetSyncInclude(config) { 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 + } +} From 3f509d837634c3a2361145b8d81b53821756698a Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 12 Apr 2021 12:15:17 +0200 Subject: [PATCH 06/10] Add changes 2 --- modules/richaudienceBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 5f672f0faa6..9f127b38cda 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -158,7 +158,7 @@ export const spec = { type: 'iframe', url: syncUrl }); - } + } if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.raiImage != 'exclude') { syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`; From 110a40f367e3dd525ec6249756a197eecd2cf2b9 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 12 Apr 2021 12:17:16 +0200 Subject: [PATCH 07/10] Add changes 3 --- modules/richaudienceBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 9f127b38cda..5f672f0faa6 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -158,7 +158,7 @@ export const spec = { type: 'iframe', url: syncUrl }); - } + } if (syncOptions.pixelEnabled && REFERER != null && syncs.length == 0 && raiSync.raiImage != 'exclude') { syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`; From 7b648d96d91068dba576fcbe9503e80a052760ea Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 12 Apr 2021 15:06:02 +0200 Subject: [PATCH 08/10] Add changes 4 --- modules/richaudienceBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 5f672f0faa6..2386e242806 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -128,7 +128,7 @@ export const spec = { }, /*** * User Syncs - * + * * @param {syncOptions} Publisher prebid configuration * @param {serverResponses} Response from the server * @param {gdprConsent} GPDR consent object From 095c6e1be94e991c2e77f275eafa10115fb3fee3 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Mon, 12 Apr 2021 15:09:08 +0200 Subject: [PATCH 09/10] Add changes 5 --- modules/richaudienceBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 2386e242806..5f672f0faa6 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -128,7 +128,7 @@ export const spec = { }, /*** * User Syncs - * + * * @param {syncOptions} Publisher prebid configuration * @param {serverResponses} Response from the server * @param {gdprConsent} GPDR consent object From 26339ddf944fc5fde0efa274314c089f44de19f4 Mon Sep 17 00:00:00 2001 From: sgimenez Date: Wed, 14 Apr 2021 16:31:12 +0200 Subject: [PATCH 10/10] Solved issues --- modules/richaudienceBidAdapter.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index 5f672f0faa6..5e2a5e1bff5 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -141,7 +141,7 @@ export const spec = { var syncUrl = ''; var consent = ''; - var raiSync = []; + var raiSync = {}; raiSync = raiGetSyncInclude(config); @@ -272,13 +272,13 @@ function raiGetSyncInclude(config) { try { let raConfig = null; let raiSync = {}; - if (config.getConfig('userSync').filterSettings != null) { + if (config.getConfig('userSync').filterSettings != null && typeof config.getConfig('userSync').filterSettings != 'undefined') { 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'; + raiSync.raiIframe = raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raConfig.iframe.filter : 'exclude'; } if (raConfig.image != null && typeof raConfig.image != 'undefined') { - raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raiSync.raiImage = raConfig.image.filter : raiSync.raiImage = 'exclude'; + raiSync.raiImage = raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raConfig.image.filter : 'exclude'; } } return raiSync;