@rxap/nest-sentry 11.0.0-dev.5 → 11.0.0-dev.7
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 +10 -0
- package/package.json +7 -7
- package/src/index.d.ts +2 -6
- package/src/index.js +2 -6
- package/src/lib/get-sentry-log-levels.d.ts +2 -0
- package/src/lib/get-sentry-log-levels.js +46 -0
- package/src/lib/sentry-app-config.d.ts +4 -9
- package/src/lib/sentry-app-config.js +2 -16
- package/src/lib/sentry-init-hook.d.ts +2 -1
- package/src/lib/sentry-init-hook.js +5 -3
- package/src/lib/sentry-module-options.factory.d.ts +10 -0
- package/src/lib/sentry-module-options.factory.js +38 -0
- package/src/lib/sentry.interfaces.d.ts +4 -39
- package/src/lib/sentry.logger.d.ts +3 -0
- package/src/lib/sentry.logger.js +63 -20
- package/src/lib/sentry.module.d.ts +5 -12
- package/src/lib/sentry.module.js +14 -36
- package/src/lib/tokens.d.ts +0 -4
- package/src/lib/tokens.js +1 -5
- package/src/lib/sentry-logger.module.d.ts +0 -5
- package/src/lib/sentry-logger.module.js +0 -36
- package/src/lib/sentry-options.factory.d.ts +0 -4
- package/src/lib/sentry-options.factory.js +0 -23
- package/src/lib/sentry.interceptor.d.ts +0 -13
- package/src/lib/sentry.interceptor.js +0 -71
- package/src/lib/sentry.service.d.ts +0 -10
- package/src/lib/sentry.service.js +0 -66
- package/src/lib/setup-sentry-error-handler.d.ts +0 -2
- package/src/lib/setup-sentry-error-handler.js +0 -11
- package/src/lib/setup-sentry-logger.d.ts +0 -6
- package/src/lib/setup-sentry-logger.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [11.0.0-dev.7](https://gitlab.com/rxap/packages/compare/@rxap/nest-sentry@11.0.0-dev.6...@rxap/nest-sentry@11.0.0-dev.7) (2025-09-08)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **nest-sentry:** upgrade to sentry 10 ([2302e70](https://gitlab.com/rxap/packages/commit/2302e70ee4ac4e13b925d812de762d3b6c5a8968))
|
|
11
|
+
|
|
12
|
+
# [11.0.0-dev.6](https://gitlab.com/rxap/packages/compare/@rxap/nest-sentry@11.0.0-dev.5...@rxap/nest-sentry@11.0.0-dev.6) (2025-09-01)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @rxap/nest-sentry
|
|
15
|
+
|
|
6
16
|
# [11.0.0-dev.5](https://gitlab.com/rxap/packages/compare/@rxap/nest-sentry@11.0.0-dev.4...@rxap/nest-sentry@11.0.0-dev.5) (2025-07-02)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "11.0.0-dev.
|
|
2
|
+
"version": "11.0.0-dev.7",
|
|
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",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@nx/devkit": "20.5.0",
|
|
8
|
-
"@rxap/ts-morph": "^1.
|
|
8
|
+
"@rxap/ts-morph": "^1.6.0-dev.0",
|
|
9
9
|
"@rxap/workspace-utilities": "^19.8.1-dev.0",
|
|
10
10
|
"tslib": "2.6.2"
|
|
11
11
|
},
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@nestjs/common": "^11.1.1",
|
|
14
14
|
"@nestjs/config": "^4.0.2",
|
|
15
15
|
"@nestjs/core": "^11.1.1",
|
|
16
|
-
"@rxap/nest-logger": "^11.0.0-dev.
|
|
17
|
-
"@rxap/nest-utilities": "^11.0.0-dev.
|
|
16
|
+
"@rxap/nest-logger": "^11.0.0-dev.3",
|
|
17
|
+
"@rxap/nest-utilities": "^11.0.0-dev.5",
|
|
18
18
|
"@sentry/core": "^8.55.0",
|
|
19
19
|
"@sentry/nestjs": "^8.55.0",
|
|
20
20
|
"@sentry/node": "^8.55.0",
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"package": "@rxap/nest-logger",
|
|
84
|
-
"version": "11.0.0-dev.
|
|
84
|
+
"version": "11.0.0-dev.3"
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
"package": "@rxap/nest-utilities",
|
|
88
|
-
"version": "11.0.0-dev.
|
|
88
|
+
"version": "11.0.0-dev.5"
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
"package": "@rxap/utilities",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
},
|
|
129
129
|
"schematics": "./generators.json",
|
|
130
130
|
"type": "commonjs",
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "34740039c547dace5fe51410d0a3d445a6661622",
|
|
132
132
|
"types": "./src/index.d.ts",
|
|
133
133
|
"main": "./src/index.js"
|
|
134
134
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
export * from './lib/determine-sentry-environment';
|
|
2
2
|
export * from './lib/determine-sentry-release';
|
|
3
|
+
export * from './lib/get-sentry-log-levels';
|
|
3
4
|
export * from './lib/sentry-app-config';
|
|
4
5
|
export * from './lib/sentry-init-hook';
|
|
5
|
-
export * from './lib/sentry-
|
|
6
|
-
export * from './lib/sentry-options.factory';
|
|
7
|
-
export * from './lib/sentry.interceptor';
|
|
6
|
+
export * from './lib/sentry-module-options.factory';
|
|
8
7
|
export * from './lib/sentry.interfaces';
|
|
9
8
|
export * from './lib/sentry.logger';
|
|
10
9
|
export * from './lib/sentry.module';
|
|
11
|
-
export * from './lib/sentry.service';
|
|
12
|
-
export * from './lib/setup-sentry-error-handler';
|
|
13
|
-
export * from './lib/setup-sentry-logger';
|
|
14
10
|
export * from './lib/tokens';
|
|
15
11
|
export * from './lib/use-sentry-logger-factory';
|
package/src/index.js
CHANGED
|
@@ -4,17 +4,13 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
// region
|
|
5
5
|
tslib_1.__exportStar(require("./lib/determine-sentry-environment"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./lib/determine-sentry-release"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/get-sentry-log-levels"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./lib/sentry-app-config"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./lib/sentry-init-hook"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./lib/sentry-
|
|
10
|
-
tslib_1.__exportStar(require("./lib/sentry-options.factory"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./lib/sentry.interceptor"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./lib/sentry-module-options.factory"), exports);
|
|
12
11
|
tslib_1.__exportStar(require("./lib/sentry.interfaces"), exports);
|
|
13
12
|
tslib_1.__exportStar(require("./lib/sentry.logger"), exports);
|
|
14
13
|
tslib_1.__exportStar(require("./lib/sentry.module"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./lib/sentry.service"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./lib/setup-sentry-error-handler"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./lib/setup-sentry-logger"), exports);
|
|
18
14
|
tslib_1.__exportStar(require("./lib/tokens"), exports);
|
|
19
15
|
tslib_1.__exportStar(require("./lib/use-sentry-logger-factory"), exports);
|
|
20
16
|
// endregion
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetSentryLogLevels = GetSentryLogLevels;
|
|
4
|
+
function GetSentryLogLevels(sentryLogLevel = process.env['SENTRY_LOG_LEVEL']) {
|
|
5
|
+
const logLevels = [];
|
|
6
|
+
switch (sentryLogLevel?.toLowerCase()) {
|
|
7
|
+
case 'verbose':
|
|
8
|
+
case 'trace':
|
|
9
|
+
logLevels.push('trace');
|
|
10
|
+
logLevels.push('debug');
|
|
11
|
+
logLevels.push('info');
|
|
12
|
+
logLevels.push('warn');
|
|
13
|
+
logLevels.push('error');
|
|
14
|
+
logLevels.push('fatal');
|
|
15
|
+
break;
|
|
16
|
+
case 'debug':
|
|
17
|
+
logLevels.push('debug');
|
|
18
|
+
logLevels.push('info');
|
|
19
|
+
logLevels.push('warn');
|
|
20
|
+
logLevels.push('error');
|
|
21
|
+
logLevels.push('fatal');
|
|
22
|
+
break;
|
|
23
|
+
case 'log':
|
|
24
|
+
case 'info':
|
|
25
|
+
logLevels.push('info');
|
|
26
|
+
logLevels.push('warn');
|
|
27
|
+
logLevels.push('error');
|
|
28
|
+
logLevels.push('fatal');
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
case 'warn':
|
|
32
|
+
logLevels.push('warn');
|
|
33
|
+
logLevels.push('error');
|
|
34
|
+
logLevels.push('fatal');
|
|
35
|
+
break;
|
|
36
|
+
case 'error':
|
|
37
|
+
logLevels.push('error');
|
|
38
|
+
logLevels.push('fatal');
|
|
39
|
+
break;
|
|
40
|
+
case 'fatal':
|
|
41
|
+
logLevels.push('fatal');
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
console.debug('SentryLogLevels:', logLevels.join(', '));
|
|
45
|
+
return logLevels;
|
|
46
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Environment } from '@rxap/nest-utilities';
|
|
2
|
+
import { LogSeverityLevel } from '@sentry/core';
|
|
2
3
|
import type { SchemaMap } from 'joi';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
release: string;
|
|
7
|
-
environment: string;
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
dsn: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function sentryValidationSchema(environment: Environment, { debug, serverName, release, environment: environmentName, enabled, dsn, }?: Partial<SentryConfig>): SchemaMap;
|
|
4
|
+
export declare function sentryValidationSchema(environment: Environment, { logLevel }?: Partial<{
|
|
5
|
+
logLevel: LogSeverityLevel;
|
|
6
|
+
}>): SchemaMap;
|
|
@@ -2,22 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sentryValidationSchema = sentryValidationSchema;
|
|
4
4
|
const Joi = require("joi");
|
|
5
|
-
function sentryValidationSchema(environment, {
|
|
5
|
+
function sentryValidationSchema(environment, { logLevel = 'warn' } = {}) {
|
|
6
6
|
const schema = {};
|
|
7
|
-
schema['
|
|
8
|
-
schema['SENTRY_SERVER_NAME'] = Joi.string().default(serverName);
|
|
9
|
-
schema['SENTRY_ENABLED'] = Joi.string().default(enabled);
|
|
10
|
-
schema['SENTRY_RELEASE'] = Joi.string();
|
|
11
|
-
if (release) {
|
|
12
|
-
schema['SENTRY_RELEASE'] = schema['SENTRY_RELEASE'].default(release);
|
|
13
|
-
}
|
|
14
|
-
schema['SENTRY_ENVIRONMENT'] = Joi.string();
|
|
15
|
-
if (environmentName) {
|
|
16
|
-
schema['SENTRY_ENVIRONMENT'] = schema['SENTRY_ENVIRONMENT'].default(environmentName);
|
|
17
|
-
}
|
|
18
|
-
schema['SENTRY_DSN'] = Joi.string();
|
|
19
|
-
if (dsn) {
|
|
20
|
-
schema['SENTRY_DSN'] = schema['SENTRY_DSN'].default(dsn);
|
|
21
|
-
}
|
|
7
|
+
schema['SENTRY_LOG_LEVEL'] = Joi.string().allow('trace', 'debug', 'info', 'warn', 'error', 'fatal').default(logLevel);
|
|
22
8
|
return schema;
|
|
23
9
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Environment } from '@rxap/nest-utilities';
|
|
2
|
-
|
|
2
|
+
import type { NodeOptions } from '@sentry/node/build/types/types';
|
|
3
|
+
export declare function sentryInitHook(options: Partial<NodeOptions>): (_: any, environment: Environment) => void;
|
|
@@ -5,7 +5,7 @@ const Sentry = require("@sentry/nestjs");
|
|
|
5
5
|
const profiling_node_1 = require("@sentry/profiling-node");
|
|
6
6
|
const determine_sentry_environment_1 = require("./determine-sentry-environment");
|
|
7
7
|
const determine_sentry_release_1 = require("./determine-sentry-release");
|
|
8
|
-
function sentryInitHook() {
|
|
8
|
+
function sentryInitHook(options) {
|
|
9
9
|
return (_, environment) => {
|
|
10
10
|
const dsn = process.env['SENTRY_DSN'] ?? environment.sentry?.dsn;
|
|
11
11
|
if (!dsn) {
|
|
@@ -24,10 +24,12 @@ function sentryInitHook() {
|
|
|
24
24
|
levels: ['error'],
|
|
25
25
|
}),
|
|
26
26
|
(0, profiling_node_1.nodeProfilingIntegration)(),
|
|
27
|
-
Sentry.anrIntegration({ captureStackTrace: true }),
|
|
28
27
|
],
|
|
29
28
|
tracesSampleRate: 1.0,
|
|
30
|
-
|
|
29
|
+
profileSessionSampleRate: 1.0,
|
|
30
|
+
profileLifecycle: 'trace',
|
|
31
|
+
enableLogs: true,
|
|
32
|
+
...options,
|
|
31
33
|
});
|
|
32
34
|
};
|
|
33
35
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigurableModuleOptionsFactory, Logger } from '@nestjs/common';
|
|
2
|
+
import { ConsoleLoggerOptions } from '@nestjs/common/services/console-logger.service';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
import { SentryModuleOptions } from '@rxap/nest-sentry';
|
|
5
|
+
export declare class SentryModuleOptionsFactory implements ConfigurableModuleOptionsFactory<SentryModuleOptions, 'create'> {
|
|
6
|
+
protected readonly config: ConfigService;
|
|
7
|
+
protected readonly logger: Logger;
|
|
8
|
+
protected readonly options?: ConsoleLoggerOptions;
|
|
9
|
+
create(): Promise<SentryModuleOptions>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SentryModuleOptionsFactory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const config_1 = require("@nestjs/config");
|
|
7
|
+
const nest_logger_1 = require("@rxap/nest-logger");
|
|
8
|
+
const nest_utilities_1 = require("@rxap/nest-utilities");
|
|
9
|
+
const get_sentry_log_levels_1 = require("./get-sentry-log-levels");
|
|
10
|
+
let SentryModuleOptionsFactory = class SentryModuleOptionsFactory {
|
|
11
|
+
async create() {
|
|
12
|
+
return {
|
|
13
|
+
logLevels: (0, get_sentry_log_levels_1.GetSentryLogLevels)(this.config.getOrThrow('SENTRY_LOG_LEVEL')),
|
|
14
|
+
logger: {
|
|
15
|
+
timestamp: true,
|
|
16
|
+
logLevels: (0, nest_utilities_1.GetLogLevels)(),
|
|
17
|
+
...this.options ?? {},
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.SentryModuleOptionsFactory = SentryModuleOptionsFactory;
|
|
23
|
+
tslib_1.__decorate([
|
|
24
|
+
(0, common_1.Inject)(config_1.ConfigService),
|
|
25
|
+
tslib_1.__metadata("design:type", config_1.ConfigService)
|
|
26
|
+
], SentryModuleOptionsFactory.prototype, "config", void 0);
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
(0, common_1.Inject)(common_1.Logger),
|
|
29
|
+
tslib_1.__metadata("design:type", common_1.Logger)
|
|
30
|
+
], SentryModuleOptionsFactory.prototype, "logger", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, common_1.Optional)(),
|
|
33
|
+
(0, common_1.Inject)(nest_logger_1.CONSOLE_LOGGER_OPTIONS),
|
|
34
|
+
tslib_1.__metadata("design:type", Object)
|
|
35
|
+
], SentryModuleOptionsFactory.prototype, "options", void 0);
|
|
36
|
+
exports.SentryModuleOptionsFactory = SentryModuleOptionsFactory = tslib_1.__decorate([
|
|
37
|
+
(0, common_1.Injectable)()
|
|
38
|
+
], SentryModuleOptionsFactory);
|
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
import { ConsoleLoggerOptions } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface SentryCloseOptions {
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
timeout?: number;
|
|
9
|
-
}
|
|
10
|
-
export type SentryModuleOptions = Omit<NodeOptions, 'integrations'> & {
|
|
11
|
-
integrations?: Integration[];
|
|
12
|
-
close?: SentryCloseOptions;
|
|
13
|
-
interceptors?: SentryInterceptorOptions;
|
|
14
|
-
} & ConsoleLoggerOptions;
|
|
15
|
-
export interface ISentryOptionsFactory {
|
|
16
|
-
createSentryModuleOptions(): Promise<SentryModuleOptions> | SentryModuleOptions;
|
|
17
|
-
}
|
|
18
|
-
export interface SentryModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
19
|
-
inject?: any[];
|
|
20
|
-
useClass?: Type<ISentryOptionsFactory>;
|
|
21
|
-
useExisting?: Type<ISentryOptionsFactory>;
|
|
22
|
-
useFactory?: (...args: any[]) => Promise<SentryModuleOptions> | SentryModuleOptions;
|
|
23
|
-
}
|
|
24
|
-
export interface SentryFilterFunction {
|
|
25
|
-
(exception: any): boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface SentryInterceptorOptionsFilter {
|
|
28
|
-
type: any;
|
|
29
|
-
filter?: SentryFilterFunction;
|
|
30
|
-
}
|
|
31
|
-
export type SentryInterceptorOptions = AddRequestDataToEventOptions['include'] & {
|
|
32
|
-
filters?: SentryInterceptorOptionsFilter[];
|
|
33
|
-
tags?: {
|
|
34
|
-
[key: string]: string;
|
|
35
|
-
};
|
|
36
|
-
extra?: {
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
};
|
|
39
|
-
fingerprint?: string[];
|
|
40
|
-
level?: SeverityLevel;
|
|
2
|
+
import { LogSeverityLevel } from '@sentry/core';
|
|
3
|
+
export type SentryModuleOptions = {
|
|
4
|
+
logLevels: LogSeverityLevel[];
|
|
5
|
+
logger?: ConsoleLoggerOptions;
|
|
41
6
|
};
|
|
@@ -8,10 +8,13 @@ import { RxapLogger } from '@rxap/nest-logger';
|
|
|
8
8
|
export declare class SentryLogger extends RxapLogger {
|
|
9
9
|
protected readonly options: ConsoleLoggerOptions;
|
|
10
10
|
private readonly sentryOptions;
|
|
11
|
+
private readonly config;
|
|
11
12
|
log(message: string, ...optionalParams: any[]): void;
|
|
12
13
|
error(message: string, ...optionalParams: any[]): void;
|
|
14
|
+
fatal(message: string, ...optionalParams: any[]): void;
|
|
13
15
|
warn(message: string, ...optionalParams: any[]): void;
|
|
14
16
|
debug(message: string, ...optionalParams: any[]): void;
|
|
17
|
+
verbose(message: string, ...optionalParams: any[]): void;
|
|
15
18
|
private _getContextAndMessagesToPrint;
|
|
16
19
|
private _getContextAndStackAndMessagesToPrint;
|
|
17
20
|
}
|
package/src/lib/sentry.logger.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.SentryLogger = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
|
7
|
+
const config_1 = require("@nestjs/config");
|
|
7
8
|
const nest_logger_1 = require("@rxap/nest-logger");
|
|
8
9
|
const Sentry = require("@sentry/node");
|
|
9
10
|
const tokens_1 = require("./tokens");
|
|
@@ -25,10 +26,10 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
25
26
|
...optionalParams,
|
|
26
27
|
]);
|
|
27
28
|
super.log(message, ...optionalParams);
|
|
28
|
-
if (!this.
|
|
29
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
if (this.sentryOptions.logLevels && !this.sentryOptions.logLevels.includes(
|
|
32
|
+
if (this.sentryOptions.logLevels && !['log', 'info'].some(level => this.sentryOptions.logLevels.includes(level))) {
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
@@ -39,11 +40,7 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
39
40
|
data: {
|
|
40
41
|
context,
|
|
41
42
|
},
|
|
42
|
-
}) :
|
|
43
|
-
Sentry.captureMessage(message, {
|
|
44
|
-
level: 'log',
|
|
45
|
-
extra: { context },
|
|
46
|
-
});
|
|
43
|
+
}) : Sentry.logger.info(message, { data: context });
|
|
47
44
|
}
|
|
48
45
|
catch (err) {
|
|
49
46
|
console.error('Failed to capture message with sentry: ' + err.message);
|
|
@@ -55,16 +52,39 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
55
52
|
...optionalParams,
|
|
56
53
|
]);
|
|
57
54
|
super.error(message, ...optionalParams);
|
|
58
|
-
if (!this.
|
|
55
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
59
56
|
return;
|
|
60
57
|
}
|
|
61
58
|
if (this.sentryOptions.logLevels && !this.sentryOptions.logLevels.includes('error')) {
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
64
61
|
try {
|
|
65
|
-
Sentry.
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
Sentry.logger.error(message, {
|
|
63
|
+
data: {
|
|
64
|
+
context,
|
|
65
|
+
stack,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
console.error('Failed to capture message with sentry: ' + err.message);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
fatal(message, ...optionalParams) {
|
|
74
|
+
const { context, stack, } = this._getContextAndStackAndMessagesToPrint([
|
|
75
|
+
message,
|
|
76
|
+
...optionalParams,
|
|
77
|
+
]);
|
|
78
|
+
super.error(message, ...optionalParams);
|
|
79
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this.sentryOptions.logLevels && !this.sentryOptions.logLevels.includes('fatal')) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
Sentry.logger.fatal(message, {
|
|
87
|
+
data: {
|
|
68
88
|
context,
|
|
69
89
|
stack,
|
|
70
90
|
},
|
|
@@ -86,10 +106,10 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
86
106
|
...optionalParams,
|
|
87
107
|
]);
|
|
88
108
|
super.warn(message, ...optionalParams);
|
|
89
|
-
if (!this.
|
|
109
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
90
110
|
return;
|
|
91
111
|
}
|
|
92
|
-
if (this.sentryOptions.logLevels && !this.sentryOptions.logLevels.includes(
|
|
112
|
+
if (this.sentryOptions.logLevels && !['warn', 'warning'].some(level => this.sentryOptions.logLevels.includes(level))) {
|
|
93
113
|
return;
|
|
94
114
|
}
|
|
95
115
|
try {
|
|
@@ -101,9 +121,8 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
101
121
|
context,
|
|
102
122
|
},
|
|
103
123
|
}) :
|
|
104
|
-
Sentry.
|
|
105
|
-
|
|
106
|
-
extra: { context },
|
|
124
|
+
Sentry.logger.warn(message, {
|
|
125
|
+
data: { context },
|
|
107
126
|
});
|
|
108
127
|
}
|
|
109
128
|
catch (err) {
|
|
@@ -122,7 +141,7 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
122
141
|
...optionalParams,
|
|
123
142
|
]);
|
|
124
143
|
super.debug(message, ...optionalParams);
|
|
125
|
-
if (!this.
|
|
144
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
126
145
|
return;
|
|
127
146
|
}
|
|
128
147
|
if (this.sentryOptions.logLevels && !this.sentryOptions.logLevels.includes('debug')) {
|
|
@@ -137,15 +156,35 @@ let SentryLogger = class SentryLogger extends nest_logger_1.RxapLogger {
|
|
|
137
156
|
context,
|
|
138
157
|
},
|
|
139
158
|
}) :
|
|
140
|
-
Sentry.
|
|
141
|
-
|
|
142
|
-
extra: { context },
|
|
159
|
+
Sentry.logger.debug(message, {
|
|
160
|
+
data: { context },
|
|
143
161
|
});
|
|
144
162
|
}
|
|
145
163
|
catch (err) {
|
|
146
164
|
console.error('Failed to capture message with sentry: ' + err.message);
|
|
147
165
|
}
|
|
148
166
|
}
|
|
167
|
+
verbose(message, ...optionalParams) {
|
|
168
|
+
const { context } = this._getContextAndMessagesToPrint([
|
|
169
|
+
message,
|
|
170
|
+
...optionalParams,
|
|
171
|
+
]);
|
|
172
|
+
super.verbose(message, ...optionalParams);
|
|
173
|
+
if (!this.config.get('SENTRY_ENABLED')) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (this.sentryOptions.logLevels && !['verbose', 'trace'].some(level => this.sentryOptions.logLevels.includes(level))) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
Sentry.logger.trace(message, {
|
|
181
|
+
data: { context },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
console.error('Failed to capture message with sentry: ' + err.message);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
149
188
|
_getContextAndMessagesToPrint(args) {
|
|
150
189
|
if (args?.length <= 1) {
|
|
151
190
|
return {
|
|
@@ -199,6 +238,10 @@ tslib_1.__decorate([
|
|
|
199
238
|
(0, common_1.Inject)(tokens_1.SENTRY_MODULE_OPTIONS),
|
|
200
239
|
tslib_1.__metadata("design:type", Object)
|
|
201
240
|
], SentryLogger.prototype, "sentryOptions", void 0);
|
|
241
|
+
tslib_1.__decorate([
|
|
242
|
+
(0, common_1.Inject)(config_1.ConfigService),
|
|
243
|
+
tslib_1.__metadata("design:type", config_1.ConfigService)
|
|
244
|
+
], SentryLogger.prototype, "config", void 0);
|
|
202
245
|
exports.SentryLogger = SentryLogger = tslib_1.__decorate([
|
|
203
246
|
(0, common_1.Injectable)()
|
|
204
247
|
], SentryLogger);
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { PrintMessagesFunction } from '@rxap/nest-logger';
|
|
3
|
-
import {
|
|
3
|
+
import { SentryModuleOptions } from './sentry.interfaces';
|
|
4
4
|
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<SentryModuleOptions, "register", "create", {
|
|
5
5
|
isGlobal: boolean;
|
|
6
|
-
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE:
|
|
7
|
-
integrations?: import("@sentry/types").Integration[];
|
|
8
|
-
close?: import("./sentry.interfaces").SentryCloseOptions;
|
|
9
|
-
interceptors?: SentryInterceptorOptions;
|
|
10
|
-
} & ConsoleLoggerOptions & Partial<{
|
|
6
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: SentryModuleOptions & Partial<{
|
|
11
7
|
isGlobal: boolean;
|
|
12
8
|
}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<SentryModuleOptions, "create"> & Partial<{
|
|
13
9
|
isGlobal: boolean;
|
|
14
10
|
}>;
|
|
15
|
-
export declare const DEFAULT_SENTRY_INTERCEPTOR_OPTIONS: SentryInterceptorOptions;
|
|
16
11
|
export declare class SentryModule extends ConfigurableModuleClass {
|
|
17
|
-
static register(options
|
|
18
|
-
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE,
|
|
12
|
+
static register(options: typeof OPTIONS_TYPE, printMessagesFunction?: PrintMessagesFunction | null): DynamicModule;
|
|
13
|
+
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE, printMessagesFunction?: PrintMessagesFunction | null): DynamicModule;
|
|
19
14
|
private static updateProviders;
|
|
20
|
-
static forRoot(options: typeof OPTIONS_TYPE, consoleLoggerOptions?: ConsoleLoggerOptions): DynamicModule;
|
|
21
|
-
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE, consoleLoggerOptions?: ConsoleLoggerOptions): DynamicModule;
|
|
22
15
|
}
|
package/src/lib/sentry.module.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SentryModule = exports.
|
|
4
|
+
exports.SentryModule = exports.ASYNC_OPTIONS_TYPE = exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
|
|
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");
|
|
9
8
|
const nest_logger_1 = require("@rxap/nest-logger");
|
|
10
|
-
const
|
|
9
|
+
const nest_utilities_1 = require("@rxap/nest-utilities");
|
|
11
10
|
const sentry_logger_1 = require("./sentry.logger");
|
|
12
11
|
const tokens_1 = require("./tokens");
|
|
13
12
|
_a = new common_1.ConfigurableModuleBuilder()
|
|
@@ -15,22 +14,14 @@ _a = new common_1.ConfigurableModuleBuilder()
|
|
|
15
14
|
isGlobal: true,
|
|
16
15
|
})
|
|
17
16
|
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
|
|
18
|
-
exports.DEFAULT_SENTRY_INTERCEPTOR_OPTIONS = {
|
|
19
|
-
filters: [
|
|
20
|
-
{
|
|
21
|
-
type: common_1.HttpException,
|
|
22
|
-
filter: (exception) => 500 > exception.getStatus(),
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
17
|
let SentryModule = class SentryModule extends exports.ConfigurableModuleClass {
|
|
27
|
-
static register(options
|
|
28
|
-
return this.updateProviders(super.register(options),
|
|
18
|
+
static register(options, printMessagesFunction = null) {
|
|
19
|
+
return this.updateProviders(super.register(options), printMessagesFunction);
|
|
29
20
|
}
|
|
30
|
-
static registerAsync(options,
|
|
31
|
-
return this.updateProviders(super.registerAsync(options),
|
|
21
|
+
static registerAsync(options, printMessagesFunction = null) {
|
|
22
|
+
return this.updateProviders(super.registerAsync(options), printMessagesFunction);
|
|
32
23
|
}
|
|
33
|
-
static updateProviders(module,
|
|
24
|
+
static updateProviders(module, printMessagesFunction) {
|
|
34
25
|
module.providers ??= [];
|
|
35
26
|
module.providers.push({
|
|
36
27
|
provide: tokens_1.SENTRY_MODULE_OPTIONS,
|
|
@@ -38,16 +29,12 @@ let SentryModule = class SentryModule extends exports.ConfigurableModuleClass {
|
|
|
38
29
|
});
|
|
39
30
|
module.providers.push({
|
|
40
31
|
provide: nest_logger_1.CONSOLE_LOGGER_OPTIONS,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
module.providers.push({
|
|
48
|
-
provide: tokens_1.SENTRY_INTERCEPTOR_OPTIONS,
|
|
49
|
-
useFactory: (options) => options.interceptors ?? exports.DEFAULT_SENTRY_INTERCEPTOR_OPTIONS,
|
|
50
|
-
inject: [exports.MODULE_OPTIONS_TOKEN]
|
|
32
|
+
useFactory: (options) => ({
|
|
33
|
+
timestamp: true,
|
|
34
|
+
logLevels: (0, nest_utilities_1.GetLogLevels)(),
|
|
35
|
+
...options.logger ?? {},
|
|
36
|
+
}),
|
|
37
|
+
inject: [tokens_1.SENTRY_MODULE_OPTIONS],
|
|
51
38
|
});
|
|
52
39
|
if (printMessagesFunction) {
|
|
53
40
|
module.providers.push({
|
|
@@ -55,18 +42,8 @@ let SentryModule = class SentryModule extends exports.ConfigurableModuleClass {
|
|
|
55
42
|
useValue: printMessagesFunction
|
|
56
43
|
});
|
|
57
44
|
}
|
|
58
|
-
module.providers.push({
|
|
59
|
-
provide: core_1.APP_INTERCEPTOR,
|
|
60
|
-
useClass: sentry_interceptor_1.SentryInterceptor,
|
|
61
|
-
});
|
|
62
45
|
return module;
|
|
63
46
|
}
|
|
64
|
-
static forRoot(options, consoleLoggerOptions = {}) {
|
|
65
|
-
return this.register(options, consoleLoggerOptions);
|
|
66
|
-
}
|
|
67
|
-
static forRootAsync(options, consoleLoggerOptions = {}) {
|
|
68
|
-
return this.registerAsync(options, consoleLoggerOptions);
|
|
69
|
-
}
|
|
70
47
|
};
|
|
71
48
|
exports.SentryModule = SentryModule;
|
|
72
49
|
exports.SentryModule = SentryModule = tslib_1.__decorate([
|
|
@@ -88,6 +65,7 @@ exports.SentryModule = SentryModule = tslib_1.__decorate([
|
|
|
88
65
|
sentry_logger_1.SentryLogger,
|
|
89
66
|
nest_logger_1.RxapLogger,
|
|
90
67
|
],
|
|
68
|
+
imports: [],
|
|
91
69
|
exports: [common_1.Logger],
|
|
92
70
|
})
|
|
93
71
|
], SentryModule);
|
package/src/lib/tokens.d.ts
CHANGED
package/src/lib/tokens.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SENTRY_MODULE_OPTIONS = void 0;
|
|
4
4
|
exports.SENTRY_MODULE_OPTIONS = Symbol('SentryModuleOptions');
|
|
5
|
-
/**
|
|
6
|
-
* InjectionToken for an object of type SentryInterceptorOptions
|
|
7
|
-
*/
|
|
8
|
-
exports.SENTRY_INTERCEPTOR_OPTIONS = Symbol('SENTRY_INTERCEPTOR_OPTIONS');
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SentryLoggerModule = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const config_1 = require("@nestjs/config");
|
|
7
|
-
const nest_logger_1 = require("@rxap/nest-logger");
|
|
8
|
-
const sentry_logger_1 = require("./sentry.logger");
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated removed use the SentryModule instead
|
|
11
|
-
*/
|
|
12
|
-
let SentryLoggerModule = class SentryLoggerModule {
|
|
13
|
-
};
|
|
14
|
-
exports.SentryLoggerModule = SentryLoggerModule;
|
|
15
|
-
exports.SentryLoggerModule = SentryLoggerModule = tslib_1.__decorate([
|
|
16
|
-
(0, common_1.Global)(),
|
|
17
|
-
(0, common_1.Module)({
|
|
18
|
-
providers: [
|
|
19
|
-
{
|
|
20
|
-
provide: common_1.Logger,
|
|
21
|
-
useFactory: (config, sentry, rxap) => {
|
|
22
|
-
if (config.get('SENTRY_ENABLED')) {
|
|
23
|
-
return sentry;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return rxap;
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
inject: [config_1.ConfigService, sentry_logger_1.SentryLogger, nest_logger_1.RxapLogger]
|
|
30
|
-
},
|
|
31
|
-
sentry_logger_1.SentryLogger,
|
|
32
|
-
nest_logger_1.RxapLogger,
|
|
33
|
-
],
|
|
34
|
-
exports: [common_1.Logger],
|
|
35
|
-
})
|
|
36
|
-
], SentryLoggerModule);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ConfigService } from '@nestjs/config';
|
|
2
|
-
import { Environment } from '@rxap/nest-utilities';
|
|
3
|
-
import { SentryModuleOptions } from './sentry.interfaces';
|
|
4
|
-
export declare function SentryOptionsFactory(environment: Environment): (config: ConfigService) => SentryModuleOptions;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SentryOptionsFactory = SentryOptionsFactory;
|
|
4
|
-
const nest_utilities_1 = require("@rxap/nest-utilities");
|
|
5
|
-
function SentryOptionsFactory(environment) {
|
|
6
|
-
return (config) => {
|
|
7
|
-
const options = {
|
|
8
|
-
dsn: config.get('SENTRY_DSN'),
|
|
9
|
-
enabled: config.get('SENTRY_ENABLED', false),
|
|
10
|
-
environment: config.get('SENTRY_ENVIRONMENT', (0, nest_utilities_1.DetermineEnvironment)(environment)),
|
|
11
|
-
release: config.get('SENTRY_RELEASE', (0, nest_utilities_1.DetermineRelease)(environment)),
|
|
12
|
-
serverName: config.get('SENTRY_SERVER_NAME', environment.name),
|
|
13
|
-
debug: config.get('SENTRY_DEBUG', false),
|
|
14
|
-
tracesSampleRate: config.get('SENTRY_TRACES_SAMPLE_RATE', 1.0),
|
|
15
|
-
profilesSampleRate: config.get('SENTRY_PROFILES_SAMPLE_RATE', 1.0),
|
|
16
|
-
logLevels: config.get('SENTRY_LOG_LEVELS', ['warn', 'error']),
|
|
17
|
-
maxValueLength: config.get('SENTRY_MAX_VALUE_LENGTH', Number.MAX_SAFE_INTEGER),
|
|
18
|
-
normalizeDepth: config.get('SENTRY_NORMALIZE_DEPTH', 5),
|
|
19
|
-
};
|
|
20
|
-
console.debug(`[SentryOptionsFactory] SentryOptions: ${JSON.stringify(options)}`);
|
|
21
|
-
return options;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
-
import { Scope } from '@sentry/core';
|
|
3
|
-
import { Observable } from 'rxjs';
|
|
4
|
-
import { SentryInterceptorOptions } from './sentry.interfaces';
|
|
5
|
-
export declare class SentryInterceptor implements NestInterceptor {
|
|
6
|
-
protected readonly options?: SentryInterceptorOptions;
|
|
7
|
-
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
8
|
-
protected captureException(context: ExecutionContext, scope: Scope, exception: unknown): void;
|
|
9
|
-
private captureHttpException;
|
|
10
|
-
private captureRpcException;
|
|
11
|
-
private captureWsException;
|
|
12
|
-
private shouldReport;
|
|
13
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SentryInterceptor = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const Sentry = require("@sentry/nestjs");
|
|
7
|
-
const node_1 = require("@sentry/node");
|
|
8
|
-
const operators_1 = require("rxjs/operators");
|
|
9
|
-
const tokens_1 = require("./tokens");
|
|
10
|
-
let SentryInterceptor = class SentryInterceptor {
|
|
11
|
-
intercept(context, next) {
|
|
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
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
captureException(context, scope, exception) {
|
|
23
|
-
if (exception && typeof exception === 'object' && typeof exception['setScope'] === 'function') {
|
|
24
|
-
exception['setScope'](scope);
|
|
25
|
-
}
|
|
26
|
-
switch (context.getType()) {
|
|
27
|
-
case 'http':
|
|
28
|
-
return this.captureHttpException(scope, context.switchToHttp(), exception);
|
|
29
|
-
case 'rpc':
|
|
30
|
-
return this.captureRpcException(scope, context.switchToRpc(), exception);
|
|
31
|
-
case 'ws':
|
|
32
|
-
return this.captureWsException(scope, context.switchToWs(), exception);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
captureHttpException(scope, http, exception) {
|
|
36
|
-
const data = (0, node_1.addRequestDataToEvent)({}, http.getRequest(), { include: this.options });
|
|
37
|
-
scope.setExtra('req', data.request);
|
|
38
|
-
if (data.extra) {
|
|
39
|
-
scope.setExtras(data.extra);
|
|
40
|
-
}
|
|
41
|
-
if (data.user) {
|
|
42
|
-
scope.setUser(data.user);
|
|
43
|
-
}
|
|
44
|
-
Sentry.captureException(exception);
|
|
45
|
-
}
|
|
46
|
-
captureRpcException(scope, rpc, exception) {
|
|
47
|
-
scope.setExtra('rpc_data', rpc.getData());
|
|
48
|
-
Sentry.captureException(exception);
|
|
49
|
-
}
|
|
50
|
-
captureWsException(scope, ws, exception) {
|
|
51
|
-
scope.setExtra('ws_client', ws.getClient());
|
|
52
|
-
scope.setExtra('ws_data', ws.getData());
|
|
53
|
-
Sentry.captureException(exception);
|
|
54
|
-
}
|
|
55
|
-
shouldReport(exception) {
|
|
56
|
-
if (!this.options?.filters) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return this.options.filters
|
|
60
|
-
.some(({ type, filter, }) => !(exception instanceof type && (!filter || filter(exception))));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports.SentryInterceptor = SentryInterceptor;
|
|
64
|
-
tslib_1.__decorate([
|
|
65
|
-
(0, common_1.Optional)(),
|
|
66
|
-
(0, common_1.Inject)(tokens_1.SENTRY_INTERCEPTOR_OPTIONS),
|
|
67
|
-
tslib_1.__metadata("design:type", Object)
|
|
68
|
-
], SentryInterceptor.prototype, "options", void 0);
|
|
69
|
-
exports.SentryInterceptor = SentryInterceptor = tslib_1.__decorate([
|
|
70
|
-
(0, common_1.Injectable)()
|
|
71
|
-
], SentryInterceptor);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
2
|
-
import * as Sentry from "@sentry/nestjs";
|
|
3
|
-
export declare class SentryService implements OnApplicationShutdown, OnApplicationBootstrap {
|
|
4
|
-
private readonly options;
|
|
5
|
-
private readonly logger;
|
|
6
|
-
get hasInstance(): boolean;
|
|
7
|
-
onApplicationBootstrap(): any;
|
|
8
|
-
instance(): typeof Sentry;
|
|
9
|
-
onApplicationShutdown(signal?: string): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SentryService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const tokens_1 = require("./tokens");
|
|
7
|
-
const Sentry = require("@sentry/nestjs");
|
|
8
|
-
const profiling_node_1 = require("@sentry/profiling-node");
|
|
9
|
-
let SentryService = class SentryService {
|
|
10
|
-
get hasInstance() {
|
|
11
|
-
return !!this.options.dsn;
|
|
12
|
-
}
|
|
13
|
-
onApplicationBootstrap() {
|
|
14
|
-
if (!this.options.dsn) {
|
|
15
|
-
if (this.options.enabled !== false) {
|
|
16
|
-
this.logger.warn('Could not create SentryService instance. The required option dsn is not defined', 'SentryService');
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.logger.verbose('Dsn is not defined, but sentry is disabled', 'SentryService');
|
|
20
|
-
}
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const { integrations = [], ...sentryOptions } = this.options;
|
|
24
|
-
Sentry.init({
|
|
25
|
-
...sentryOptions,
|
|
26
|
-
integrations: [
|
|
27
|
-
(0, profiling_node_1.nodeProfilingIntegration)(),
|
|
28
|
-
Sentry.onUncaughtExceptionIntegration({
|
|
29
|
-
onFatalError: async (err) => {
|
|
30
|
-
// console.error('uncaughtException, not cool!')
|
|
31
|
-
// console.error(err);
|
|
32
|
-
if (err.name === 'SentryError') {
|
|
33
|
-
console.log(err);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
Sentry.getCurrentHub().getClient().captureException(err);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
Sentry.onUnhandledRejectionIntegration({ mode: 'warn' }),
|
|
42
|
-
...integrations,
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
instance() {
|
|
47
|
-
return Sentry;
|
|
48
|
-
}
|
|
49
|
-
async onApplicationShutdown(signal) {
|
|
50
|
-
if (this.hasInstance && this.options.close?.enabled === true) {
|
|
51
|
-
await Sentry.close(this.options.close.timeout);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.SentryService = SentryService;
|
|
56
|
-
tslib_1.__decorate([
|
|
57
|
-
(0, common_1.Inject)(tokens_1.SENTRY_MODULE_OPTIONS),
|
|
58
|
-
tslib_1.__metadata("design:type", Object)
|
|
59
|
-
], SentryService.prototype, "options", void 0);
|
|
60
|
-
tslib_1.__decorate([
|
|
61
|
-
(0, common_1.Inject)(common_1.Logger),
|
|
62
|
-
tslib_1.__metadata("design:type", common_1.Logger)
|
|
63
|
-
], SentryService.prototype, "logger", void 0);
|
|
64
|
-
exports.SentryService = SentryService = tslib_1.__decorate([
|
|
65
|
-
(0, common_1.Injectable)()
|
|
66
|
-
], SentryService);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetupSentryErrorHandler = SetupSentryErrorHandler;
|
|
4
|
-
const core_1 = require("@nestjs/core");
|
|
5
|
-
const Sentry = require("@sentry/nestjs");
|
|
6
|
-
function SetupSentryErrorHandler() {
|
|
7
|
-
return (app) => {
|
|
8
|
-
const { httpAdapter } = app.get(core_1.HttpAdapterHost);
|
|
9
|
-
Sentry.setupNestErrorHandler(app, new core_1.BaseExceptionFilter(httpAdapter));
|
|
10
|
-
};
|
|
11
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { INestApplication } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated instead import the module SentryLoggerModule in the AppModule
|
|
5
|
-
*/
|
|
6
|
-
export declare function SetupSentryLogger(): (app: INestApplication, config: ConfigService) => void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetupSentryLogger = SetupSentryLogger;
|
|
4
|
-
const nest_logger_1 = require("@rxap/nest-logger");
|
|
5
|
-
const sentry_logger_1 = require("./sentry.logger");
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated instead import the module SentryLoggerModule in the AppModule
|
|
8
|
-
*/
|
|
9
|
-
function SetupSentryLogger() {
|
|
10
|
-
return (app, config) => {
|
|
11
|
-
if (config.get('SENTRY_ENABLED')) {
|
|
12
|
-
app.useLogger(app.get(sentry_logger_1.SentryLogger));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
app.useLogger(new nest_logger_1.RxapLogger());
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|