Skip to content

Commit

Permalink
Beachfront Bid Adapter : GPP support (#10227)
Browse files Browse the repository at this point in the history
* add gpp support to beachfront adapter

* bump beachfront adapter version

---------

Co-authored-by: John Salis <john@beachfront.com>
  • Loading branch information
jsalis and John Salis authored Jul 18, 2023
1 parent be29701 commit 33a5fe2
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 8 deletions.
38 changes: 32 additions & 6 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ import {
isFn,
logWarn,
parseSizesInput,
parseUrl
parseUrl,
formatQS
} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {Renderer} from '../src/Renderer.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {find, includes} from '../src/polyfill.js';

const ADAPTER_VERSION = '1.19';
const ADAPTER_VERSION = '1.20';
const ADAPTER_NAME = 'BFIO_PREBID';
const OUTSTREAM = 'outstream';
const CURRENCY = 'USD';

export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id=';
export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display';
export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js';
export const SYNC_IFRAME_ENDPOINT = 'https://sync.bfmio.com/sync_iframe';
export const SYNC_IMAGE_ENDPOINT = 'https://sync.bfmio.com/syncb';

export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement', 'skip', 'skipmin', 'skipafter'];
export const DEFAULT_MIMES = ['video/mp4', 'application/javascript'];
Expand Down Expand Up @@ -152,11 +155,22 @@ export const spec = {
}
},

getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '') {
let syncs = [];
getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = {}) {
let { gdprApplies, consentString = '' } = gdprConsent;
let { gppString = '', applicableSections = [] } = gppConsent;
let bannerResponse = find(serverResponses, (res) => isArray(res.body));

let syncs = [];
let params = {
id: appId,
gdpr: gdprApplies ? 1 : 0,
gc: consentString,
gce: 1,
us_privacy: uspConsent,
gpp: gppString,
gpp_sid: Array.isArray(applicableSections) ? applicableSections.join(',') : ''
};

if (bannerResponse) {
if (syncOptions.iframeEnabled) {
bannerResponse.body
Expand All @@ -171,12 +185,12 @@ export const spec = {
} else if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
url: `https://sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}`
url: `${SYNC_IFRAME_ENDPOINT}?ifg=1&${formatQS(params)}`
});
} else if (syncOptions.pixelEnabled) {
syncs.push({
type: 'image',
url: `https://sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}`
url: `${SYNC_IMAGE_ENDPOINT}?pid=144&${formatQS(params)}`
});
}

Expand Down Expand Up @@ -404,6 +418,12 @@ function createVideoRequestData(bid, bidderRequest) {
deepSetValue(payload, 'user.ext.consent', consentString);
}

if (bidderRequest && bidderRequest.gppConsent) {
let { gppString, applicableSections } = bidderRequest.gppConsent;
deepSetValue(payload, 'regs.gpp', gppString);
deepSetValue(payload, 'regs.gpp_sid', applicableSections);
}

if (bid.schain) {
deepSetValue(payload, 'source.ext.schain', bid.schain);
}
Expand Down Expand Up @@ -459,6 +479,12 @@ function createBannerRequestData(bids, bidderRequest) {
payload.gdprConsent = consentString;
}

if (bidderRequest && bidderRequest.gppConsent) {
let { gppString, applicableSections } = bidderRequest.gppConsent;
payload.gpp = gppString;
payload.gppSid = applicableSections;
}

if (bids[0] && bids[0].schain) {
payload.schain = bids[0].schain;
}
Expand Down
37 changes: 35 additions & 2 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js';
import { config } from 'src/config.js';
import { parseUrl, deepAccess } from 'src/utils.js';
import { parseUrl } from 'src/utils.js';

describe('BeachfrontAdapter', function () {
let bidRequests;
Expand Down Expand Up @@ -296,6 +295,23 @@ describe('BeachfrontAdapter', function () {
expect(data.user.ext.consent).to.equal(consentString);
});

it('must add GPP consent data to the request', function () {
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = { video: {} };
const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
const applicableSections = [1, 2, 3];
const bidderRequest = {
gppConsent: {
gppString,
applicableSections
}
};
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.regs.gpp).to.equal(gppString);
expect(data.regs.gpp_sid).to.deep.equal(applicableSections);
});

it('must add schain data to the request', () => {
const schain = {
ver: '1.0',
Expand Down Expand Up @@ -517,6 +533,23 @@ describe('BeachfrontAdapter', function () {
expect(data.gdprConsent).to.equal(consentString);
});

it('must add GPP consent data to the request', function () {
const bidRequest = bidRequests[0];
bidRequest.mediaTypes = { banner: {} };
const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
const applicableSections = [1, 2, 3];
const bidderRequest = {
gppConsent: {
gppString,
applicableSections
}
};
const requests = spec.buildRequests([ bidRequest ], bidderRequest);
const data = requests[0].data;
expect(data.gpp).to.equal(gppString);
expect(data.gppSid).to.deep.equal(applicableSections);
});

it('must add schain data to the request', () => {
const schain = {
ver: '1.0',
Expand Down

0 comments on commit 33a5fe2

Please sign in to comment.