Skip to content

Commit fce247d

Browse files
author
Adrian Dzida
committed
Pass qid to user sync (10.29.x legacy)
1 parent c05c22f commit fce247d

2 files changed

Lines changed: 168 additions & 139 deletions

File tree

modules/adqueryBidAdapter.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
deepSetValue,
1010
deepAccess
1111
} from '../src/utils.js';
12+
import { hasPurpose1Consent } from '../src/utils/gdpr.js';
1213

1314
/**
1415
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
@@ -41,14 +42,11 @@ export const spec = {
4142
*/
4243
isBidRequestValid: (bid) => {
4344
const video = bid.mediaTypes && bid.mediaTypes.video;
44-
if (video) {
45-
if (['instream', 'outstream'].includes(video.context)) {
46-
return !!(video.playerSize);
47-
}
48-
return false;
45+
if (video && ['instream', 'outstream'].includes(video.context)) {
46+
return !!(video.playerSize);
4947
}
5048

51-
return !!(bid && bid.params && bid.params.placementId && bid.mediaTypes.banner.sizes)
49+
return !!(bid && bid.params && bid.params.placementId && bid.mediaTypes.banner.sizes);
5250
},
5351

5452
/**
@@ -189,15 +187,15 @@ export const spec = {
189187
logInfo('onBidWon', bid);
190188

191189
if (bid.nurl) {
192-
triggerPixel(bid.nurl)
193-
return
190+
triggerPixel(bid.nurl);
191+
return;
194192
}
195193

196-
const copyOfBid = { ...bid }
194+
const copyOfBid = { ...bid };
197195

198196
const uuidMatch = copyOfBid.ad && typeof copyOfBid.ad === 'string' ? copyOfBid.ad.match(/data-uuid="([^"]*)"/) : null;
199197
copyOfBid.uuid = uuidMatch ? uuidMatch[1] : null;
200-
delete copyOfBid.ad
198+
delete copyOfBid.ad;
201199
const shortBidString = JSON.stringify(copyOfBid);
202200
const encodedBuf = window.btoa(shortBidString);
203201

@@ -249,10 +247,20 @@ export const spec = {
249247
*/
250248
getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => {
251249
logMessage('getUserSyncs', syncOptions, serverResponses, gdprConsent, uspConsent);
250+
if (!gdprConsent?.gdprApplies || !hasPurpose1Consent(gdprConsent)) {
251+
logMessage('no gdpr or purpose1 consent, no syncs');
252+
return [];
253+
}
254+
const qid = Array.isArray(serverResponses) ? serverResponses.map(r => deepAccess(r, 'body.data.qid')).find(Boolean) : null;
255+
if (!qid) {
256+
logMessage('no qid found in server responses');
257+
return [];
258+
}
252259
const syncData = {
253260
'gdpr': gdprConsent && gdprConsent.gdprApplies ? 1 : 0,
254261
'gdpr_consent': gdprConsent && gdprConsent.consentString ? gdprConsent.consentString : '',
255-
'ccpa_consent': uspConsent && uspConsent.uspConsent ? uspConsent.uspConsent : '',
262+
'ccpa_consent': uspConsent || '',
263+
'qid': qid,
256264
};
257265

258266
const syncUrlObject = {
@@ -306,28 +314,30 @@ function buildRequest(bid, bidderRequest, isVideo = false) {
306314
}
307315

308316
if (isVideo) {
309-
let baseRequest = bid.ortb2
317+
let baseRequest = bid.ortb2;
310318
let videoRequest = {
311319
...baseRequest,
312320
imp: [{
313321
id: bid.bidId,
314322
video: bid.ortb2Imp?.video || {},
315323
}]
316-
}
324+
};
317325

318326
deepSetValue(videoRequest, 'site.ext.bidder', bid.params);
319-
videoRequest.id = bid.bidId
327+
videoRequest.id = bid.bidId;
320328

321-
if (bidderRequest?.gdprConsent?.consentString) {
329+
if (bidderRequest?.gdprConsent?.gdprApplies != null) {
322330
deepSetValue(videoRequest, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies ? 1 : 0);
331+
}
332+
if (bidderRequest?.gdprConsent?.consentString) {
323333
deepSetValue(videoRequest, 'user.consent', bidderRequest.gdprConsent.consentString);
324334
}
325335
if (bidderRequest?.uspConsent) {
326336
deepSetValue(videoRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent);
327337
}
328338

329339
let currency = bid?.ortb2?.ext?.prebid?.adServerCurrency || "PLN";
330-
videoRequest.cur = [currency]
340+
videoRequest.cur = [currency];
331341

332342
let floorInfo;
333343
if (typeof bid.getFloor === 'function') {
@@ -341,11 +351,11 @@ function buildRequest(bid, bidderRequest, isVideo = false) {
341351
const bidfloorcur = floorInfo?.currency;
342352

343353
if (bidfloor && bidfloorcur) {
344-
videoRequest.imp[0].video.bidfloor = bidfloor
345-
videoRequest.imp[0].video.bidfloorcur = bidfloorcur
354+
videoRequest.imp[0].video.bidfloor = bidfloor;
355+
videoRequest.imp[0].video.bidfloorcur = bidfloorcur;
346356
}
347357

348-
return videoRequest
358+
return videoRequest;
349359
}
350360

351361
return {

0 commit comments

Comments
 (0)