From 33a5fe20269c2c0a06b6d96e6c67a95bdc8ef4f0 Mon Sep 17 00:00:00 2001 From: John Salis Date: Tue, 18 Jul 2023 09:56:35 -0400 Subject: [PATCH] Beachfront Bid Adapter : GPP support (#10227) * add gpp support to beachfront adapter * bump beachfront adapter version --------- Co-authored-by: John Salis --- modules/beachfrontBidAdapter.js | 38 ++++++++++++++++--- .../spec/modules/beachfrontBidAdapter_spec.js | 37 +++++++++++++++++- 2 files changed, 67 insertions(+), 8 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 37de8e637a9..658fc30b43b 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -7,14 +7,15 @@ 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'; @@ -22,6 +23,8 @@ 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']; @@ -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 @@ -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)}` }); } @@ -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); } @@ -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; } diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 4e30b822a61..c0994985aae 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -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; @@ -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', @@ -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',