@oneteme/inspect-ng-collector 1.3.0-beta.1 → 1.3.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,25 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, inject, provideAppInitializer, ErrorHandler, NgModule } from '@angular/core';
3
- import { HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
2
+ import { Injectable, APP_INITIALIZER, ErrorHandler, NgModule } from '@angular/core';
3
+ import { HttpErrorResponse, HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
4
4
  import { finalize, interval, startWith, tap as tap$1 } from 'rxjs';
5
5
  import { tap } from 'rxjs/operators';
6
- import { NavigationStart, NavigationEnd, Router } from '@angular/router';
6
+ import { NavigationStart, NavigationEnd, NavigationCancel, Router } from '@angular/router';
7
7
 
8
+ const WIN = window;
8
9
  function dateNow() {
9
10
  return Date.now() / 1_000;
10
11
  }
12
+ var RequestMask;
13
+ (function (RequestMask) {
14
+ RequestMask[RequestMask["LOCAL"] = 1] = "LOCAL";
15
+ RequestMask[RequestMask["REST"] = 4] = "REST";
16
+ })(RequestMask || (RequestMask = {}));
11
17
  const DISPATCH = 'dispatch';
12
18
  const PRE_DISPATCH = 'pre-dispatch';
13
19
  const BEFOREUNLOAD = 'beforeunload';
14
20
  function createLogEntry(level, message, sessionId) {
15
21
  return {
16
- "@type": "log",
22
+ "@type": "00",
17
23
  level: level,
18
24
  message: message,
19
25
  instant: dateNow(),
@@ -22,7 +28,7 @@ function createLogEntry(level, message, sessionId) {
22
28
  }
23
29
  function createReport(message) {
24
30
  return {
25
- "@type": "log",
31
+ "@type": "00",
26
32
  level: "ERROR",
27
33
  message: message,
28
34
  instant: dateNow(),
@@ -84,12 +90,6 @@ function detectOs() {
84
90
  }
85
91
  return undefined;
86
92
  }
87
- function instanceApiURL$1(host, path) {
88
- return toURL$1(host, path);
89
- }
90
- function sessionApiURL$1(host, path) {
91
- return toURL$1(host, path);
92
- }
93
93
  function toURL$1(host, path) {
94
94
  return host.endsWith(SLASH$1) || path.startsWith(SLASH$1) ? host + path : [host, path].join(SLASH$1);
95
95
  }
@@ -125,6 +125,10 @@ function require(v, name) {
125
125
  function adaptedConfig(conf) {
126
126
  return {
127
127
  ...conf,
128
+ scheduling: {
129
+ ...conf.scheduling,
130
+ interval: conf.scheduling?.interval && conf.scheduling.interval / 1000
131
+ },
128
132
  monitoring: {
129
133
  ...conf.monitoring,
130
134
  additionalProperties: String(conf.monitoring?.additionalProperties),
@@ -135,7 +139,7 @@ function adaptedConfig(conf) {
135
139
  httpRoute: {
136
140
  ...conf.monitoring?.httpRoute,
137
141
  excludes: {
138
- path: (conf?.monitoring?.httpRoute?.excludes?.path).map(r => r.source) // convert to string array to conform to backend expectation
142
+ path: (conf?.monitoring?.httpRoute?.excludes?.path).map(r => r.source)
139
143
  }
140
144
  }
141
145
  },
@@ -143,7 +147,8 @@ function adaptedConfig(conf) {
143
147
  ...conf.tracing,
144
148
  remote: {
145
149
  ...conf.tracing?.remote,
146
- '@type': "rest-rmt", // add this to conform to backend expectation
150
+ '@type': "02",
151
+ retentionMaxAge: (conf.tracing?.remote?.retentionMaxAge ?? 10) * 60 * 60 * 24
147
152
  }
148
153
  }
149
154
  };
@@ -164,7 +169,7 @@ class ContextManager {
164
169
  }
165
170
  static get instance() {
166
171
  if (!ContextManager._instance) {
167
- console.warn("[Inspect-ng-collecotor] Error while initializing ContextManager");
172
+ console.warn("[Inspect-ng-collector] Error while initializing ContextManager");
168
173
  }
169
174
  return ContextManager._instance;
170
175
  }
@@ -184,6 +189,7 @@ class ContextManager {
184
189
  instanceApi: sessionApiURL(host, instanceApi),
185
190
  sessionApi: instanceApiURL(host, sessionApi).replace(':id', instanceId),
186
191
  exclude: getRegArrOrCall(conf?.monitoring?.httpRoute?.excludes?.path) || [],
192
+ hostExcludes: conf?.monitoring?.httpRequest?.excludes?.host || [],
187
193
  debugMode: conf.debugMode ?? false,
188
194
  analytics: conf?.monitoring?.analytics?.enabled ?? false,
189
195
  resources: conf?.monitoring?.resources?.enabled ?? false,
@@ -196,7 +202,7 @@ class ContextManager {
196
202
  id: instanceId,
197
203
  name: require(getStringOrCall(conf?.monitoring?.name), 'name'),
198
204
  version: getStringOrCall(conf?.monitoring?.version),
199
- address: undefined, //server side
205
+ address: getSessionAddress(), //server side
200
206
  env: require(getStringOrCall(conf?.monitoring?.env), 'env'),
201
207
  os: detectOs(),
202
208
  re: detectBrowser(),
@@ -210,6 +216,14 @@ class ContextManager {
210
216
  };
211
217
  }
212
218
  }
219
+ function getSessionAddress() {
220
+ let inspectId = localStorage.getItem("inspect-id");
221
+ if (!inspectId) {
222
+ inspectId = crypto.randomUUID();
223
+ localStorage.setItem("inspect-id", inspectId);
224
+ }
225
+ return inspectId;
226
+ }
213
227
  function instanceApiURL(host, path) {
214
228
  return toURL(host, path);
215
229
  }
@@ -224,49 +238,72 @@ class SessionManager {
224
238
  static get instance() {
225
239
  if (!SessionManager._instance) {
226
240
  SessionManager._instance = new SessionManager();
241
+ WIN["inspect-session-manager"] = SessionManager._instance;
227
242
  }
228
243
  return SessionManager._instance;
229
244
  }
230
- newSession(url) {
231
- if (this.currentSession) {
232
- this.currentSession.end = dateNow();
233
- this.currentSession.name = document.title;
234
- this.currentSession.location = document.URL;
235
- if (!ContextManager.instance.techConfig.exclude?.some((e) => e.test(this.currentSession.location))) {
236
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: this.currentSession } }));
245
+ navigate(url) {
246
+ this.getCurrentSession(s => {
247
+ if (s) {
248
+ this.getCurrentSessionCallBack(cb => cb.end = dateNow());
249
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { force: !url, traces: this.currentSessionCallBack } }));
237
250
  }
238
- }
251
+ this.currentSession = null;
252
+ });
239
253
  if (url) {
254
+ let id = crypto.randomUUID();
240
255
  this.currentSession = {
241
- '@type': "main-ses",
242
- id: crypto.randomUUID(),
243
- user: "",
256
+ '@type': "10",
257
+ id: id,
258
+ user: ContextManager.instance.techConfig.user,
244
259
  start: dateNow(),
245
260
  type: "VIEW",
246
261
  location: url,
247
262
  loading: true,
248
- exceptions: []
263
+ requestMask: 0,
264
+ };
265
+ this.currentSessionCallBack = {
266
+ '@type': "11",
267
+ id: id,
268
+ requestMask: 0,
249
269
  };
250
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: this.currentSession } }));
251
270
  }
252
271
  }
253
- currentSessionID() {
272
+ updateSession() {
273
+ this.getCurrentSession(s => {
274
+ s.name = document.title;
275
+ s.location = document.URL;
276
+ if (!ContextManager.instance.techConfig.exclude?.some((e) => e.test(s.location))) {
277
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: s } }));
278
+ }
279
+ });
280
+ }
281
+ getCurrentSession(fn) {
254
282
  if (this.currentSession) {
255
- return this.currentSession.id;
283
+ return fn(this.currentSession);
284
+ }
285
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: createReport("no active session found ") } }));
286
+ return undefined;
287
+ }
288
+ getCurrentSessionCallBack(fn) {
289
+ if (this.currentSessionCallBack) {
290
+ return fn(this.currentSessionCallBack);
256
291
  }
257
292
  window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: createReport("no active session found ") } }));
258
293
  return undefined;
259
294
  }
260
- getCurrentSession() {
261
- return this.currentSession;
295
+ currentSessionID() {
296
+ return this.getCurrentSession(s => s.id);
297
+ }
298
+ updateMask(requestMask) {
299
+ return this.getCurrentSessionCallBack(s => {
300
+ let before = s.requestMask;
301
+ s.requestMask |= requestMask;
302
+ return s.requestMask !== before;
303
+ });
262
304
  }
263
305
  addException(exception) {
264
- if (this.currentSession) {
265
- this.currentSession.exceptions.push(exception);
266
- }
267
- else {
268
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: createReport("no active session found ") } }));
269
- }
306
+ this.getCurrentSessionCallBack(s => s.exception = exception);
270
307
  }
271
308
  }
272
309
 
@@ -276,7 +313,7 @@ class RestRequestMonitor {
276
313
  const url = toHref(restRequest.urlWithParams);
277
314
  const auth_user = extractAuthSchemeAnduser(restRequest.headers);
278
315
  this.restRequest = {
279
- "@type": "http-req",
316
+ "@type": "120",
280
317
  id: crypto.randomUUID(),
281
318
  method: restRequest.method,
282
319
  protocol: url.protocol.slice(0, -1),
@@ -287,48 +324,71 @@ class RestRequestMonitor {
287
324
  contentType: restRequest.responseType,
288
325
  authScheme: auth_user.authScheme,
289
326
  user: auth_user.user,
290
- ouDataSize: sizeOf(restRequest.body),
327
+ dataSize: sizeOf(restRequest.body),
291
328
  start: start,
292
329
  sessionId: SessionManager.instance.currentSessionID()
293
330
  };
331
+ this.restRequestCallBack = {
332
+ "@type": "121",
333
+ id: this.restRequest.id,
334
+ dataSize: -1,
335
+ linked: false
336
+ };
337
+ if (SessionManager.instance.currentSessionID() != null) {
338
+ let doUpdateMask = SessionManager.instance.updateMask(RequestMask.REST);
339
+ doUpdateMask && window.dispatchEvent(new CustomEvent(DISPATCH, { detail: {
340
+ traces: {
341
+ "@type": "03",
342
+ id: SessionManager.instance.currentSessionID(),
343
+ main: true,
344
+ mask: SessionManager.instance.getCurrentSessionCallBack(s => s.requestMask)
345
+ }
346
+ }
347
+ }));
348
+ }
294
349
  }
295
350
  postProcess(event, error) {
296
351
  let status = 0, exception = null;
297
352
  if (event) {
298
353
  status = +event.status;
299
- this.restRequest.inDataSize = sizeOf(event.body);
300
- this.assertSessionID(this.restRequest.id, event.headers);
354
+ this.restRequestCallBack.dataSize = sizeOf(event.body);
355
+ this.restRequestCallBack.linked = this.assertSessionID(this.restRequest.id, event.headers);
301
356
  }
302
357
  if (error) {
303
- this.assertSessionID(this.restRequest.id, error?.headers);
358
+ this.restRequestCallBack.linked = error?.headers && this.assertSessionID(this.restRequest.id, error.headers);
304
359
  status = +error.status;
305
360
  exception = {
306
361
  type: error.name,
307
362
  message: error.error && error.status ? JSON.stringify(error.error) : error.message
308
363
  };
364
+ this.restRequestCallBack.bodyContent = error instanceof HttpErrorResponse ? JSON.stringify(error.error) : undefined;
365
+ this.restRequestCallBack.dataSize = sizeOf(error.error);
309
366
  }
310
- this.restRequest.end = dateNow();
311
- this.restRequest.status = +status;
367
+ this.restRequestCallBack.contentType = extractContentType(event?.headers);
368
+ this.restRequestCallBack.end = dateNow();
369
+ this.restRequestCallBack.status = +status;
312
370
  let stage = {
313
- "@type": "http-stg",
371
+ "@type": "220",
314
372
  name: "PROCESS",
315
- start: this.restRequest.start,
373
+ start: this.restRequest.start, // use request
316
374
  end: dateNow(),
317
375
  order: 0,
318
376
  exception: exception,
319
- requestId: this.restRequest.id
377
+ requestId: this.restRequestCallBack.id
320
378
  };
321
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: this.restRequest } }));
379
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: this.restRequestCallBack } }));
322
380
  window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: stage } }));
323
381
  }
324
382
  assertSessionID(id, headers) {
325
383
  if (headers?.has('x-tracert')) {
326
- if (id !== headers.get('x-tracert')) {
327
- window.dispatchEvent(new CustomEvent(DISPATCH, {
328
- detail: { traces: createReport("The received x-tracert header (" + headers.get('x-tracert') + ") does not match the request id (" + id + ")") }
329
- }));
384
+ if (id == headers.get('x-tracert')) {
385
+ return true;
330
386
  }
387
+ window.dispatchEvent(new CustomEvent(DISPATCH, {
388
+ detail: { traces: createReport("The received x-tracert header (" + headers.get('x-tracert') + ") does not match the request id (" + id + ")") }
389
+ }));
331
390
  }
391
+ return false;
332
392
  }
333
393
  }
334
394
  function toHref(url) {
@@ -364,6 +424,17 @@ function extractAuthSchemeAnduser(headers) {
364
424
  }
365
425
  return auth_user;
366
426
  }
427
+ function extractContentType(headers) {
428
+ try {
429
+ if (headers?.has('Content-Type')) {
430
+ return headers.get('Content-Type');
431
+ }
432
+ }
433
+ catch (err) {
434
+ createReport(JSON.stringify(err));
435
+ }
436
+ return undefined;
437
+ }
367
438
  function sizeOf(body) {
368
439
  return body ? JSON.stringify(body).length : 0;
369
440
  }
@@ -374,13 +445,25 @@ class HttpInterceptorService {
374
445
  let restRequestMonitor = new RestRequestMonitor(req);
375
446
  let e;
376
447
  window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: restRequestMonitor.restRequest } }));
377
- req = req.clone({ headers: req.headers.set('x-tracert', restRequestMonitor.restRequest.id) });
378
- return next.handle(req).pipe(tap((event) => {
379
- if (event instanceof HttpResponse) {
380
- e = event;
448
+ const host = new URL(req.url, window.location.origin).host;
449
+ if (!ContextManager.instance.techConfig.hostExcludes?.some((e) => e == host)) {
450
+ req = req.clone({ headers: req.headers.set('x-tracert', restRequestMonitor.restRequest.id) });
451
+ }
452
+ return next.handle(req).pipe(tap({
453
+ next: (event) => {
454
+ if (event instanceof HttpResponse) {
455
+ e = event;
456
+ }
457
+ },
458
+ error: (error) => {
459
+ e = error;
460
+ },
461
+ unsubscribe: () => {
462
+ e = { status: 0,
463
+ name: "Unsubscribed",
464
+ message: "The request was cancelled before completion."
465
+ };
381
466
  }
382
- }, error => {
383
- e = error;
384
467
  }), finalize(() => {
385
468
  e instanceof HttpResponse ? restRequestMonitor.postProcess(e, null) : restRequestMonitor.postProcess(null, e ?? {
386
469
  status: 0,
@@ -389,10 +472,10 @@ class HttpInterceptorService {
389
472
  });
390
473
  }));
391
474
  }
392
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: HttpInterceptorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
393
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: HttpInterceptorService, providedIn: 'root' }); }
475
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: HttpInterceptorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
476
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: HttpInterceptorService, providedIn: 'root' }); }
394
477
  }
395
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: HttpInterceptorService, decorators: [{
478
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: HttpInterceptorService, decorators: [{
396
479
  type: Injectable,
397
480
  args: [{ providedIn: 'root' }]
398
481
  }], ctorParameters: () => [] });
@@ -410,10 +493,10 @@ class GlobalErrorHandlerService {
410
493
  }
411
494
  throw error;
412
495
  }
413
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GlobalErrorHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
414
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GlobalErrorHandlerService, providedIn: 'root' }); }
496
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: GlobalErrorHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
497
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: GlobalErrorHandlerService, providedIn: 'root' }); }
415
498
  }
416
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: GlobalErrorHandlerService, decorators: [{
499
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: GlobalErrorHandlerService, decorators: [{
417
500
  type: Injectable,
418
501
  args: [{ providedIn: 'root' }]
419
502
  }] });
@@ -432,14 +515,19 @@ class EventTraceScheduledDispatcherService {
432
515
  .pipe(tap$1(() => {
433
516
  if (this.sendSessionfinished) {
434
517
  this.sendSessionfinished = false;
435
- setTimeout(() => window.dispatchEvent(new CustomEvent(PRE_DISPATCH)), 50);
436
- this.Dispatch().finally(() => { this.sendSessionfinished = true; });
518
+ window.dispatchEvent(new CustomEvent(PRE_DISPATCH));
519
+ this.Dispatch()
520
+ .catch(err => { })
521
+ .finally(() => { this.sendSessionfinished = true; });
437
522
  }
438
523
  }))
439
524
  .subscribe();
440
525
  window.addEventListener(DISPATCH, (e) => {
441
526
  e.detail.traces && this.addtoQueue(e.detail.traces);
442
- e.detail.force && this.sendSessions(true);
527
+ if (e.detail.force) {
528
+ this.sendSessions(true);
529
+ this.onDestroy();
530
+ }
443
531
  });
444
532
  }
445
533
  Dispatch() {
@@ -518,21 +606,31 @@ class EventTraceScheduledDispatcherService {
518
606
  this.addtoQueue(createReport(String(e)));
519
607
  }
520
608
  }
609
+ onDestroy() {
610
+ this.traceQueue.clear();
611
+ this.sendSessionfinished = true;
612
+ this.instanceSaved = false;
613
+ this.sessionSendAttempts = 0;
614
+ }
521
615
  }
522
616
 
523
617
  function routeHandler(event) {
524
618
  if (event instanceof NavigationStart) {
525
- SessionManager.instance.newSession(event.url);
619
+ SessionManager.instance.navigate(event.url);
526
620
  }
527
- if (event instanceof NavigationEnd) {
528
- delete SessionManager.instance?.getCurrentSession().loading;
621
+ if (event instanceof NavigationEnd || event instanceof NavigationCancel) {
622
+ setTimeout(() => SessionManager.instance.updateSession(), 0);
529
623
  }
530
624
  }
531
625
  function windowUnloadHandler(event) {
532
- if (!SessionManager.instance.getCurrentSession().loading) {
533
- SessionManager.instance.newSession();
626
+ SessionManager.instance.navigate();
627
+ }
628
+ function bfCacheHandler(event) {
629
+ if (event.persisted) { // if the page was restored from bfcache
630
+ ContextManager.init(NgCollectorModule.configuration);
631
+ SessionManager.instance.navigate(document.URL);
632
+ setTimeout(() => SessionManager.instance.updateSession(), 0);
534
633
  }
535
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { force: true } }));
536
634
  }
537
635
 
538
636
  function machineRessourceUsageHandler(event) {
@@ -542,7 +640,7 @@ function getMemoryInfo() {
542
640
  try {
543
641
  const memory = performance.memory;
544
642
  return {
545
- '@type': 'rsrc-usg',
643
+ '@type': '01',
546
644
  instant: dateNow(),
547
645
  usedHeap: memory.usedJSHeapSize / (1024 * 1024),
548
646
  commitedHeap: memory.totalJSHeapSize / (1024 * 1024),
@@ -554,8 +652,8 @@ function getMemoryInfo() {
554
652
  return null;
555
653
  }
556
654
 
557
- function routerEventsListener() {
558
- inject(Router).events.subscribe(routeHandler);
655
+ function routerEventsListener(router) {
656
+ router.events.subscribe(routeHandler);
559
657
  }
560
658
  function beforeUnloadListener() {
561
659
  window.addEventListener(BEFOREUNLOAD, windowUnloadHandler);
@@ -565,6 +663,9 @@ function beforeDispatchListener() {
565
663
  window.addEventListener(PRE_DISPATCH, machineRessourceUsageHandler);
566
664
  }
567
665
  }
666
+ function bfCacheListener() {
667
+ window.addEventListener('pageshow', bfCacheHandler);
668
+ }
568
669
 
569
670
  const genericMap = [
570
671
  t => t.getAttribute('placeholder'),
@@ -657,17 +758,16 @@ function lookUpChild(t, depth) {
657
758
  }
658
759
  function addActionUser(eventType, target) {
659
760
  const ua = {
660
- '@type': "user-act",
761
+ '@type': "300",
661
762
  type: eventType,
662
763
  start: dateNow(),
663
764
  name: extractName(target),
664
765
  nodeName: target.tagName?.toLowerCase(),
665
- sessionId: SessionManager.instance?.getCurrentSession().id
766
+ sessionId: SessionManager.instance?.currentSessionID()
666
767
  };
667
- // window.dispatchEvent(new CustomEvent( DISPATCH ,{ detail : { traces:ua }}));
768
+ // window.dispatchEvent(new CustomEvent( DISPATCH ,{ detail : { traces:ua }}));
668
769
  }
669
770
 
670
- const WIN = window;
671
771
  function eventTraceDebugger() {
672
772
  EventTraceDebugger._instance = new EventTraceDebugger();
673
773
  }
@@ -737,7 +837,7 @@ class EventTraceDebugger {
737
837
  if (session.location) {
738
838
  s += `(${session.location}) `;
739
839
  }
740
- s += this.prettyDurationFormat(session.start, session.end) + '\n';
840
+ //s+= this.prettyDurationFormat(session.start, session.end)+'\n';
741
841
  s += this.getChildPrint(this.restRequests, this.prettyRestRequestFormat.bind(this));
742
842
  s += this.getChildPrint(this.localRequests, this.prettyLocalRequestFormat.bind(this));
743
843
  s += this.getChildPrint(this.userActions, this.prettyActionUserFormat.bind(this));
@@ -765,8 +865,9 @@ class EventTraceDebugger {
765
865
  if (rest.query) {
766
866
  s += rest.query;
767
867
  }
768
- s += ` >> ${rest.status} `;
769
- s += this.prettyDurationFormat(rest.start, rest.end) + '\n';
868
+ // s+= ` >> ${rest.status} `
869
+ // s+= this.prettyDurationFormat(rest.start,rest.end);
870
+ s += '\n';
770
871
  this.httpRequestStages.filter((s) => s.requestId == rest.id).forEach((stage) => {
771
872
  s += this.prettyHttpRequestStageFormat(stage);
772
873
  });
@@ -789,14 +890,14 @@ class EventTraceDebugger {
789
890
  if (local.location) {
790
891
  s += `(${local.location})`;
791
892
  }
792
- s += " >> ";
793
- if (local.exception?.type) {
794
- s += ` ${local.exception?.type}:`;
795
- }
796
- if (local.exception?.message) {
797
- s += ` ${local.exception.message}`;
798
- }
799
- s += ` ${this.prettyDurationFormat(local.start, local.end)}`;
893
+ /*s+= " >> ";
894
+ if(local.exception?.type){
895
+ s+= ` ${local.exception?.type}:`;
896
+ }
897
+ if(local.exception?.message){
898
+ s+= ` ${local.exception.message}`
899
+ }
900
+ s+= ` ${this.prettyDurationFormat(local.start, local.end)}`;*/
800
901
  return s;
801
902
  }
802
903
  prettyLogEntryFormat(log) {
@@ -856,6 +957,7 @@ class NgCollectorModule {
856
957
  static { this.forRootCalled = false; }
857
958
  static forRoot(configuration) {
858
959
  console.log("forRootCalled");
960
+ this.configuration = configuration;
859
961
  if (configuration?.enabled && !NgCollectorModule.forRootCalled) {
860
962
  NgCollectorModule.forRootCalled = true;
861
963
  try {
@@ -863,7 +965,8 @@ class NgCollectorModule {
863
965
  return {
864
966
  ngModule: NgCollectorModule,
865
967
  providers: [
866
- provideAppInitializer(initializeEvents),
968
+ //provideAppInitializer(initializeEvents),
969
+ { provide: APP_INITIALIZER, useFactory: initializeEvents, deps: [Router], multi: true },
867
970
  { provide: HTTP_INTERCEPTORS, useClass: HttpInterceptorService, multi: true },
868
971
  { provide: ErrorHandler, useClass: GlobalErrorHandlerService }
869
972
  ]
@@ -877,71 +980,91 @@ class NgCollectorModule {
877
980
  ngModule: NgCollectorModule
878
981
  };
879
982
  }
880
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: NgCollectorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
881
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.3", ngImport: i0, type: NgCollectorModule }); }
882
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: NgCollectorModule }); }
983
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: NgCollectorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
984
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.17", ngImport: i0, type: NgCollectorModule }); }
985
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: NgCollectorModule }); }
883
986
  }
884
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.3", ngImport: i0, type: NgCollectorModule, decorators: [{
987
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: NgCollectorModule, decorators: [{
885
988
  type: NgModule
886
989
  }] });
887
- function initializeEvents() {
888
- eventTraceScheduledDispatcher();
889
- eventTraceDebugger();
890
- analyticsEventsListener();
891
- //storageEventListener();
892
- beforeDispatchListener();
893
- beforeUnloadListener();
894
- routerEventsListener();
990
+ function initializeEvents(router) {
991
+ return () => {
992
+ ContextManager.init(NgCollectorModule.configuration);
993
+ eventTraceScheduledDispatcher();
994
+ eventTraceDebugger();
995
+ analyticsEventsListener();
996
+ //storageEventListener();
997
+ beforeDispatchListener();
998
+ beforeUnloadListener();
999
+ routerEventsListener(router);
1000
+ bfCacheListener();
1001
+ };
895
1002
  }
896
1003
 
897
1004
  function TraceableStage() {
898
1005
  return function (target, propertyKey, descriptor) {
899
1006
  const originalMethod = descriptor.value;
900
1007
  descriptor.value = function (...args) {
901
- if (SessionManager) {
902
- let session = SessionManager.instance?.getCurrentSession();
903
- let exception;
904
- let start, end;
905
- start = Date.now();
906
- try {
907
- return originalMethod.apply(this, args);
908
- }
909
- catch (e) {
910
- let type = null, message = null;
911
- if (e) {
912
- if (typeof e === "string") {
913
- message = e;
914
- }
915
- else if (e instanceof Error) {
916
- type = e.name;
917
- message = e.message;
918
- }
919
- else {
920
- message = JSON.stringify(e);
921
- }
1008
+ let exception;
1009
+ let start, end;
1010
+ start = Date.now();
1011
+ try {
1012
+ return originalMethod.apply(this, args);
1013
+ }
1014
+ catch (e) {
1015
+ let type = null, message = null;
1016
+ if (e) {
1017
+ if (typeof e === "string") {
1018
+ message = e;
1019
+ }
1020
+ else if (e instanceof Error) {
1021
+ type = e.name;
1022
+ message = e.message;
1023
+ }
1024
+ else {
1025
+ message = JSON.stringify(e);
922
1026
  }
923
- exception = {
924
- type: type,
925
- message: message
926
- };
927
- throw e;
928
1027
  }
929
- finally {
930
- end = Date.now();
931
- window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: {
932
- "@type": "locl-req",
933
- id: crypto.randomUUID(),
934
- name: propertyKey,
935
- location: target.constructor.name,
936
- user: session.user,
937
- start: start,
938
- end: end,
939
- exception: exception,
940
- sessionId: SessionManager.instance.currentSessionID()
1028
+ exception = {
1029
+ type: type,
1030
+ message: message
1031
+ };
1032
+ throw e;
1033
+ }
1034
+ finally {
1035
+ end = Date.now();
1036
+ let id = crypto.randomUUID();
1037
+ if (WIN["inspect-session-manager"]?.currentSessionID() != null) {
1038
+ let doUpdateMask = WIN["inspect-session-manager"]?.updateMask(RequestMask.LOCAL);
1039
+ doUpdateMask && window.dispatchEvent(new CustomEvent(DISPATCH, { detail: {
1040
+ traces: {
1041
+ "@type": "03",
1042
+ id: WIN["inspect-session-manager"]?.currentSessionID(),
1043
+ main: true,
1044
+ mask: WIN["inspect-session-manager"]?.getCurrentSessionCallBack((s) => s.requestMask)
941
1045
  }
942
1046
  }
943
1047
  }));
944
1048
  }
1049
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: {
1050
+ "@type": "110",
1051
+ id: id,
1052
+ name: propertyKey,
1053
+ location: target.constructor.name,
1054
+ user: WIN["inspect-session-manager"]?.currentSession?.user,
1055
+ start: start,
1056
+ sessionId: WIN["inspect-session-manager"]?.currentSession?.id
1057
+ }
1058
+ }
1059
+ }));
1060
+ window.dispatchEvent(new CustomEvent(DISPATCH, { detail: { traces: {
1061
+ "@type": "111",
1062
+ id: id,
1063
+ exception: exception,
1064
+ end: end
1065
+ }
1066
+ }
1067
+ }));
945
1068
  }
946
1069
  };
947
1070
  return descriptor;