Skip to content

Commit 5f6dab3

Browse files
6012: Fix for passing US Privacy string in buildVideoUrl and buildAdpodVideoUrl (#6075)
* added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * pass USP consent string in dfpVideoUrl and dfpAdpodVideoUrl * added test cases
1 parent b9a4cc6 commit 5f6dab3

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

modules/dfpAdServerVideo.js

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, bui
88
import { config } from '../src/config.js';
99
import { getHook, submodule } from '../src/hook.js';
1010
import { auctionManager } from '../src/auctionManager.js';
11+
import { uspDataHandler } from '../src/adapterManager.js';
1112
import events from '../src/events.js';
1213
import CONSTANTS from '../src/constants.json';
1314

@@ -100,6 +101,9 @@ export function buildDfpVideoUrl(options) {
100101
const descriptionUrl = getDescriptionUrl(bid, options, 'params');
101102
if (descriptionUrl) { queryParams.description_url = descriptionUrl; }
102103

104+
const uspConsent = uspDataHandler.getConsentData();
105+
if (uspConsent) { queryParams.us_privacy = uspConsent; }
106+
103107
return buildUrl({
104108
protocol: 'https',
105109
host: 'securepubads.g.doubleclick.net',
@@ -183,6 +187,9 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) {
183187
{ cust_params: encodedCustomParams }
184188
);
185189

190+
const uspConsent = uspDataHandler.getConsentData();
191+
if (uspConsent) { queryParams.us_privacy = uspConsent; }
192+
186193
const masterTag = buildUrl({
187194
protocol: 'https',
188195
host: 'securepubads.g.doubleclick.net',

test/spec/modules/dfpAdServerVideo_spec.js

+43
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as utils from 'src/utils.js';
77
import { config } from 'src/config.js';
88
import { targeting } from 'src/targeting.js';
99
import { auctionManager } from 'src/auctionManager.js';
10+
import { uspDataHandler } from 'src/adapterManager.js';
1011
import * as adpod from 'modules/adpod.js';
1112
import { server } from 'test/mocks/xhr.js';
1213

@@ -115,6 +116,44 @@ describe('The DFP video support module', function () {
115116
expect(customParams).to.have.property('hb_cache_id', bid.videoCacheKey);
116117
});
117118

119+
it('should include the us_privacy key when USP Consent is available', function () {
120+
let uspDataHandlerStub = sinon.stub(uspDataHandler, 'getConsentData');
121+
uspDataHandlerStub.returns('1YYY');
122+
123+
const bidCopy = utils.deepClone(bid);
124+
bidCopy.adserverTargeting = Object.assign(bidCopy.adserverTargeting, {
125+
hb_adid: 'ad_id',
126+
});
127+
128+
const url = parse(buildDfpVideoUrl({
129+
adUnit: adUnit,
130+
bid: bidCopy,
131+
params: {
132+
'iu': 'my/adUnit'
133+
}
134+
}));
135+
const queryObject = utils.parseQS(url.query);
136+
expect(queryObject.us_privacy).to.equal('1YYY');
137+
uspDataHandlerStub.restore();
138+
});
139+
140+
it('should not include the us_privacy key when USP Consent is not available', function () {
141+
const bidCopy = utils.deepClone(bid);
142+
bidCopy.adserverTargeting = Object.assign(bidCopy.adserverTargeting, {
143+
hb_adid: 'ad_id',
144+
});
145+
146+
const url = parse(buildDfpVideoUrl({
147+
adUnit: adUnit,
148+
bid: bidCopy,
149+
params: {
150+
'iu': 'my/adUnit'
151+
}
152+
}));
153+
const queryObject = utils.parseQS(url.query);
154+
expect(queryObject.us_privacy).to.equal(undefined);
155+
});
156+
118157
describe('special targeting unit test', function () {
119158
const allTargetingData = {
120159
'hb_format': 'video',
@@ -350,6 +389,8 @@ describe('The DFP video support module', function () {
350389

351390
it('should return masterTag url', function() {
352391
amStub.returns(getBidsReceived());
392+
let uspDataHandlerStub = sinon.stub(uspDataHandler, 'getConsentData');
393+
uspDataHandlerStub.returns('1YYY');
353394
let url;
354395
parse(buildAdpodVideoUrl({
355396
code: 'adUnitCode-1',
@@ -380,10 +421,12 @@ describe('The DFP video support module', function () {
380421
expect(queryParams).to.have.property('unviewed_position_start', '1');
381422
expect(queryParams).to.have.property('url');
382423
expect(queryParams).to.have.property('cust_params');
424+
expect(queryParams).to.have.property('us_privacy', '1YYY');
383425

384426
const custParams = utils.parseQS(decodeURIComponent(queryParams.cust_params));
385427
expect(custParams).to.have.property('hb_cache_id', '123');
386428
expect(custParams).to.have.property('hb_pb_cat_dur', '15.00_395_15s,15.00_406_30s,10.00_395_15s');
429+
uspDataHandlerStub.restore();
387430
}
388431
});
389432

0 commit comments

Comments
 (0)