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 37a9554e9a4..5e2a5e1bff5 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,
@@ -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.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.raiImage != 'exclude') {
syncUrl = `https://sync.richaudience.com/bf7c142f4339da0278e83698a02b0854/?referrer=${REFERER}`;
if (consent != '') {
syncUrl += `&${consent}`
@@ -263,3 +267,42 @@ function raiGetResolution() {
}
return resolution;
}
+
+function raiGetSyncInclude(config) {
+ try {
+ let raConfig = null;
+ let raiSync = {};
+ 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') {
+ raiSync.raiIframe = raConfig.iframe.bidders == 'richaudience' || raConfig.iframe.bidders == '*' ? raConfig.iframe.filter : 'exclude';
+ }
+ if (raConfig.image != null && typeof raConfig.image != 'undefined') {
+ raiSync.raiImage = raConfig.image.bidders == 'richaudience' || raConfig.image.bidders == '*' ? raConfig.image.filter : '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
+ }
+}
diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js
index 5deb2463523..72410b71fb2 100644
--- a/test/spec/modules/richaudienceBidAdapter_spec.js
+++ b/test/spec/modules/richaudienceBidAdapter_spec.js
@@ -788,76 +788,343 @@ 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);
});
+ it('Verifies user syncs iframe exclude', function () {
+ config.setConfig({
+ 'userSync': {filterSettings: {iframe: {bidders: '*', filter: 'exclude'}}}
+ })
- 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
+ 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);
+ });
+ })
});