@igo2/core 19.0.0-next.21 → 19.0.0-next.22

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.
@@ -34,8 +34,8 @@ const ALTERNATE_CONFIG_FROM_DEPRECATION = new Map(Object.entries(CONFIG_DEPRECAT
34
34
  ]));
35
35
 
36
36
  const version = {
37
- lib: '19.0.0-next.21',
38
- releaseDate: 1750170617891
37
+ lib: '19.0.0-next.22',
38
+ releaseDate: 1750273161927
39
39
  };
40
40
 
41
41
  class ConfigService {
@@ -1 +1 @@
1
- {"version":3,"file":"igo2-core-config.mjs","sources":["../../../packages/core/config/src/config-deprecated.ts","../../../packages/core/config/src/version.ts","../../../packages/core/config/src/config.service.ts","../../../packages/core/config/src/config.provider.ts","../../../packages/core/config/src/config.module.ts","../../../packages/core/config/src/igo2-core-config.ts"],"sourcesContent":["import { AlternateConfigOptions, DeprecatedOptions } from './config.interface';\n\nexport const CONFIG_DEPRECATED: Record<string, DeprecatedOptions> = {\n showMenuButton: {\n alternativeKey: 'menu.button.visible',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n menuButtonReverseColor: {\n alternativeKey: 'menu.button.useThemeColor',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n importWithStyle: {\n alternativeKey: 'importExport.importWithStyle',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n hasGeolocateButton: {\n alternativeKey: 'geolocate.button.visible',\n mayBeRemoveIn: new Date('2024-06-06')\n }\n};\n\nexport const ALTERNATE_CONFIG_FROM_DEPRECATION = new Map<\n string,\n AlternateConfigOptions\n>(\n Object.entries(CONFIG_DEPRECATED)\n .filter(([_, options]) => options.alternativeKey)\n .map(([key, options]) => [\n options.alternativeKey,\n {\n deprecatedKey: key\n } satisfies AlternateConfigOptions\n ])\n);\n","export interface Version {\n app?: string;\n lib?: string;\n releaseDateApp?: number;\n releaseDate?: number;\n}\n\nexport const version: Version = {\n lib: '19.0.0-next.21',\n releaseDate: 1750170617891\n};\n","import { HttpBackend, HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\n\nimport { ObjectUtils } from '@igo2/utils';\n\nimport { BehaviorSubject, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport {\n ALTERNATE_CONFIG_FROM_DEPRECATION,\n CONFIG_DEPRECATED\n} from './config-deprecated';\nimport { ConfigOptions } from './config.interface';\nimport { version } from './version';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<T extends object = Record<string, any>> {\n private config: T | null;\n private httpClient: HttpClient;\n private configDeprecated = new Map(Object.entries(CONFIG_DEPRECATED));\n\n private _isLoaded$ = new BehaviorSubject<boolean>(null);\n isLoaded$ = this._isLoaded$.asObservable();\n\n constructor(handler: HttpBackend) {\n this.httpClient = new HttpClient(handler);\n }\n\n /**\n * Use to get the all config file (merge from environnement.ts and config.json)\n */\n public getConfigs(): any {\n Array.from(this.configDeprecated.keys()).map((deprecatedKey) => {\n const deprecatedValue = ObjectUtils.resolve(this.config, deprecatedKey);\n if (deprecatedValue !== undefined) {\n this.handleDeprecatedConfig(deprecatedKey);\n }\n });\n return this.config;\n }\n\n /**\n * Use to get the data found in config file\n */\n public getConfig<T = any>(key: string, defaultValue?: unknown): T {\n let value = ObjectUtils.resolve(this.config, key);\n\n const isDeprecated = this.configDeprecated.get(key);\n if (isDeprecated && value !== undefined) {\n this.handleDeprecatedConfig(key);\n } else if (value === undefined) {\n value = this.handleDeprecationPossibility(key);\n }\n\n return value ?? defaultValue;\n }\n\n private handleDeprecatedConfig(key: string): void {\n const options = this.configDeprecated.get(key);\n\n let message = `This config (${key}) is deprecated and will be removed shortly`;\n if (options.alternativeKey) {\n message += ` You should use this key (${options.alternativeKey}) as an alternate solution`;\n }\n\n const currentDate = new Date();\n currentDate >= options.mayBeRemoveIn\n ? console.error(message)\n : console.warn(message);\n }\n\n private handleDeprecationPossibility(key: string): any {\n const options = ALTERNATE_CONFIG_FROM_DEPRECATION.get(key);\n if (!options) {\n return;\n }\n\n return this.getConfig(options.deprecatedKey);\n }\n\n /**\n * This method loads \"[path]\" to get all config's variables\n */\n public load(options: ConfigOptions<T>): void | Promise<unknown> {\n const baseConfig = options.default;\n if (!options.path) {\n this.config = baseConfig;\n this._isLoaded$.next(true);\n return;\n }\n\n return new Promise((resolve) => {\n this.httpClient\n .get(options.path)\n .pipe(\n catchError((error: any): any => {\n console.log(`Configuration file ${options.path} could not be read`);\n this._isLoaded$.next(false);\n resolve(true);\n return throwError(error.error || 'Server error');\n })\n )\n .subscribe((configResponse: object) => {\n this.config = ObjectUtils.mergeDeep(\n ObjectUtils.mergeDeep({ version }, baseConfig),\n configResponse\n );\n this._isLoaded$.next(true);\n resolve(true);\n });\n });\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n inject,\n makeEnvironmentProviders,\n provideAppInitializer\n} from '@angular/core';\n\nimport { ConfigOptions } from './config.interface';\nimport { ConfigService } from './config.service';\n\nexport const CONFIG_OPTIONS = new InjectionToken<ConfigOptions>(\n 'configOptions'\n);\n\nexport function provideConfig(options: ConfigOptions): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: CONFIG_OPTIONS,\n useValue: options\n },\n provideAppInitializer(async () => {\n const configService = inject(ConfigService);\n const options = inject(CONFIG_OPTIONS);\n return configService.load(options);\n })\n ]);\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { provideConfig } from './config.provider';\n\n/**\n * @deprecated import the provideConfig directly\n */\n@NgModule({\n imports: [],\n declarations: [],\n exports: []\n})\nexport class IgoConfigModule {\n static forRoot(): ModuleWithProviders<IgoConfigModule> {\n return {\n ngModule: IgoConfigModule,\n providers: [provideConfig({})]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAEO,MAAM,iBAAiB,GAAsC;AAClE,IAAA,cAAc,EAAE;AACd,QAAA,cAAc,EAAE,qBAAqB;AACrC,QAAA,aAAa,EAA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A,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;AACV,iBAAA;;;ACXD;;AAEG;;;;"}
1
+ {"version":3,"file":"igo2-core-config.mjs","sources":["../../../packages/core/config/src/config-deprecated.ts","../../../packages/core/config/src/version.ts","../../../packages/core/config/src/config.service.ts","../../../packages/core/config/src/config.provider.ts","../../../packages/core/config/src/config.module.ts","../../../packages/core/config/src/igo2-core-config.ts"],"sourcesContent":["import { AlternateConfigOptions, DeprecatedOptions } from './config.interface';\n\nexport const CONFIG_DEPRECATED: Record<string, DeprecatedOptions> = {\n showMenuButton: {\n alternativeKey: 'menu.button.visible',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n menuButtonReverseColor: {\n alternativeKey: 'menu.button.useThemeColor',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n importWithStyle: {\n alternativeKey: 'importExport.importWithStyle',\n mayBeRemoveIn: new Date('2024-06-06')\n },\n hasGeolocateButton: {\n alternativeKey: 'geolocate.button.visible',\n mayBeRemoveIn: new Date('2024-06-06')\n }\n};\n\nexport const ALTERNATE_CONFIG_FROM_DEPRECATION = new Map<\n string,\n AlternateConfigOptions\n>(\n Object.entries(CONFIG_DEPRECATED)\n .filter(([_, options]) => options.alternativeKey)\n .map(([key, options]) => [\n options.alternativeKey,\n {\n deprecatedKey: key\n } satisfies AlternateConfigOptions\n ])\n);\n","export interface Version {\n app?: string;\n lib?: string;\n releaseDateApp?: number;\n releaseDate?: number;\n}\n\nexport const version: Version = {\n lib: '19.0.0-next.22',\n releaseDate: 1750273161927\n};\n","import { HttpBackend, HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\n\nimport { ObjectUtils } from '@igo2/utils';\n\nimport { BehaviorSubject, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\n\nimport {\n ALTERNATE_CONFIG_FROM_DEPRECATION,\n CONFIG_DEPRECATED\n} from './config-deprecated';\nimport { ConfigOptions } from './config.interface';\nimport { version } from './version';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class ConfigService<T extends object = Record<string, any>> {\n private config: T | null;\n private httpClient: HttpClient;\n private configDeprecated = new Map(Object.entries(CONFIG_DEPRECATED));\n\n private _isLoaded$ = new BehaviorSubject<boolean>(null);\n isLoaded$ = this._isLoaded$.asObservable();\n\n constructor(handler: HttpBackend) {\n this.httpClient = new HttpClient(handler);\n }\n\n /**\n * Use to get the all config file (merge from environnement.ts and config.json)\n */\n public getConfigs(): any {\n Array.from(this.configDeprecated.keys()).map((deprecatedKey) => {\n const deprecatedValue = ObjectUtils.resolve(this.config, deprecatedKey);\n if (deprecatedValue !== undefined) {\n this.handleDeprecatedConfig(deprecatedKey);\n }\n });\n return this.config;\n }\n\n /**\n * Use to get the data found in config file\n */\n public getConfig<T = any>(key: string, defaultValue?: unknown): T {\n let value = ObjectUtils.resolve(this.config, key);\n\n const isDeprecated = this.configDeprecated.get(key);\n if (isDeprecated && value !== undefined) {\n this.handleDeprecatedConfig(key);\n } else if (value === undefined) {\n value = this.handleDeprecationPossibility(key);\n }\n\n return value ?? defaultValue;\n }\n\n private handleDeprecatedConfig(key: string): void {\n const options = this.configDeprecated.get(key);\n\n let message = `This config (${key}) is deprecated and will be removed shortly`;\n if (options.alternativeKey) {\n message += ` You should use this key (${options.alternativeKey}) as an alternate solution`;\n }\n\n const currentDate = new Date();\n currentDate >= options.mayBeRemoveIn\n ? console.error(message)\n : console.warn(message);\n }\n\n private handleDeprecationPossibility(key: string): any {\n const options = ALTERNATE_CONFIG_FROM_DEPRECATION.get(key);\n if (!options) {\n return;\n }\n\n return this.getConfig(options.deprecatedKey);\n }\n\n /**\n * This method loads \"[path]\" to get all config's variables\n */\n public load(options: ConfigOptions<T>): void | Promise<unknown> {\n const baseConfig = options.default;\n if (!options.path) {\n this.config = baseConfig;\n this._isLoaded$.next(true);\n return;\n }\n\n return new Promise((resolve) => {\n this.httpClient\n .get(options.path)\n .pipe(\n catchError((error: any): any => {\n console.log(`Configuration file ${options.path} could not be read`);\n this._isLoaded$.next(false);\n resolve(true);\n return throwError(error.error || 'Server error');\n })\n )\n .subscribe((configResponse: object) => {\n this.config = ObjectUtils.mergeDeep(\n ObjectUtils.mergeDeep({ version }, baseConfig),\n configResponse\n );\n this._isLoaded$.next(true);\n resolve(true);\n });\n });\n }\n}\n","import {\n EnvironmentProviders,\n InjectionToken,\n inject,\n makeEnvironmentProviders,\n provideAppInitializer\n} from '@angular/core';\n\nimport { ConfigOptions } from './config.interface';\nimport { ConfigService } from './config.service';\n\nexport const CONFIG_OPTIONS = new InjectionToken<ConfigOptions>(\n 'configOptions'\n);\n\nexport function provideConfig(options: ConfigOptions): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: CONFIG_OPTIONS,\n useValue: options\n },\n provideAppInitializer(async () => {\n const configService = inject(ConfigService);\n const options = inject(CONFIG_OPTIONS);\n return configService.load(options);\n })\n ]);\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\n\nimport { provideConfig } from './config.provider';\n\n/**\n * @deprecated import the provideConfig directly\n */\n@NgModule({\n imports: [],\n declarations: [],\n exports: []\n})\nexport class IgoConfigModule {\n static forRoot(): ModuleWithProviders<IgoConfigModule> {\n return {\n ngModule: IgoConfigModule,\n providers: [provideConfig({})]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAEO,MAAM,iBAAiB,GAAsC;AAClE,IAAA,cAAc,EAAE;AACd,QAAA,cAAc,EAAE,qBAAqB;AACrC,QAAA,aAAa,EAAE,IAAI,IAAI,CAAC,YAAY;AACrC,KAAA;AACD,IAAA,sBAAsB,EAAE;AACtB,QAAA,cAAc,EAAE,2BAA2B;AAC3C,QAAA,aAAa,EAAE,IAAI,IAAI,CAAC,YAAY;AACrC,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,cAAc,EAAE,8BAA8B;AAC9C,QAA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orHandler, provideAppInitializer, inject } from '@angular/core';
2
2
  import { Router } from '@angular/router';
3
- import { setUser, createErrorHandler, getClient, browserTracingIntegration, replayIntegration, init, TraceService } from '@sentry/angular';
3
+ import { createErrorHandler, getClient, init, browserTracingIntegration, TraceService, setUser } from '@sentry/angular';
4
4
 
5
- const isTracingEnabled = (options) => !!options.tracesSampleRate || !!options.tracesSampler;
6
- const isReplayEnabled = (options) => !!options.replaysSessionSampleRate || !!options.replaysOnErrorSampleRate;
7
- const identifySentryUser = (user) => {
8
- setUser(user
9
- ? {
10
- id: user.id,
11
- username: `${user.firstName} ${user.lastName}`,
12
- email: user.email
13
- }
14
- : null);
15
- };
5
+ const MONITORING_OPTIONS = new InjectionToken('monitoring.options');
16
6
 
17
7
  const createSentryErrorHandler = (options) => {
18
8
  return createErrorHandler({
@@ -25,59 +15,68 @@ const initSentry = (options, force) => {
25
15
  if (!force && client) {
26
16
  return;
27
17
  }
28
- const baseConfig = {
29
- ...options,
30
- integrations: [
31
- isTracingEnabled(options) && browserTracingIntegration(),
32
- isReplayEnabled(options) && replayIntegration()
33
- ].filter(Boolean)
34
- };
35
- init(baseConfig);
18
+ init(options);
36
19
  };
37
20
 
38
- const provideSentryMonitoring = (options) => {
21
+ const provideSentryMonitoring = (options, integrations) => {
39
22
  const isEnabled = options.enabled !== undefined ? options.enabled : true;
40
23
  if (!isEnabled) {
41
24
  return [];
42
25
  }
43
- initSentry(options);
44
- const tracingEnabled = isTracingEnabled(options);
45
- return [
26
+ const providers = [
27
+ { provide: MONITORING_OPTIONS, useValue: options },
46
28
  {
47
29
  provide: ErrorHandler,
48
30
  useFactory: () => createSentryErrorHandler(options)
49
- },
50
- tracingEnabled && {
51
- provide: TraceService,
52
- deps: [Router]
53
- },
54
- // Force instantiate TraceService to avoid require it in any constructor.
55
- tracingEnabled &&
56
- provideAppInitializer(() => {
57
- inject(TraceService);
58
- return;
59
- })
60
- ].filter(Boolean);
61
- };
62
-
63
- const MONITORING_OPTIONS = new InjectionToken('monitoring.options');
64
- function provideMonitoring(options) {
65
- if (!options) {
66
- return [];
67
- }
68
- const providers = [
69
- { provide: MONITORING_OPTIONS, useValue: options }
31
+ }
70
32
  ];
71
- switch (options.provider) {
72
- case 'sentry':
73
- providers.push(...provideSentryMonitoring(options));
74
- break;
75
- default:
76
- break;
33
+ if (integrations) {
34
+ for (const integration of integrations) {
35
+ const value = integration(options);
36
+ providers.push(...value.providers);
37
+ }
77
38
  }
39
+ initSentry(options);
78
40
  return providers;
41
+ };
42
+ var SentryIntegrationKind;
43
+ (function (SentryIntegrationKind) {
44
+ SentryIntegrationKind[SentryIntegrationKind["Tracing"] = 0] = "Tracing";
45
+ SentryIntegrationKind[SentryIntegrationKind["Replay"] = 1] = "Replay";
46
+ })(SentryIntegrationKind || (SentryIntegrationKind = {}));
47
+ function withTracingIntegration(options) {
48
+ return (sentryOptions) => {
49
+ sentryOptions.integrations = [
50
+ ...(sentryOptions.integrations ?? []),
51
+ browserTracingIntegration(options)
52
+ ];
53
+ return {
54
+ kind: SentryIntegrationKind.Tracing,
55
+ providers: [
56
+ {
57
+ provide: TraceService,
58
+ deps: [Router]
59
+ },
60
+ // Force instantiate TraceService to avoid require it in any constructor.
61
+ provideAppInitializer(() => {
62
+ inject(TraceService);
63
+ return;
64
+ })
65
+ ]
66
+ };
67
+ };
79
68
  }
80
69
 
70
+ const identifySentryUser = (user) => {
71
+ setUser(user
72
+ ? {
73
+ id: user.id,
74
+ username: `${user.firstName} ${user.lastName}`,
75
+ email: user.email
76
+ }
77
+ : null);
78
+ };
79
+
81
80
  const MOCK_SENTRY_OPTIONS = {
82
81
  provider: 'sentry',
83
82
  dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
@@ -89,5 +88,5 @@ const MOCK_MONITORING_OPTIONS = MOCK_SENTRY_OPTIONS;
89
88
  * Generated bundle index. Do not edit.
90
89
  */
91
90
 
92
- export { MOCK_MONITORING_OPTIONS, MOCK_SENTRY_OPTIONS, MONITORING_OPTIONS, identifySentryUser, isReplayEnabled, isTracingEnabled, provideMonitoring, provideSentryMonitoring };
91
+ export { MOCK_MONITORING_OPTIONS, MOCK_SENTRY_OPTIONS, MONITORING_OPTIONS, SentryIntegrationKind, identifySentryUser, provideSentryMonitoring, withTracingIntegration };
93
92
  //# sourceMappingURL=igo2-core-monitoring.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"igo2-core-monitoring.mjs","sources":["../../../packages/core/monitoring/src/sentry/sentry.utils.ts","../../../packages/core/monitoring/src/sentry/sentry.ts","../../../packages/core/monitoring/src/sentry/sentry.provider.ts","../../../packages/core/monitoring/src/monitoring.provider.ts","../../../packages/core/monitoring/src/__mocks__/monitoring-mock.ts","../../../packages/core/monitoring/src/igo2-core-monitoring.ts"],"sourcesContent":["import { BaseUser } from '@igo2/core/user';\n\nimport { setUser } from '@sentry/angular';\n\nimport { SentryMonitoringOptions } from './sentry.interface';\n\nexport const isTracingEnabled = (options: SentryMonitoringOptions): boolean =>\n !!options.tracesSampleRate || !!options.tracesSampler;\n\nexport const isReplayEnabled = (options: SentryMonitoringOptions): boolean =>\n !!options.replaysSessionSampleRate || !!options.replaysOnErrorSampleRate;\n\nexport const identifySentryUser = (user: BaseUser | null): void => {\n setUser(\n user\n ? {\n id: user.id,\n username: `${user.firstName} ${user.lastName}`,\n email: user.email\n }\n : null\n );\n};\n","import {\n BrowserOptions,\n SentryErrorHandler,\n browserTracingIntegration,\n createErrorHandler,\n getClient,\n init,\n replayIntegration\n} from '@sentry/angular';\n\nimport { SentryMonitoringOptions } from './sentry.interface';\nimport { isReplayEnabled, isTracingEnabled } from './sentry.utils';\n\nexport const createSentryErrorHandler = (\n options: SentryMonitoringOptions\n): SentryErrorHandler => {\n return createErrorHandler({\n logErrors: options.logErrors,\n ...(options.errorHandlerOptions ?? {})\n });\n};\n\nexport const initSentry = (\n options: SentryMonitoringOptions,\n force?: boolean\n): void => {\n const client = getClient();\n if (!force && client) {\n return;\n }\n\n const baseConfig: BrowserOptions = {\n ...options,\n integrations: [\n isTracingEnabled(options) && browserTracingIntegration(),\n isReplayEnabled(options) && replayIntegration()\n ].filter(Boolean)\n };\n\n init(baseConfig);\n};\n","import {\n ConstructorProvider,\n EnvironmentProviders,\n ErrorHandler,\n inject,\n provideAppInitializer\n} from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { TraceService } from '@sentry/angular';\n\nimport { createSentryErrorHandler, initSentry } from './sentry';\nimport { SentryMonitoringOptions } from './sentry.interface';\nimport { isTracingEnabled } from './sentry.utils';\n\nexport const provideSentryMonitoring = (\n options: SentryMonitoringOptions\n): (EnvironmentProviders | ConstructorProvider)[] => {\n const isEnabled = options.enabled !== undefined ? options.enabled : true;\n if (!isEnabled) {\n return [];\n }\n\n initSentry(options);\n\n const tracingEnabled = isTracingEnabled(options);\n\n return [\n {\n provide: ErrorHandler,\n useFactory: () => createSentryErrorHandler(options)\n },\n tracingEnabled && {\n provide: TraceService,\n deps: [Router]\n },\n // Force instantiate TraceService to avoid require it in any constructor.\n tracingEnabled &&\n provideAppInitializer(() => {\n inject(TraceService);\n return;\n })\n ].filter(Boolean);\n};\n","import { EnvironmentProviders, InjectionToken, Provider } from '@angular/core';\n\nimport { provideSentryMonitoring } from './sentry/sentry.provider';\nimport { AnyMonitoringOptions, MonitoringOptions } from './shared';\n\nexport const MONITORING_OPTIONS = new InjectionToken<MonitoringOptions | null>(\n 'monitoring.options'\n);\n\nexport function provideMonitoring(\n options: AnyMonitoringOptions | null\n): (EnvironmentProviders | Provider)[] {\n if (!options) {\n return [];\n }\n\n const providers: (EnvironmentProviders | Provider)[] = [\n { provide: MONITORING_OPTIONS, useValue: options }\n ];\n\n switch (options.provider) {\n case 'sentry':\n providers.push(...provideSentryMonitoring(options));\n break;\n default:\n break;\n }\n\n return providers;\n}\n","import { SentryMonitoringOptions } from '../sentry';\nimport { AnyMonitoringOptions } from '../shared';\n\nexport const MOCK_SENTRY_OPTIONS: SentryMonitoringOptions = {\n provider: 'sentry',\n dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',\n identifyUser: true\n};\n\nexport const MOCK_MONITORING_OPTIONS: AnyMonitoringOptions =\n MOCK_SENTRY_OPTIONS;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAMa,gBAAgB,GAAG,CAAC,OAAgC,KAC/D,CAAC,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,CAAC,OAAO,CAAC;MAE7B,eAAe,GAAG,CAAC,OAAgC,KAC9D,CAAC,CAAC,OAAO,CAAC,wBAAwB,IAAI,CAAC,CAAC,OAAO,CAAC;AAErC,MAAA,kBAAkB,GAAG,CAAC,IAAqB,KAAU;AAChE,IAAA,OAAO,CACL;AACE,UAAE;YACE,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAI,CAAA,EAAA,IAAI,CAAC,QAAQ,CAAE,CAAA;YAC9C,KAAK,EAAE,IAAI,CAAC;AACb;UACD,IAAI,CACT;AACH;;ACTO,MAAM,wBAAwB,GAAG,CACtC,OAAgC,KACV;AACtB,IAAA,OAAO,kBAAkB,CAAC;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;AAC5B,QAAA,IAAI,OAAO,CAAC,mBAAmB,IAAI,EAAE;AACtC,KAAA,CAAC;AACJ,CAAC;AAEM,MAAM,UAAU,GAAG,CACxB,OAAgC,EAChC,KAAe,KACP;AACR,IAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAC1B,IAAA,IAAI,CAAC,KAAK,IAAI,MAAM,EAAE;QACpB;;AAGF,IAAA,MAAM,UAAU,GAAmB;AACjC,QAAA,GAAG,OAAO;AACV,QAAA,YAAY,EAAE;AACZ,YAAA,gBAAgB,CAAC,OAAO,CAAC,IAAI,yBAAyB,EAAE;AACxD,YAAA,eAAe,CAAC,OAAO,CAAC,IAAI,iBAAiB;SAC9C,CAAC,MAAM,CAAC,OAAO;KACjB;IAED,IAAI,C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AuB,GAClC;;ACVF;;AAEG;;;;"}
1
+ {"version":3,"file":"igo2-core-monitoring.mjs","sources":["../../../packages/core/monitoring/src/shared/monitoring.ts","../../../packages/core/monitoring/src/sentry/sentry.ts","../../../packages/core/monitoring/src/sentry/sentry.provider.ts","../../../packages/core/monitoring/src/sentry/sentry.utils.ts","../../../packages/core/monitoring/src/__mocks__/monitoring-mock.ts","../../../packages/core/monitoring/src/igo2-core-monitoring.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { MonitoringOptions } from './monitoring.interface';\n\nexport const MONITORING_OPTIONS = new InjectionToken<MonitoringOptions | null>(\n 'monitoring.options'\n);\n","import {\n SentryErrorHandler,\n createErrorHandler,\n getClient,\n init\n} from '@sentry/angular';\n\nimport { SentryMonitoringOptions } from './sentry.interface';\n\nexport const createSentryErrorHandler = (\n options: SentryMonitoringOptions\n): SentryErrorHandler => {\n return createErrorHandler({\n logErrors: options.logErrors,\n ...(options.errorHandlerOptions ?? {})\n });\n};\n\nexport const initSentry = (\n options: SentryMonitoringOptions,\n force?: boolean\n): void => {\n const client = getClient();\n if (!force && client) {\n return;\n }\n\n init(options);\n};\n","import {\n EnvironmentProviders,\n ErrorHandler,\n Provider,\n inject,\n provideAppInitializer\n} from '@angular/core';\nimport { Router } from '@angular/router';\n\nimport { TraceService, browserTracingIntegration } from '@sentry/angular';\n\nimport { MONITORING_OPTIONS } from '../shared';\nimport { createSentryErrorHandler, initSentry } from './sentry';\nimport { SentryMonitoringOptions } from './sentry.interface';\n\nexport const provideSentryMonitoring = (\n options: SentryMonitoringOptions,\n integrations?: SentryIntegrationFactory<SentryIntegrationKind>[]\n): (Provider | EnvironmentProviders)[] => {\n const isEnabled = options.enabled !== undefined ? options.enabled : true;\n if (!isEnabled) {\n return [];\n }\n\n const providers: (Provider | EnvironmentProviders)[] = [\n { provide: MONITORING_OPTIONS, useValue: options },\n {\n provide: ErrorHandler,\n useFactory: () => createSentryErrorHandler(options)\n }\n ];\n\n if (integrations) {\n for (const integration of integrations) {\n const value = integration(options);\n providers.push(...value.providers);\n }\n }\n\n initSentry(options);\n\n return providers;\n};\n\nexport interface SentryIntegration<KindT extends SentryIntegrationKind> {\n kind: KindT;\n providers: (Provider | EnvironmentProviders)[];\n}\n\ntype SentryIntegrationFactory<KindT extends SentryIntegrationKind> = (\n sentryOptions: SentryMonitoringOptions\n) => SentryIntegration<KindT>;\n\nexport enum SentryIntegrationKind {\n Tracing = 0,\n Replay = 1\n}\n\nexport function withTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0]\n): SentryIntegrationFactory<SentryIntegrationKind.Tracing> {\n return (sentryOptions: SentryMonitoringOptions) => {\n sentryOptions.integrations = [\n ...(sentryOptions.integrations ?? []),\n browserTracingIntegration(options)\n ];\n\n return {\n kind: SentryIntegrationKind.Tracing,\n providers: [\n {\n provide: TraceService,\n deps: [Router]\n },\n // Force instantiate TraceService to avoid require it in any constructor.\n provideAppInitializer(() => {\n inject(TraceService);\n return;\n })\n ]\n };\n };\n}\n","import { BaseUser } from '@igo2/core/user';\n\nimport { setUser } from '@sentry/angular';\n\nexport const identifySentryUser = (user: BaseUser | null): void => {\n setUser(\n user\n ? {\n id: user.id,\n username: `${user.firstName} ${user.lastName}`,\n email: user.email\n }\n : null\n );\n};\n","import { SentryMonitoringOptions } from '../sentry';\nimport { AnyMonitoringOptions } from '../shared';\n\nexport const MOCK_SENTRY_OPTIONS: SentryMonitoringOptions = {\n provider: 'sentry',\n dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',\n identifyUser: true\n};\n\nexport const MOCK_MONITORING_OPTIONS: AnyMonitoringOptions =\n MOCK_SENTRY_OPTIONS;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAIa,kBAAkB,GAAG,IAAI,cAAc,CAClD,oBAAoB;;ACIf,MAAM,wBAAwB,GAAG,CACtC,OAAgC,KACV;AACtB,IAAA,OAAO,kBAAkB,CAAC;QACxB,S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,SAAU,sBAAsB,CACpC,OAAwD,EAAA;IAExD,OAAO,CAAC,aAAsC,KAAI;QAChD,aAAa,CAAC,YAAY,GAAG;AAC3B,YAAA,IAAI,aAAa,CAAC,YAAY,IAAI,EAAE,CAAC;YACrC,yBAAyB,CAAC,OAAO;SAClC;QAED,OAAO;YACL,IAAI,EAAE,qBAAqB,CAAC,OAAO;AACnC,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,YAAY;oBACrB,IAAI,EAAE,CAAC,MAAM;AACd,iBAAA;;gBAED,qBAAqB,CAAC,MAAK;oBACzB,MAAM,CAAC,YAAY,CAAC;oBACpB;AACF,iBAAC;AACF;SACF;AACH,KAAC;AACH;;AC9Ea,MAAA,kBAAkB,GAAG,CAAC,IAAqB,KAAU;AAChE,IAAA,OAAO,CACL;AACE,UAAE;YACE,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAI,CAAA,EAAA,IAAI,CAAC,QAAQ,CAAE,CAAA;YAC9C,KAAK,EAAE,IAAI,CAAC;AACb;UACD,IAAI,CACT;AACH;;ACXa,MAAA,mBAAmB,GAA4B;AAC1D,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,GAAG,EAAE,gDAAgD;AACrD,IAAA,YAAY,EAAE;;AAGT,MAAM,uBAAuB,GAClC;;ACVF;;AAEG;;;;"}
@@ -1,4 +1,3 @@
1
1
  export * from './sentry';
2
2
  export * from './shared';
3
- export * from './monitoring.provider';
4
3
  export * from './__mocks__';
@@ -1,6 +1,8 @@
1
1
  import { BrowserOptions, ErrorHandlerOptions } from '@sentry/angular';
2
+ import { Integration } from '@sentry/core';
2
3
  import { MonitoringOptions } from '../shared/monitoring.interface';
3
4
  export type SentryMonitoringOptions = BrowserOptions & MonitoringOptions & {
4
5
  provider: 'sentry';
5
6
  errorHandlerOptions?: ErrorHandlerOptions;
7
+ integrations?: Integration[];
6
8
  };
@@ -1,3 +1,15 @@
1
- import { ConstructorProvider, EnvironmentProviders } from '@angular/core';
1
+ import { EnvironmentProviders, Provider } from '@angular/core';
2
+ import { browserTracingIntegration } from '@sentry/angular';
2
3
  import { SentryMonitoringOptions } from './sentry.interface';
3
- export declare const provideSentryMonitoring: (options: SentryMonitoringOptions) => (EnvironmentProviders | ConstructorProvider)[];
4
+ export declare const provideSentryMonitoring: (options: SentryMonitoringOptions, integrations?: SentryIntegrationFactory<SentryIntegrationKind>[]) => (Provider | EnvironmentProviders)[];
5
+ export interface SentryIntegration<KindT extends SentryIntegrationKind> {
6
+ kind: KindT;
7
+ providers: (Provider | EnvironmentProviders)[];
8
+ }
9
+ type SentryIntegrationFactory<KindT extends SentryIntegrationKind> = (sentryOptions: SentryMonitoringOptions) => SentryIntegration<KindT>;
10
+ export declare enum SentryIntegrationKind {
11
+ Tracing = 0,
12
+ Replay = 1
13
+ }
14
+ export declare function withTracingIntegration(options: Parameters<typeof browserTracingIntegration>[0]): SentryIntegrationFactory<SentryIntegrationKind.Tracing>;
15
+ export {};
@@ -1,5 +1,2 @@
1
1
  import { BaseUser } from '@igo2/core/user';
2
- import { SentryMonitoringOptions } from './sentry.interface';
3
- export declare const isTracingEnabled: (options: SentryMonitoringOptions) => boolean;
4
- export declare const isReplayEnabled: (options: SentryMonitoringOptions) => boolean;
5
2
  export declare const identifySentryUser: (user: BaseUser | null) => void;
@@ -1,2 +1,3 @@
1
1
  export * from './any-monitoring.interface';
2
2
  export * from './monitoring.interface';
3
+ export * from './monitoring';
@@ -0,0 +1,3 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { MonitoringOptions } from './monitoring.interface';
3
+ export declare const MONITORING_OPTIONS: InjectionToken<MonitoringOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@igo2/core",
3
- "version": "19.0.0-next.21",
3
+ "version": "19.0.0-next.22",
4
4
  "description": "IGO Library",
5
5
  "author": "IGO Community",
6
6
  "keywords": [
@@ -109,7 +109,7 @@
109
109
  "@angular/core": "^19.0.0",
110
110
  "@angular/platform-browser": "^19.0.0",
111
111
  "@angular/router": "^19.0.0",
112
- "@igo2/utils": "^19.0.0-next.21",
112
+ "@igo2/utils": "^19.0.0-next.22",
113
113
  "ngx-toastr": "^19.0.0",
114
114
  "@ngx-translate/core": "^16.0.0",
115
115
  "@ngx-translate/http-loader": "^16.0.0",
@@ -1,4 +0,0 @@
1
- import { EnvironmentProviders, InjectionToken, Provider } from '@angular/core';
2
- import { AnyMonitoringOptions, MonitoringOptions } from './shared';
3
- export declare const MONITORING_OPTIONS: InjectionToken<MonitoringOptions>;
4
- export declare function provideMonitoring(options: AnyMonitoringOptions | null): (EnvironmentProviders | Provider)[];