Skip to content

Commit

Permalink
Missena bidAdapter: pass gdpr data to sync frame (#8611)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdamoc authored Jun 29, 2022
1 parent 86399d9 commit 2b423e1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 16 deletions.
22 changes: 20 additions & 2 deletions modules/missenaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 36 additions & 14 deletions test/spec/modules/missenaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit 2b423e1

Please sign in to comment.