From 2b423e105dc61f0bb2fa4bc50259e9485e32bfbc Mon Sep 17 00:00:00 2001 From: Petre Damoc Date: Wed, 29 Jun 2022 15:29:50 +0200 Subject: [PATCH] Missena bidAdapter: pass gdpr data to sync frame (#8611) --- modules/missenaBidAdapter.js | 22 ++++++++- test/spec/modules/missenaBidAdapter_spec.js | 50 +++++++++++++++------ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/modules/missenaBidAdapter.js b/modules/missenaBidAdapter.js index 841f545e09c..2ec9d39fc5d 100644 --- a/modules/missenaBidAdapter.js +++ b/modules/missenaBidAdapter.js @@ -72,11 +72,29 @@ export const spec = { return bidResponses; }, - getUserSyncs: function (syncOptions, serverResponses) { + getUserSyncs: function ( + syncOptions, + serverResponses, + gdprConsent, + uspConsent + ) { if (!syncOptions.iframeEnabled) { return []; } - return [{ type: 'iframe', url: 'https://sync.missena.io/iframe' }]; + + let gdprParams = ''; + if ( + gdprConsent && + 'gdprApplies' in gdprConsent && + typeof gdprConsent.gdprApplies === 'boolean' + ) { + gdprParams = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${ + gdprConsent.consentString + }`; + } + return [ + { type: 'iframe', url: 'https://sync.missena.io/iframe' + gdprParams }, + ]; }, /** * Register bidder specific code, which will execute if bidder timed out after an auction diff --git a/test/spec/modules/missenaBidAdapter_spec.js b/test/spec/modules/missenaBidAdapter_spec.js index 21aa8aca217..157137b4730 100644 --- a/test/spec/modules/missenaBidAdapter_spec.js +++ b/test/spec/modules/missenaBidAdapter_spec.js @@ -133,25 +133,47 @@ describe('Missena Adapter', function () { }); describe('getUserSyncs', function () { - const expectedUserSyncs = [ - { type: 'iframe', url: 'https://sync.missena.io/iframe' }, - ]; - const serverResponses = []; + const syncFrameUrl = 'https://sync.missena.io/iframe'; + const consentString = 'sampleString'; + const iframeEnabledOptions = { + iframeEnabled: true, + }; + const iframeDisabledOptions = { + iframeEnabled: false, + }; it('should return userSync when iframeEnabled', function () { - const syncOptions = { - iframeEnabled: true, - }; - const userSyncs = spec.getUserSyncs(syncOptions, serverResponses); - expect(userSyncs).to.deep.equal(expectedUserSyncs); + const userSync = spec.getUserSyncs(iframeEnabledOptions, []); + + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(syncFrameUrl); }); it('should return empty array when iframeEnabled is false', function () { - const syncOptions = { - iframeEnabled: false, - }; - const userSyncs = spec.getUserSyncs(syncOptions, serverResponses); - expect(userSyncs).to.deep.equal([]); + const userSync = spec.getUserSyncs(iframeDisabledOptions, []); + expect(userSync.length).to.be.equal(0); + }); + + it('sync frame url should contain gdpr data when present', function () { + const userSync = spec.getUserSyncs(iframeEnabledOptions, [], { + gdprApplies: true, + consentString, + }); + const expectedUrl = `${syncFrameUrl}?gdpr=1&gdpr_consent=${consentString}`; + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(expectedUrl); + }); + it('sync frame url should contain gdpr data when present (gdprApplies false)', function () { + const userSync = spec.getUserSyncs(iframeEnabledOptions, [], { + gdprApplies: false, + consentString, + }); + const expectedUrl = `${syncFrameUrl}?gdpr=0&gdpr_consent=${consentString}`; + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(expectedUrl); }); }); });