1
1
import { registerBidder } from '../src/adapters/bidderFactory.js' ;
2
2
import { BANNER } from '../src/mediaTypes.js' ;
3
- import { buildUrl , logInfo , parseSizesInput , triggerPixel } from '../src/utils.js' ;
3
+ import { buildUrl , logInfo , logMessage , parseSizesInput , triggerPixel } from '../src/utils.js' ;
4
4
5
5
/**
6
6
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest } BidRequest
@@ -14,7 +14,9 @@ const ADQUERY_GVLID = 902;
14
14
const ADQUERY_BIDDER_CODE = 'adquery' ;
15
15
const ADQUERY_BIDDER_DOMAIN_PROTOCOL = 'https' ;
16
16
const ADQUERY_BIDDER_DOMAIN = 'bidder.adquery.io' ;
17
- const ADQUERY_USER_SYNC_DOMAIN = ADQUERY_BIDDER_DOMAIN_PROTOCOL + '://' + ADQUERY_BIDDER_DOMAIN + '/prebid/userSync?1=1' ;
17
+ const ADQUERY_STATIC_DOMAIN_PROTOCOL = 'https' ;
18
+ const ADQUERY_STATIC_DOMAIN = 'api.adquery.io' ;
19
+ const ADQUERY_USER_SYNC_DOMAIN = ADQUERY_BIDDER_DOMAIN ;
18
20
const ADQUERY_DEFAULT_CURRENCY = 'PLN' ;
19
21
const ADQUERY_NET_REVENUE = true ;
20
22
const ADQUERY_TTL = 360 ;
@@ -26,7 +28,6 @@ export const spec = {
26
28
supportedMediaTypes : [ BANNER ] ,
27
29
28
30
/**
29
- * f
30
31
* @param {object } bid
31
32
* @return {boolean }
32
33
*/
@@ -41,10 +42,18 @@ export const spec = {
41
42
*/
42
43
buildRequests : ( bidRequests , bidderRequest ) => {
43
44
const requests = [ ] ;
45
+
46
+ let adqueryRequestUrl = buildUrl ( {
47
+ protocol : ADQUERY_BIDDER_DOMAIN_PROTOCOL ,
48
+ hostname : ADQUERY_BIDDER_DOMAIN ,
49
+ pathname : '/prebid/bid' ,
50
+ // search: params
51
+ } ) ;
52
+
44
53
for ( let i = 0 , len = bidRequests . length ; i < len ; i ++ ) {
45
54
const request = {
46
55
method : 'POST' ,
47
- url : ADQUERY_BIDDER_DOMAIN_PROTOCOL + '://' + ADQUERY_BIDDER_DOMAIN + '/prebid/bid' ,
56
+ url : adqueryRequestUrl , // ADQUERY_BIDDER_DOMAIN_PROTOCOL + '://' + ADQUERY_BIDDER_DOMAIN + '/prebid/bid',
48
57
data : buildRequest ( bidRequests [ i ] , bidderRequest ) ,
49
58
options : {
50
59
withCredentials : false ,
@@ -62,8 +71,8 @@ export const spec = {
62
71
* @return {Bid[] }
63
72
*/
64
73
interpretResponse : ( response , request ) => {
65
- logInfo ( request ) ;
66
- logInfo ( response ) ;
74
+ logMessage ( request ) ;
75
+ logMessage ( response ) ;
67
76
68
77
const res = response && response . body && response . body . data ;
69
78
let bidResponses = [ ] ;
@@ -125,7 +134,6 @@ export const spec = {
125
134
*/
126
135
onBidWon : ( bid ) => {
127
136
logInfo ( 'onBidWon' , bid ) ;
128
-
129
137
const bidString = JSON . stringify ( bid ) ;
130
138
let copyOfBid = JSON . parse ( bidString ) ;
131
139
delete copyOfBid . ad ;
@@ -169,21 +177,48 @@ export const spec = {
169
177
} ) ;
170
178
triggerPixel ( adqueryRequestUrl ) ;
171
179
} ,
180
+ /**
181
+ * Retrieves user synchronization URLs based on provided options and consents.
182
+ *
183
+ * @param {object } syncOptions - Options for synchronization.
184
+ * @param {object[] } serverResponses - Array of server responses.
185
+ * @param {object } gdprConsent - GDPR consent object.
186
+ * @param {object } uspConsent - USP consent object.
187
+ * @returns {object[] } - Array of synchronization URLs.
188
+ */
172
189
getUserSyncs : ( syncOptions , serverResponses , gdprConsent , uspConsent ) => {
173
- let syncUrl = ADQUERY_USER_SYNC_DOMAIN ;
174
- if ( gdprConsent && gdprConsent . consentString ) {
175
- if ( typeof gdprConsent . gdprApplies === 'boolean' ) {
176
- syncUrl += `&gdpr=${ Number ( gdprConsent . gdprApplies ) } &gdpr_consent=${ gdprConsent . consentString } ` ;
177
- } else {
178
- syncUrl += `&gdpr=0&gdpr_consent=${ gdprConsent . consentString } ` ;
179
- }
190
+ logMessage ( 'getUserSyncs' , syncOptions , serverResponses , gdprConsent , uspConsent ) ;
191
+ let syncData = {
192
+ 'gdpr' : gdprConsent && gdprConsent . gdprApplies ? 1 : 0 ,
193
+ 'gdpr_consent' : gdprConsent && gdprConsent . consentString ? gdprConsent . consentString : '' ,
194
+ 'ccpa_consent' : uspConsent && uspConsent . uspConsent ? uspConsent . uspConsent : '' ,
195
+ } ;
196
+
197
+ if ( window . qid ) { // only for new users (new qid)
198
+ syncData . qid = window . qid ;
180
199
}
181
- if ( uspConsent && uspConsent . consentString ) {
182
- syncUrl += `&ccpa_consent=${ uspConsent . consentString } ` ;
200
+
201
+ let syncUrlObject = {
202
+ protocol : ADQUERY_BIDDER_DOMAIN_PROTOCOL ,
203
+ hostname : ADQUERY_USER_SYNC_DOMAIN ,
204
+ pathname : '/prebid/userSync' ,
205
+ search : syncData
206
+ } ;
207
+
208
+ if ( syncOptions . iframeEnabled ) {
209
+ syncUrlObject . protocol = ADQUERY_STATIC_DOMAIN_PROTOCOL ;
210
+ syncUrlObject . hostname = ADQUERY_STATIC_DOMAIN ;
211
+ syncUrlObject . pathname = '/user-sync-iframe.html' ;
212
+
213
+ return [ {
214
+ type : 'iframe' ,
215
+ url : buildUrl ( syncUrlObject )
216
+ } ] ;
183
217
}
218
+
184
219
return [ {
185
220
type : 'image' ,
186
- url : syncUrl
221
+ url : buildUrl ( syncUrlObject )
187
222
} ] ;
188
223
}
189
224
} ;
@@ -205,7 +240,7 @@ function buildRequest(validBidRequests, bidderRequest) {
205
240
// onetime User ID
206
241
const ramdomValues = Array . from ( window . crypto . getRandomValues ( new Uint32Array ( 4 ) ) ) ;
207
242
userId = ramdomValues . map ( val => val . toString ( 36 ) ) . join ( '' ) . substring ( 0 , 20 ) ;
208
- logInfo ( 'generated onetime User ID: ' , userId ) ;
243
+ logMessage ( 'generated onetime User ID: ' , userId ) ;
209
244
window . qid = userId ;
210
245
}
211
246
0 commit comments