@rxap/nest-sentry 10.5.5-dev.6 → 10.6.0-dev.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.6.0-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/nest-sentry@10.5.5-dev.6...@rxap/nest-sentry@10.6.0-dev.0) (2025-05-16)
7
+
8
+ ### Features
9
+
10
+ - **sentry:** remove SentryService and streamline integration ([68d77b9](https://gitlab.com/rxap/packages/commit/68d77b9ac0b91dbab455c0472c58ade93d831851))
11
+ - **sentry:** remove SentryService and streamline integration ([92c37bb](https://gitlab.com/rxap/packages/commit/92c37bb6fa4b75d6c9f970e42090ff6619949749))
12
+
6
13
  ## [10.5.5-dev.6](https://gitlab.com/rxap/packages/compare/@rxap/nest-sentry@10.5.5-dev.5...@rxap/nest-sentry@10.5.5-dev.6) (2025-04-22)
7
14
 
8
15
  ### Bug Fixes
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "10.5.5-dev.6",
2
+ "version": "10.6.0-dev.0",
3
3
  "name": "@rxap/nest-sentry",
4
4
  "description": "This package provides a Sentry integration for NestJS applications. It includes a logger, interceptor, and module to simplify error tracking and performance monitoring with Sentry. It offers configurable options for setting up Sentry in your NestJS application.\n",
5
5
  "license": "GPL-3.0-or-later",
@@ -14,7 +14,7 @@
14
14
  "@nestjs/config": "^3.2.2",
15
15
  "@nestjs/core": "^10.3.8",
16
16
  "@rxap/nest-logger": "^10.3.5-dev.4",
17
- "@rxap/nest-utilities": "^10.4.3-dev.0",
17
+ "@rxap/nest-utilities": "^10.4.3-dev.1",
18
18
  "@sentry/core": "^8.18.0",
19
19
  "@sentry/nestjs": "^8.18.0",
20
20
  "@sentry/node": "^8.18.0",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  {
86
86
  "package": "@rxap/nest-utilities",
87
- "version": "10.4.3-dev.0"
87
+ "version": "10.4.3-dev.1"
88
88
  },
89
89
  {
90
90
  "package": "@rxap/utilities",
@@ -127,7 +127,7 @@
127
127
  },
128
128
  "schematics": "./generators.json",
129
129
  "type": "commonjs",
130
- "gitHead": "c4852b8a1c98c7c153614bdf59c0e8c6a48bda4e",
130
+ "gitHead": "3fa611b2b0cd102039813fb5c696924069fb40f1",
131
131
  "types": "./src/index.d.ts",
132
132
  "main": "./src/index.js"
133
133
  }
package/src/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ export * from './lib/determine-sentry-environment';
2
+ export * from './lib/determine-sentry-release';
1
3
  export * from './lib/sentry-app-config';
4
+ export * from './lib/sentry-init-hook';
2
5
  export * from './lib/sentry-logger.module';
3
6
  export * from './lib/sentry-options.factory';
4
7
  export * from './lib/sentry.interceptor';
package/src/index.js CHANGED
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  // region
5
+ tslib_1.__exportStar(require("./lib/determine-sentry-environment"), exports);
6
+ tslib_1.__exportStar(require("./lib/determine-sentry-release"), exports);
5
7
  tslib_1.__exportStar(require("./lib/sentry-app-config"), exports);
8
+ tslib_1.__exportStar(require("./lib/sentry-init-hook"), exports);
6
9
  tslib_1.__exportStar(require("./lib/sentry-logger.module"), exports);
7
10
  tslib_1.__exportStar(require("./lib/sentry-options.factory"), exports);
8
11
  tslib_1.__exportStar(require("./lib/sentry.interceptor"), exports);
@@ -0,0 +1,10 @@
1
+ import { Environment } from '@rxap/nest-utilities';
2
+ /**
3
+ * Determines the sentry environment based on the build info object.
4
+ *
5
+ * If the tier is local return undefined.
6
+ * If the tier is production determine the environment based on the tag and branch name.
7
+ *
8
+ * @param environment
9
+ */
10
+ export declare function DetermineSentryEnvironment(environment: Environment): string | undefined;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DetermineSentryEnvironment = DetermineSentryEnvironment;
4
+ const nest_utilities_1 = require("@rxap/nest-utilities");
5
+ /**
6
+ * Determines the sentry environment based on the build info object.
7
+ *
8
+ * If the tier is local return undefined.
9
+ * If the tier is production determine the environment based on the tag and branch name.
10
+ *
11
+ * @param environment
12
+ */
13
+ function DetermineSentryEnvironment(environment) {
14
+ switch (environment['tier']) {
15
+ case 'local':
16
+ return undefined;
17
+ case 'production':
18
+ return (0, nest_utilities_1.DetermineProductionEnvironmentName)(environment);
19
+ default:
20
+ return undefined;
21
+ }
22
+ }
@@ -0,0 +1,10 @@
1
+ import { Environment } from '@rxap/nest-utilities';
2
+ /**
3
+ * Determines the sentry release based on the build info object.
4
+ *
5
+ * If the tier is local return undefined.
6
+ * If the tier is production return the tag value as release or undefined.
7
+ *
8
+ * @param environment
9
+ */
10
+ export declare function DetermineSentryRelease(environment: Environment): string | undefined;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DetermineSentryRelease = DetermineSentryRelease;
4
+ /**
5
+ * Determines the sentry release based on the build info object.
6
+ *
7
+ * If the tier is local return undefined.
8
+ * If the tier is production return the tag value as release or undefined.
9
+ *
10
+ * @param environment
11
+ */
12
+ function DetermineSentryRelease(environment) {
13
+ switch (environment.tier) {
14
+ case 'local':
15
+ return undefined;
16
+ case 'development':
17
+ case 'testing':
18
+ case 'staging':
19
+ case 'production':
20
+ return environment.tag ?? undefined;
21
+ default:
22
+ return undefined;
23
+ }
24
+ }
@@ -0,0 +1,2 @@
1
+ import { Environment } from '@rxap/nest-utilities';
2
+ export declare function sentryInitHook(): (_: any, environment: Environment) => void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sentryInitHook = sentryInitHook;
4
+ const Sentry = require("@sentry/nestjs");
5
+ const determine_sentry_environment_1 = require("./determine-sentry-environment");
6
+ const determine_sentry_release_1 = require("./determine-sentry-release");
7
+ const profiling_node_1 = require("@sentry/profiling-node");
8
+ function sentryInitHook() {
9
+ return (_, environment) => {
10
+ const dsn = process.env['SENTRY_DSN'] ?? environment.sentry?.dsn;
11
+ if (!dsn) {
12
+ console.warn('No sentry dsn provided.');
13
+ }
14
+ Sentry.init({
15
+ dsn,
16
+ enabled: process.env['SENTRY_ENABLED'] === 'true' || (environment.sentry?.enabled ?? false),
17
+ debug: process.env['SENTRY_DEBUG'] === 'true' || (environment.sentry?.debug ?? false),
18
+ environment: (0, determine_sentry_environment_1.DetermineSentryEnvironment)(environment),
19
+ release: (0, determine_sentry_release_1.DetermineSentryRelease)(environment),
20
+ integrations: [
21
+ Sentry.captureConsoleIntegration({
22
+ levels: ['error', 'warn'],
23
+ }),
24
+ (0, profiling_node_1.nodeProfilingIntegration)(),
25
+ Sentry.anrIntegration({ captureStackTrace: true }),
26
+ ],
27
+ tracesSampleRate: 1.0,
28
+ profilesSampleRate: 1.0,
29
+ });
30
+ };
31
+ }
@@ -2,9 +2,7 @@ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
2
  import { Scope } from '@sentry/core';
3
3
  import { Observable } from 'rxjs';
4
4
  import { SentryInterceptorOptions } from './sentry.interfaces';
5
- import { SentryService } from './sentry.service';
6
5
  export declare class SentryInterceptor implements NestInterceptor {
7
- protected readonly client: SentryService;
8
6
  protected readonly options?: SentryInterceptorOptions;
9
7
  intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
10
8
  protected captureException(context: ExecutionContext, scope: Scope, exception: unknown): void;
@@ -3,25 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SentryInterceptor = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const common_1 = require("@nestjs/common");
6
+ const Sentry = require("@sentry/nestjs");
6
7
  const node_1 = require("@sentry/node");
7
8
  const operators_1 = require("rxjs/operators");
8
- const sentry_service_1 = require("./sentry.service");
9
9
  const tokens_1 = require("./tokens");
10
10
  let SentryInterceptor = class SentryInterceptor {
11
11
  intercept(context, next) {
12
- if (this.client.hasInstance) {
13
- // first param would be for events, second is for errors
14
- return next.handle().pipe((0, operators_1.tap)({
15
- error: (exception) => {
16
- if (this.shouldReport(exception)) {
17
- this.client.instance().withScope((scope) => {
18
- return this.captureException(context, scope, exception);
19
- });
20
- }
21
- },
22
- }));
23
- }
24
- return next.handle();
12
+ return next.handle().pipe((0, operators_1.tap)({
13
+ error: (exception) => {
14
+ if (this.shouldReport(exception)) {
15
+ Sentry.withScope((scope) => {
16
+ return this.captureException(context, scope, exception);
17
+ });
18
+ }
19
+ },
20
+ }));
25
21
  }
26
22
  captureException(context, scope, exception) {
27
23
  if (exception && typeof exception === 'object' && typeof exception['setScope'] === 'function') {
@@ -45,16 +41,16 @@ let SentryInterceptor = class SentryInterceptor {
45
41
  if (data.user) {
46
42
  scope.setUser(data.user);
47
43
  }
48
- this.client.instance().captureException(exception);
44
+ Sentry.captureException(exception);
49
45
  }
50
46
  captureRpcException(scope, rpc, exception) {
51
47
  scope.setExtra('rpc_data', rpc.getData());
52
- this.client.instance().captureException(exception);
48
+ Sentry.captureException(exception);
53
49
  }
54
50
  captureWsException(scope, ws, exception) {
55
51
  scope.setExtra('ws_client', ws.getClient());
56
52
  scope.setExtra('ws_data', ws.getData());
57
- this.client.instance().captureException(exception);
53
+ Sentry.captureException(exception);
58
54
  }
59
55
  shouldReport(exception) {
60
56
  if (!this.options?.filters) {
@@ -65,10 +61,6 @@ let SentryInterceptor = class SentryInterceptor {
65
61
  }
66
62
  };
67
63
  exports.SentryInterceptor = SentryInterceptor;
68
- tslib_1.__decorate([
69
- (0, common_1.Inject)(sentry_service_1.SentryService),
70
- tslib_1.__metadata("design:type", sentry_service_1.SentryService)
71
- ], SentryInterceptor.prototype, "client", void 0);
72
64
  tslib_1.__decorate([
73
65
  (0, common_1.Optional)(),
74
66
  (0, common_1.Inject)(tokens_1.SENTRY_INTERCEPTOR_OPTIONS),
@@ -5,12 +5,11 @@ exports.SentryModule = exports.DEFAULT_SENTRY_INTERCEPTOR_OPTIONS = exports.ASYN
5
5
  const tslib_1 = require("tslib");
6
6
  const common_1 = require("@nestjs/common");
7
7
  const config_1 = require("@nestjs/config");
8
+ const core_1 = require("@nestjs/core");
8
9
  const nest_logger_1 = require("@rxap/nest-logger");
10
+ const sentry_interceptor_1 = require("./sentry.interceptor");
9
11
  const sentry_logger_1 = require("./sentry.logger");
10
- const sentry_service_1 = require("./sentry.service");
11
12
  const tokens_1 = require("./tokens");
12
- const core_1 = require("@nestjs/core");
13
- const sentry_interceptor_1 = require("./sentry.interceptor");
14
13
  _a = new common_1.ConfigurableModuleBuilder()
15
14
  .setExtras({
16
15
  isGlobal: true,
@@ -88,8 +87,7 @@ exports.SentryModule = SentryModule = tslib_1.__decorate([
88
87
  },
89
88
  sentry_logger_1.SentryLogger,
90
89
  nest_logger_1.RxapLogger,
91
- sentry_service_1.SentryService
92
90
  ],
93
- exports: [common_1.Logger, sentry_service_1.SentryService],
91
+ exports: [common_1.Logger],
94
92
  })
95
93
  ], SentryModule);