Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seedtag Bid Adapter: add coppa #9202

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions modules/seedtagBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isArray, _map, triggerPixel } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { VIDEO, BANNER } from '../src/mediaTypes.js'
import { config } from '../src/config.js';

const BIDDER_CODE = 'seedtag';
const SEEDTAG_ALIAS = 'st';
Expand Down Expand Up @@ -177,7 +178,7 @@ function ttfb() {
return ttfb >= 0 && ttfb <= performance.now() ? ttfb : 0;
}

export function getTimeoutUrl (data) {
export function getTimeoutUrl(data) {
let queryParams = '';
if (
isArray(data) && data[0] &&
Expand Down Expand Up @@ -235,7 +236,6 @@ export const spec = {
if (gdprApplies !== undefined) payload['ga'] = gdprApplies;
payload['cd'] = bidderRequest.gdprConsent.consentString;
}

if (bidderRequest.uspConsent) {
payload['uspConsent'] = bidderRequest.uspConsent
}
Expand All @@ -244,6 +244,11 @@ export const spec = {
payload.schain = validBidRequests[0].schain;
}

let coppa = config.getConfig('coppa')
if (coppa) {
payload.coppa = coppa
}

const payloadString = JSON.stringify(payload)
return {
method: 'POST',
Expand All @@ -258,10 +263,10 @@ export const spec = {
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function(serverResponse) {
interpretResponse: function (serverResponse) {
const serverBody = serverResponse.body;
if (serverBody && serverBody.bids && isArray(serverBody.bids)) {
return _map(serverBody.bids, function(bid) {
return _map(serverBody.bids, function (bid) {
return buildBidResponse(bid);
});
} else {
Expand Down
44 changes: 34 additions & 10 deletions test/spec/modules/seedtagBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js';
import * as utils from 'src/utils.js';
import { config } from '../../../src/config.js';

const PUBLISHER_ID = '0000-0000-01';
const ADUNIT_ID = '000000';
Expand Down Expand Up @@ -357,6 +358,29 @@ describe('Seedtag Adapter', function () {
});
});

describe('COPPA param', function () {
it('should add COPPA param to payload when prebid config has parameter COPPA equal to true', function () {
config.setConfig({ coppa: true })

const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);
expect(data.coppa).to.equal(true);
})

it('should not add COPPA param to payload when prebid config has parameter COPPA equal to false', function () {
config.setConfig({ coppa: false })

const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);
expect(data.coppa).to.be.undefined;
})

it('should not add COPPA param to payload when prebid config has not parameter COPPA', function () {
const request = spec.buildRequests(validBidRequests, bidderRequest);
const data = JSON.parse(request.data);
expect(data.coppa).to.be.undefined;
})
})
describe('schain param', function () {
it('should add schain to payload when exposed on validBidRequest', function () {
// https://github.com/prebid/Prebid.js/blob/master/modules/schain.md#sample-code-for-passing-the-schain-object
Expand Down Expand Up @@ -536,11 +560,11 @@ describe('Seedtag Adapter', function () {
const timeoutUrl = getTimeoutUrl(timeoutData);
expect(timeoutUrl).to.equal(
'https://s.seedtag.com/se/hb/timeout?publisherToken=' +
params.publisherId +
'&adUnitId=' +
params.adUnitId +
'&timeout=' +
timeout
params.publisherId +
'&adUnitId=' +
params.adUnitId +
'&timeout=' +
timeout
);
});

Expand All @@ -552,11 +576,11 @@ describe('Seedtag Adapter', function () {
expect(
utils.triggerPixel.calledWith(
'https://s.seedtag.com/se/hb/timeout?publisherToken=' +
params.publisherId +
'&adUnitId=' +
params.adUnitId +
'&timeout=' +
timeout
params.publisherId +
'&adUnitId=' +
params.adUnitId +
'&timeout=' +
timeout
)
).to.equal(true);
});
Expand Down