Skip to content

Commit

Permalink
add coppa param to payload (#9202)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmenarDevST authored Nov 8, 2022
1 parent e19b7f1 commit 8e023b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
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

0 comments on commit 8e023b1

Please sign in to comment.