@@ -7,15 +7,16 @@ import {config} from '../src/config.js';
7
7
import { EVENTS } from '../src/constants.js' ;
8
8
import { MODULE_TYPE_ANALYTICS } from '../src/activities/modules.js' ;
9
9
import { detectBrowser } from '../libraries/intentIqUtils/detectBrowserUtils.js' ;
10
+ import { appendSPData } from '../libraries/intentIqUtils/urlUtils.js' ;
10
11
import { appendVrrefAndFui , getReferrer } from '../libraries/intentIqUtils/getRefferer.js' ;
11
12
import { getCmpData } from '../libraries/intentIqUtils/getCmpData.js'
12
- import { CLIENT_HINTS_KEY , FIRST_PARTY_KEY , VERSION } from '../libraries/intentIqConstants/intentIqConstants.js' ;
13
+ import { CLIENT_HINTS_KEY , FIRST_PARTY_KEY , VERSION , PREBID } from '../libraries/intentIqConstants/intentIqConstants.js' ;
13
14
import { readData , defineStorageType } from '../libraries/intentIqUtils/storageUtils.js' ;
15
+ import { reportingServerAddress } from '../libraries/intentIqUtils/intentIqConfig.js' ;
16
+ import { handleAdditionalParams } from '../libraries/intentIqUtils/handleAdditionalParams.js' ;
14
17
15
18
const MODULE_NAME = 'iiqAnalytics'
16
19
const analyticsType = 'endpoint' ;
17
- const REPORT_ENDPOINT = 'https://reports.intentiq.com/report' ;
18
- const REPORT_ENDPOINT_GDPR = 'https://reports-gdpr.intentiq.com/report' ;
19
20
const storage = getStorageManager ( { moduleType : MODULE_TYPE_ANALYTICS , moduleName : MODULE_NAME } ) ;
20
21
const prebidVersion = '$prebid.version$' ;
21
22
export const REPORTER_ID = Date . now ( ) + '_' + getRandom ( 0 , 1000 ) ;
@@ -59,7 +60,21 @@ const PARAMS_NAMES = {
59
60
adType : 'adType'
60
61
} ;
61
62
62
- let iiqAnalyticsAnalyticsAdapter = Object . assign ( adapter ( { defaultUrl : REPORT_ENDPOINT , analyticsType} ) , {
63
+ function getIntentIqConfig ( ) {
64
+ return config . getConfig ( 'userSync.userIds' ) ?. find ( m => m . name === 'intentIqId' ) ;
65
+ }
66
+
67
+ const DEFAULT_URL = 'https://reports.intentiq.com/report'
68
+
69
+ const getDataForDefineURL = ( ) => {
70
+ const iiqConfig = getIntentIqConfig ( )
71
+ const cmpData = getCmpData ( ) ;
72
+ const gdprDetected = cmpData . gdprString ;
73
+
74
+ return [ iiqConfig , gdprDetected ]
75
+ }
76
+
77
+ let iiqAnalyticsAnalyticsAdapter = Object . assign ( adapter ( { url : DEFAULT_URL , analyticsType} ) , {
63
78
initOptions : {
64
79
lsValueInitialized : false ,
65
80
partner : null ,
@@ -69,7 +84,10 @@ let iiqAnalyticsAnalyticsAdapter = Object.assign(adapter({defaultUrl: REPORT_END
69
84
eidl : null ,
70
85
lsIdsInitialized : false ,
71
86
manualWinReportEnabled : false ,
72
- domainName : null
87
+ domainName : null ,
88
+ siloEnabled : false ,
89
+ reportMethod : null ,
90
+ additionalParams : null
73
91
} ,
74
92
track ( { eventType, args} ) {
75
93
switch ( eventType ) {
@@ -91,11 +109,7 @@ const {
91
109
BID_REQUESTED
92
110
} = EVENTS ;
93
111
94
- function getIntentIqConfig ( ) {
95
- return config . getConfig ( 'userSync.userIds' ) ?. find ( m => m . name === 'intentIqId' ) ;
96
- }
97
-
98
- function initLsValues ( ) {
112
+ function initAdapterConfig ( ) {
99
113
if ( iiqAnalyticsAnalyticsAdapter . initOptions . lsValueInitialized ) return ;
100
114
let iiqConfig = getIntentIqConfig ( )
101
115
@@ -108,16 +122,24 @@ function initLsValues() {
108
122
typeof iiqConfig . params ?. browserBlackList === 'string' ? iiqConfig . params . browserBlackList . toLowerCase ( ) : '' ;
109
123
iiqAnalyticsAnalyticsAdapter . initOptions . manualWinReportEnabled = iiqConfig . params ?. manualWinReportEnabled || false ;
110
124
iiqAnalyticsAnalyticsAdapter . initOptions . domainName = iiqConfig . params ?. domainName || '' ;
125
+ iiqAnalyticsAnalyticsAdapter . initOptions . siloEnabled =
126
+ typeof iiqConfig . params ?. siloEnabled === 'boolean' ? iiqConfig . params . siloEnabled : false ;
127
+ iiqAnalyticsAnalyticsAdapter . initOptions . reportMethod = parseReportingMethod ( iiqConfig . params ?. reportMethod ) ;
128
+ iiqAnalyticsAnalyticsAdapter . initOptions . additionalParams = iiqConfig . params ?. additionalParams || null ;
111
129
} else {
112
130
iiqAnalyticsAnalyticsAdapter . initOptions . lsValueInitialized = false ;
113
131
iiqAnalyticsAnalyticsAdapter . initOptions . partner = - 1 ;
132
+ iiqAnalyticsAnalyticsAdapter . initOptions . reportMethod = 'GET' ;
114
133
}
115
134
}
116
135
117
136
function initReadLsIds ( ) {
118
137
try {
119
138
iiqAnalyticsAnalyticsAdapter . initOptions . dataInLs = null ;
120
- iiqAnalyticsAnalyticsAdapter . initOptions . fpid = JSON . parse ( readData ( FIRST_PARTY_KEY , allowedStorage , storage ) ) ;
139
+ iiqAnalyticsAnalyticsAdapter . initOptions . fpid = JSON . parse ( readData (
140
+ `${ FIRST_PARTY_KEY } ${ iiqAnalyticsAnalyticsAdapter . initOptions . siloEnabled ? '_p_' + iiqAnalyticsAnalyticsAdapter . initOptions . partner : '' } ` ,
141
+ allowedStorage , storage
142
+ ) ) ;
121
143
if ( iiqAnalyticsAnalyticsAdapter . initOptions . fpid ) {
122
144
iiqAnalyticsAnalyticsAdapter . initOptions . currentGroup = iiqAnalyticsAnalyticsAdapter . initOptions . fpid . group ;
123
145
}
@@ -144,7 +166,7 @@ function initReadLsIds() {
144
166
145
167
function bidWon ( args , isReportExternal ) {
146
168
if ( ! iiqAnalyticsAnalyticsAdapter . initOptions . lsValueInitialized ) {
147
- initLsValues ( ) ;
169
+ initAdapterConfig ( ) ;
148
170
}
149
171
150
172
if ( isNaN ( iiqAnalyticsAnalyticsAdapter . initOptions . partner ) || iiqAnalyticsAnalyticsAdapter . initOptions . partner == - 1 ) return ;
@@ -159,13 +181,32 @@ function bidWon(args, isReportExternal) {
159
181
initReadLsIds ( ) ;
160
182
}
161
183
if ( ( isReportExternal && iiqAnalyticsAnalyticsAdapter . initOptions . manualWinReportEnabled ) || ( ! isReportExternal && ! iiqAnalyticsAnalyticsAdapter . initOptions . manualWinReportEnabled ) ) {
162
- ajax ( constructFullUrl ( preparePayload ( args , true ) ) , undefined , null , { method : 'GET' } ) ;
163
- logInfo ( 'IIQ ANALYTICS -> BID WON' )
184
+ const { url, method, payload } = constructFullUrl ( preparePayload ( args , true ) ) ;
185
+ if ( method === 'POST' ) {
186
+ ajax ( url , undefined , payload , { method, contentType : 'application/x-www-form-urlencoded' } ) ;
187
+ } else {
188
+ ajax ( url , undefined , null , { method} ) ;
189
+ }
190
+ logInfo ( 'IIQ ANALYTICS -> BID WON' ) ;
164
191
return true ;
165
192
}
166
193
return false ;
167
194
}
168
195
196
+ function parseReportingMethod ( reportMethod ) {
197
+ if ( typeof reportMethod === 'string' ) {
198
+ switch ( reportMethod . toUpperCase ( ) ) {
199
+ case 'GET' :
200
+ return 'GET' ;
201
+ case 'POST' :
202
+ return 'POST' ;
203
+ default :
204
+ return 'GET' ;
205
+ }
206
+ }
207
+ return 'GET' ;
208
+ }
209
+
169
210
function defineGlobalVariableName ( ) {
170
211
function reportExternalWin ( args ) {
171
212
return bidWon ( args , true ) ;
@@ -302,30 +343,36 @@ function getDefaultDataObject() {
302
343
303
344
function constructFullUrl ( data ) {
304
345
let report = [ ] ;
346
+ const reportMethod = iiqAnalyticsAnalyticsAdapter . initOptions . reportMethod ;
347
+ const currentBrowserLowerCase = detectBrowser ( ) ;
305
348
data = btoa ( JSON . stringify ( data ) ) ;
306
349
report . push ( data ) ;
307
350
308
351
const cmpData = getCmpData ( ) ;
309
- const gdprDetected = cmpData . gdprString ;
310
- const baseUrl = gdprDetected ? REPORT_ENDPOINT_GDPR : REPORT_ENDPOINT ;
352
+ const baseUrl = reportingServerAddress ( ...getDataForDefineURL ( ) ) ;
311
353
312
354
let url = baseUrl + '?pid=' + iiqAnalyticsAnalyticsAdapter . initOptions . partner +
313
355
'&mct=1' +
314
356
( ( iiqAnalyticsAnalyticsAdapter . initOptions ?. fpid )
315
357
? '&iiqid=' + encodeURIComponent ( iiqAnalyticsAnalyticsAdapter . initOptions . fpid . pcid ) : '' ) +
316
358
'&agid=' + REPORTER_ID +
317
359
'&jsver=' + VERSION +
318
- '&source=pbjs' +
319
- '&payload=' + JSON . stringify ( report ) +
360
+ '&source=' + PREBID +
320
361
'&uh=' + encodeURIComponent ( iiqAnalyticsAnalyticsAdapter . initOptions . clientsHints ) +
321
362
( cmpData . uspString ? '&us_privacy=' + encodeURIComponent ( cmpData . uspString ) : '' ) +
322
363
( cmpData . gppString ? '&gpp=' + encodeURIComponent ( cmpData . gppString ) : '' ) +
323
364
( cmpData . gdprString
324
365
? '&gdpr_consent=' + encodeURIComponent ( cmpData . gdprString ) + '&gdpr=1'
325
366
: '&gdpr=0' ) ;
326
-
367
+ url = appendSPData ( url , iiqAnalyticsAnalyticsAdapter . initOptions . fpid )
327
368
url = appendVrrefAndFui ( url , iiqAnalyticsAnalyticsAdapter . initOptions . domainName ) ;
328
- return url ;
369
+
370
+ if ( reportMethod === 'POST' ) {
371
+ return { url, method : 'POST' , payload : JSON . stringify ( report ) } ;
372
+ }
373
+ url += '&payload=' + encodeURIComponent ( JSON . stringify ( report ) ) ;
374
+ url = handleAdditionalParams ( currentBrowserLowerCase , url , 2 , iiqAnalyticsAnalyticsAdapter . initOptions . additionalParams ) ;
375
+ return { url, method : 'GET' } ;
329
376
}
330
377
331
378
iiqAnalyticsAnalyticsAdapter . originEnableAnalytics = iiqAnalyticsAnalyticsAdapter . enableAnalytics ;
0 commit comments