@@ -19,7 +19,7 @@ import {
1919 LogVisitEventRequest ,
2020 VisitEventResponse ,
2121} from '../internal/api' ;
22-
22+ import { ApiCredentials } from './apiCredentials' ;
2323import { validateString } from './validators' ;
2424
2525export class AnalyticsAPI {
@@ -217,15 +217,28 @@ export class AnalyticsAPI {
217217 }
218218
219219 async getCustomEventTypesByProject (
220- projectName : string
220+ projectName : string ,
221+ credentials ?: ApiCredentials
221222 ) : Promise < GetAllCustomEventTypeResponse > {
222223 validateString (
223224 projectName ,
224225 'The projectName must be provided as an input and has to be nonempty.'
225226 ) ;
226227
228+ const headers : any = { } ;
229+ if ( credentials ?. userJwt ) {
230+ headers [ 'X-User-JWT' ] = credentials . userJwt ;
231+ }
232+ if (
233+ credentials ?. projectId !== undefined &&
234+ credentials . projectId !== null
235+ ) {
236+ headers [ 'X-Project-Id' ] = String ( credentials . projectId ) ;
237+ }
238+
227239 const res = await this . internalApi . analyticsControllerGetCustomEventTypes (
228- projectName
240+ projectName ,
241+ { headers }
229242 ) ;
230243
231244 return res . body ;
@@ -255,73 +268,121 @@ export class AnalyticsAPI {
255268 return res . body ;
256269 }
257270
258- async getAllClickEvents ( event : {
259- projectName : string ;
260- afterTime ?: string ;
261- limit ?: number ;
262- } ) : Promise < GetAllClickEventsResponse > {
271+ async getAllClickEvents (
272+ event : {
273+ projectName : string ;
274+ afterTime ?: string ;
275+ limit ?: number ;
276+ } ,
277+ credentials ?: ApiCredentials
278+ ) : Promise < GetAllClickEventsResponse > {
263279 const { projectName, afterTime, limit } = event ;
264280
265281 validateString (
266282 projectName ,
267283 'The projectName must be provided as an input and has to be nonempty.'
268284 ) ;
269285
286+ const headers : any = { } ;
287+ if ( credentials ?. userJwt ) {
288+ headers [ 'X-User-JWT' ] = credentials . userJwt ;
289+ }
290+ if (
291+ credentials ?. projectId !== undefined &&
292+ credentials . projectId !== null
293+ ) {
294+ headers [ 'X-Project-Id' ] = String ( credentials . projectId ) ;
295+ }
296+
270297 const res = await this . internalApi . analyticsControllerGetAllClickEvents (
271298 projectName ,
272299 afterTime ,
273- limit
300+ limit ,
301+ { headers }
274302 ) ;
275303 return res . body ;
276304 }
277305
278- async getAllVisitEvents ( event : {
279- projectName : string ;
280- afterTime ?: string ;
281- limit ?: number ;
282- } ) : Promise < GetAllVisitEventsResponse > {
306+ async getAllVisitEvents (
307+ event : {
308+ projectName : string ;
309+ afterTime ?: string ;
310+ limit ?: number ;
311+ } ,
312+ credentials ?: ApiCredentials
313+ ) : Promise < GetAllVisitEventsResponse > {
283314 const { projectName, afterTime, limit } = event ;
284315
285316 validateString (
286317 projectName ,
287318 'The projectName must be provided as an input and has to be nonempty.'
288319 ) ;
289320
321+ const headers : any = { } ;
322+ if ( credentials ?. userJwt ) {
323+ headers [ 'X-User-JWT' ] = credentials . userJwt ;
324+ }
325+ if (
326+ credentials ?. projectId !== undefined &&
327+ credentials . projectId !== null
328+ ) {
329+ headers [ 'X-Project-Id' ] = String ( credentials . projectId ) ;
330+ }
331+
290332 const res = await this . internalApi . analyticsControllerGetAllVisitEvents (
291333 projectName ,
292334 afterTime ,
293- limit
335+ limit ,
336+ { headers }
294337 ) ;
295338 return res . body ;
296339 }
297340
298- async getAllInputEvents ( event : {
299- projectName : string ;
300- afterTime ?: string ;
301- limit ?: number ;
302- } ) : Promise < GetAllInputEventsResponse > {
341+ async getAllInputEvents (
342+ event : {
343+ projectName : string ;
344+ afterTime ?: string ;
345+ limit ?: number ;
346+ } ,
347+ credentials ?: ApiCredentials
348+ ) : Promise < GetAllInputEventsResponse > {
303349 const { projectName, afterTime, limit } = event ;
304350
305351 validateString (
306352 projectName ,
307353 'The projectName must be provided as an input and has to be nonempty.'
308354 ) ;
309355
356+ const headers : any = { } ;
357+ if ( credentials ?. userJwt ) {
358+ headers [ 'X-User-JWT' ] = credentials . userJwt ;
359+ }
360+ if (
361+ credentials ?. projectId !== undefined &&
362+ credentials . projectId !== null
363+ ) {
364+ headers [ 'X-Project-Id' ] = String ( credentials . projectId ) ;
365+ }
366+
310367 const res = await this . internalApi . analyticsControllerGetAllInputEvents (
311368 projectName ,
312369 afterTime ,
313- limit
370+ limit ,
371+ { headers }
314372 ) ;
315373 return res . body ;
316374 }
317375
318- async getAllCustomEvents ( event : {
319- projectName : string ;
320- category : string ;
321- subcategory : string ;
322- afterTime ?: string ;
323- limit ?: number ;
324- } ) : Promise < GetAllCustomEventsResponse > {
376+ async getAllCustomEvents (
377+ event : {
378+ projectName : string ;
379+ category : string ;
380+ subcategory : string ;
381+ afterTime ?: string ;
382+ limit ?: number ;
383+ } ,
384+ credentials ?: ApiCredentials
385+ ) : Promise < GetAllCustomEventsResponse > {
325386 const { projectName, category, subcategory, afterTime, limit } = event ;
326387
327388 validateString (
@@ -339,12 +400,24 @@ export class AnalyticsAPI {
339400 'The subcategory must be provided as an input and has to be nonempty.'
340401 ) ;
341402
403+ const headers : any = { } ;
404+ if ( credentials ?. userJwt ) {
405+ headers [ 'X-User-JWT' ] = credentials . userJwt ;
406+ }
407+ if (
408+ credentials ?. projectId !== undefined &&
409+ credentials . projectId !== null
410+ ) {
411+ headers [ 'X-Project-Id' ] = String ( credentials . projectId ) ;
412+ }
413+
342414 const res = await this . internalApi . analyticsControllerGetAllCustomEvents (
343415 projectName ,
344416 category ,
345417 subcategory ,
346418 afterTime ,
347- limit
419+ limit ,
420+ { headers }
348421 ) ;
349422 return res . body ;
350423 }
0 commit comments