UNPKG

@hug/ngx-sentry

Version:

Angular wrapper for the official Sentry JavaScript SDK

1 lines 5.26 kB
{"version":3,"file":"hug-ngx-sentry.mjs","sources":["../../projects/lib/src/ngx-sentry.ts","../../projects/lib/src/ngx-sentry.module.ts","../../projects/lib/src/ngx-sentry.provider.ts","../../projects/lib/src/hug-ngx-sentry.ts"],"sourcesContent":["\nimport { APP_INITIALIZER, ErrorHandler, type Provider } from '@angular/core';\nimport { Router } from '@angular/router';\nimport {\n type BrowserOptions,\n browserTracingIntegration,\n createErrorHandler,\n type ErrorHandlerOptions,\n getCurrentScope,\n init,\n replayIntegration,\n TraceService,\n type User\n} from '@sentry/angular';\n\nexport const NGX_SENTRY_PROVIDERS = (options?: ErrorHandlerOptions): Provider[] => [\n {\n // Automatically send Javascript errors captured by the Angular's error handler\n provide: ErrorHandler,\n useValue: createErrorHandler({\n showDialog: false,\n ...options\n })\n },\n {\n // Register SentryTrace as a provider in Angular's DI system\n provide: TraceService,\n deps: [Router]\n },\n {\n // Force instantiating Tracing\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n provide: APP_INITIALIZER,\n useFactory: () => () => {\n /**/\n },\n deps: [TraceService],\n multi: true\n }\n];\n\nexport type SentryOptions = BrowserOptions &\n Required<Pick<BrowserOptions, 'dsn' | 'environment' | 'release'>> & {\n tracePropagationTargets?: (string | RegExp)[];\n };\n\nexport const setSentryUser = (user: User | null): void => {\n getCurrentScope().setUser(user);\n};\n\nexport const initSentry = (options: SentryOptions): void => {\n const defaultOptions = {\n autoSessionTracking: true,\n integrations: [\n // Registers and configures the Tracing integration, which automatically instruments your\n // application to monitor its performance, including custom Angular routing instrumentation\n browserTracingIntegration(),\n\n // Registers the Replay integration, which automatically captures Session Replays\n replayIntegration()\n ],\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production\n tracesSampleRate: 0.2,\n\n // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled\n tracePropagationTargets: options.tracePropagationTargets ?? ['localhost', /^\\//],\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0\n };\n\n // Initialize Sentry\n init({\n ...defaultOptions,\n ...options\n });\n};\n","import { type ModuleWithProviders, NgModule } from '@angular/core';\nimport type { ErrorHandlerOptions } from '@sentry/angular';\n\nimport { NGX_SENTRY_PROVIDERS } from './ngx-sentry';\n\n@NgModule()\nexport class NgxSentryModule {\n public static forRoot(options?: ErrorHandlerOptions): ModuleWithProviders<NgxSentryModule> {\n return {\n ngModule: NgxSentryModule,\n providers: NGX_SENTRY_PROVIDERS(options)\n };\n }\n}\n","import { type EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport type { ErrorHandlerOptions } from '@sentry/angular';\n\nimport { NGX_SENTRY_PROVIDERS } from './ngx-sentry';\n\nexport const provideSentry = (options?: ErrorHandlerOptions): EnvironmentProviders =>\n makeEnvironmentProviders(NGX_SENTRY_PROVIDERS(options));\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAeO,MAAM,oBAAoB,GAAG,CAAC,OAA6B,KAAiB;AAC/E,IAAA;;AAEI,QAAA,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,kBAAkB,CAAC;AACzB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,GAAG;SACN;AACJ,KAAA;AACD,IAAA;;AAEI,QAAA,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,CAAC,MAAM;AAChB,KAAA;AACD,IAAA;;;AAGI,QAAA,OAAO,EAAE,eAAe;AACxB,QAAA,UAAU,EAAE,MAAM,MAAK;;QAEvB,CAAC;QACD,IAAI,EAAE,CAAC,YAAY,CAAC;AACpB,QAAA,KAAK,EAAE;AACV;CACJ;AAOM,MAAM,aAAa,GAAG,CAAC,IAAiB,KAAU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