Skip to content

Commit

Permalink
Fix dfp gdpr parameter dupes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Jul 2, 2024
1 parent bb93b03 commit 6d77026
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
13 changes: 13 additions & 0 deletions libraries/dfpUtils/dfpUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {gdprDataHandler} from '../../src/consentHandler.js';

/** Safe defaults which work on pretty much all video calls. */
export const DEFAULT_DFP_PARAMS = {
env: 'vp',
Expand All @@ -11,3 +13,14 @@ export const DFP_ENDPOINT = {
host: 'securepubads.g.doubleclick.net',
pathname: '/gampad/ads'
}

export function gdprParams() {
const gdprConsent = gdprDataHandler.getConsentData();
const params = {};
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') { params.gdpr = Number(gdprConsent.gdprApplies); }
if (gdprConsent.consentString) { params.gdpr_consent = gdprConsent.consentString; }
if (gdprConsent.addtlConsent) { params.addtl_consent = gdprConsent.addtlConsent; }
}
return params;
}
14 changes: 4 additions & 10 deletions modules/bidViewability.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import {config} from '../src/config.js';
import * as events from '../src/events.js';
import { EVENTS } from '../src/constants.js';
import {EVENTS} from '../src/constants.js';
import {isFn, logWarn, triggerPixel} from '../src/utils.js';
import {getGlobal} from '../src/prebidGlobal.js';
import adapterManager, {gdprDataHandler, uspDataHandler, gppDataHandler} from '../src/adapterManager.js';
import adapterManager, {gppDataHandler, uspDataHandler} from '../src/adapterManager.js';
import {find} from '../src/polyfill.js';
import {gdprParams} from '../libraries/dfpUtils/dfpUtils.js';

const MODULE_NAME = 'bidViewability';
const CONFIG_ENABLED = 'enabled';
Expand All @@ -32,14 +33,7 @@ export let getMatchingWinningBidForGPTSlot = (globalModuleConfig, slot) => {

export let fireViewabilityPixels = (globalModuleConfig, bid) => {
if (globalModuleConfig[CONFIG_FIRE_PIXELS] === true && bid.hasOwnProperty(BID_VURL_ARRAY)) {
let queryParams = {};

const gdprConsent = gdprDataHandler.getConsentData();
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') { queryParams.gdpr = Number(gdprConsent.gdprApplies); }
if (gdprConsent.consentString) { queryParams.gdpr_consent = gdprConsent.consentString; }
if (gdprConsent.addtlConsent) { queryParams.addtl_consent = gdprConsent.addtlConsent; }
}
let queryParams = gdprParams();

const uspConsent = uspDataHandler.getConsentData();
if (uspConsent) { queryParams.us_privacy = uspConsent; }
Expand Down
12 changes: 3 additions & 9 deletions modules/dfpAdServerVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import {
import {config} from '../src/config.js';
import {getHook} from '../src/hook.js';
import {auctionManager} from '../src/auctionManager.js';
import {gdprDataHandler} from '../src/adapterManager.js';
import * as events from '../src/events.js';
import {EVENTS} from '../src/constants.js';
import {getPPID} from '../src/adserver.js';
import {getRefererInfo} from '../src/refererDetection.js';
import {CLIENT_SECTIONS} from '../src/fpd/oneClient.js';
import {DEFAULT_DFP_PARAMS, DFP_ENDPOINT} from '../libraries/dfpUtils/dfpUtils.js';
import {DEFAULT_DFP_PARAMS, DFP_ENDPOINT, gdprParams} from '../libraries/dfpUtils/dfpUtils.js';
/**
* @typedef {Object} DfpVideoParams
*
Expand Down Expand Up @@ -109,17 +108,12 @@ export function buildDfpVideoUrl(options) {
urlComponents.search,
derivedParams,
options.params,
{ cust_params: encodedCustomParams }
{ cust_params: encodedCustomParams },
gdprParams()
);

const descriptionUrl = getDescriptionUrl(bid, options, 'params');
if (descriptionUrl) { queryParams.description_url = descriptionUrl; }
const gdprConsent = gdprDataHandler.getConsentData();
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') { queryParams.gdpr = Number(gdprConsent.gdprApplies); }
if (gdprConsent.consentString) { queryParams.gdpr_consent = gdprConsent.consentString; }
if (gdprConsent.addtlConsent) { queryParams.addtl_consent = gdprConsent.addtlConsent; }
}

if (!queryParams.ppid) {
const ppid = getPPID();
Expand Down
13 changes: 3 additions & 10 deletions modules/dfpAdpod.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {submodule} from '../src/hook.js';
import {buildUrl, deepAccess, formatQS, logError, parseSizesInput} from '../src/utils.js';
import {auctionManager} from '../src/auctionManager.js';
import {DEFAULT_DFP_PARAMS, DFP_ENDPOINT} from '../libraries/dfpUtils/dfpUtils.js';
import {gdprDataHandler} from '../src/consentHandler.js';
import {DEFAULT_DFP_PARAMS, DFP_ENDPOINT, gdprParams} from '../libraries/dfpUtils/dfpUtils.js';
import {registerVideoSupport} from '../src/adServerManager.js';

export const adpodUtils = {};
Expand Down Expand Up @@ -75,16 +74,10 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) {
DEFAULT_DFP_PARAMS,
derivedParams,
params,
{ cust_params: encodedCustomParams }
{ cust_params: encodedCustomParams },
gdprParams(),
);

const gdprConsent = gdprDataHandler.getConsentData();
if (gdprConsent) {
if (typeof gdprConsent.gdprApplies === 'boolean') { queryParams.gdpr = Number(gdprConsent.gdprApplies); }
if (gdprConsent.consentString) { queryParams.gdpr_consent = gdprConsent.consentString; }
if (gdprConsent.addtlConsent) { queryParams.addtl_consent = gdprConsent.addtlConsent; }
}

const masterTag = buildUrl({
...DFP_ENDPOINT,
search: queryParams
Expand Down

0 comments on commit 6d77026

Please sign in to comment.