UNPKG

@hug/ngx-sentry

Version:

Angular wrapper for the official Sentry JavaScript SDK

1 lines 5.02 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":["/* eslint-disable @typescript-eslint/naming-convention */\nimport { APP_INITIALIZER, ErrorHandler, Provider } from '@angular/core';\nimport { Router } from '@angular/router';\nimport {\n BrowserOptions, browserTracingIntegration, createErrorHandler, ErrorHandlerOptions, getCurrentScope,\n init, replayIntegration, TraceService, User\n} from '@sentry/angular';\n\nexport const NGX_SENTRY_PROVIDERS = (options?: ErrorHandlerOptions): Provider[] => [{\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 // Register SentryTrace as a provider in Angular's DI system\n provide: TraceService,\n deps: [Router]\n}, {\n // Force instantiating Tracing\n provide: APP_INITIALIZER,\n useFactory: () => () => { /**/ },\n deps: [TraceService],\n multi: true\n}];\n\nexport type SentryOptions = BrowserOptions & 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 { ModuleWithProviders, NgModule } from '@angular/core';\nimport { 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 { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { 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":";;;;;AAAA;AAQO,MAAM,oBAAoB,GAAG,CAAC,OAA6B,KAAiB,CAAC;;AAEhF,QAAA,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,kBAAkB,CAAC;AACzB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,GAAG;SACN;KACJ,EAAE;;AAEC,QAAA,OAAO,EAAE,YAAY;QACrB,IAAI,EAAE,CAAC,MAAM;KAChB,EAAE;;AAEC,QAAA,OAAO,EAAE,eAAe;AACxB,QAAA,UAAU,EAAE,MAAM,SAAc;QAChC,IAAI,EAAE,CAAC,YAAY,CAAC;AACpB,QAAA,KAAK,EAAE;AACV,KAAA,CAAC;AAMW,MAAA,aAAa,GAAG,CAAC,IAAiB,KAAU;AACrD,IAAA,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;AACnC;AAEa,MAAA,UA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