@@ -2,22 +2,9 @@ import { deepAccess, isPlainObject, isArray, replaceAuctionPrice, isFn } from '.
2
2
import { config } from '../src/config.js' ;
3
3
import { registerBidder } from '../src/adapters/bidderFactory.js' ;
4
4
const BIDDER_CODE = 'apacdex' ;
5
- const CONFIG = {
6
- 'apacdex' : {
7
- 'ENDPOINT' : 'https://useast.quantumdex.io/auction/apacdex' ,
8
- 'USERSYNC' : 'https://sync.quantumdex.io/usersync/apacdex'
9
- } ,
10
- 'quantumdex' : {
11
- 'ENDPOINT' : 'https://useast.quantumdex.io/auction/quantumdex' ,
12
- 'USERSYNC' : 'https://sync.quantumdex.io/usersync/quantumdex'
13
- } ,
14
- 'valueimpression' : {
15
- 'ENDPOINT' : 'https://useast.quantumdex.io/auction/adapter' ,
16
- 'USERSYNC' : 'https://sync.quantumdex.io/usersync/adapter'
17
- }
18
- } ;
5
+ const ENDPOINT = 'https://useast.quantumdex.io/auction/pbjs'
6
+ const USERSYNC = 'https://sync.quantumdex.io/usersync/pbjs'
19
7
20
- var bidderConfig = CONFIG [ BIDDER_CODE ] ;
21
8
var bySlotTargetKey = { } ;
22
9
var bySlotSizesCount = { }
23
10
@@ -56,8 +43,6 @@ export const spec = {
56
43
let test ;
57
44
let bids = [ ] ;
58
45
59
- bidderConfig = CONFIG [ validBidRequests [ 0 ] . bidder ] ;
60
-
61
46
test = config . getConfig ( 'debug' ) ;
62
47
63
48
validBidRequests . forEach ( bidReq => {
@@ -156,13 +141,14 @@ export const spec = {
156
141
transactionId : bid . transactionId ,
157
142
sizes : bid . sizes ,
158
143
bidId : bid . bidId ,
144
+ adUnitCode : bid . adUnitCode ,
159
145
bidFloor : bid . bidFloor
160
146
}
161
147
} ) ;
162
148
163
149
return {
164
150
method : 'POST' ,
165
- url : bidderConfig . ENDPOINT ,
151
+ url : ENDPOINT ,
166
152
data : payload ,
167
153
withCredentials : true ,
168
154
bidderRequests : bids
@@ -209,32 +195,47 @@ export const spec = {
209
195
} ) ;
210
196
return bidResponses ;
211
197
} ,
212
- getUserSyncs : function ( syncOptions , serverResponses ) {
198
+ getUserSyncs : function ( syncOptions , serverResponses , gdprConsent , uspConsent ) {
213
199
const syncs = [ ] ;
214
- try {
215
- if ( syncOptions . iframeEnabled ) {
216
- syncs . push ( {
217
- type : 'iframe' ,
218
- url : bidderConfig . USERSYNC
219
- } ) ;
200
+ if ( hasPurpose1Consent ( gdprConsent ) ) {
201
+ let params = '' ;
202
+ if ( gdprConsent && typeof gdprConsent . consentString === 'string' ) {
203
+ // add 'gdpr' only if 'gdprApplies' is defined
204
+ if ( typeof gdprConsent . gdprApplies === 'boolean' ) {
205
+ params = `?gdpr=${ Number ( gdprConsent . gdprApplies ) } &gdpr_consent=${ gdprConsent . consentString } ` ;
206
+ } else {
207
+ params = `?gdpr_consent=${ gdprConsent . consentString } ` ;
208
+ }
220
209
}
221
- if ( serverResponses . length > 0 && serverResponses [ 0 ] . body && serverResponses [ 0 ] . body . pixel ) {
222
- serverResponses [ 0 ] . body . pixel . forEach ( px => {
223
- if ( px . type === 'image' && syncOptions . pixelEnabled ) {
224
- syncs . push ( {
225
- type : 'image' ,
226
- url : px . url
227
- } ) ;
228
- }
229
- if ( px . type === 'iframe' && syncOptions . iframeEnabled ) {
230
- syncs . push ( {
231
- type : 'iframe' ,
232
- url : px . url
233
- } ) ;
234
- }
235
- } ) ;
210
+ if ( uspConsent ) {
211
+ params += `${ params ? '&' : '?' } us_privacy=${ encodeURIComponent ( uspConsent ) } ` ;
236
212
}
237
- } catch ( e ) { }
213
+
214
+ try {
215
+ if ( syncOptions . iframeEnabled ) {
216
+ syncs . push ( {
217
+ type : 'iframe' ,
218
+ url : USERSYNC + params
219
+ } ) ;
220
+ }
221
+ if ( serverResponses . length > 0 && serverResponses [ 0 ] . body && serverResponses [ 0 ] . body . pixel ) {
222
+ serverResponses [ 0 ] . body . pixel . forEach ( px => {
223
+ if ( px . type === 'image' && syncOptions . pixelEnabled ) {
224
+ syncs . push ( {
225
+ type : 'image' ,
226
+ url : px . url + params
227
+ } ) ;
228
+ }
229
+ if ( px . type === 'iframe' && syncOptions . iframeEnabled ) {
230
+ syncs . push ( {
231
+ type : 'iframe' ,
232
+ url : px . url + params
233
+ } ) ;
234
+ }
235
+ } ) ;
236
+ }
237
+ } catch ( e ) { }
238
+ }
238
239
return syncs ;
239
240
}
240
241
} ;
@@ -377,4 +378,14 @@ function getBidFloor(bid) {
377
378
return null ;
378
379
}
379
380
381
+ function hasPurpose1Consent ( gdprConsent ) {
382
+ let result = true ;
383
+ if ( gdprConsent ) {
384
+ if ( gdprConsent . gdprApplies && gdprConsent . apiVersion === 2 ) {
385
+ result = ! ! ( deepAccess ( gdprConsent , 'vendorData.purpose.consents.1' ) === true ) ;
386
+ }
387
+ }
388
+ return result ;
389
+ }
390
+
380
391
registerBidder ( spec ) ;
0 commit comments