@rxap/nest-sentry 9.0.1

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 ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 9.0.1 (2022-12-28)
7
+
8
+ **Note:** Version bump only for package @rxap/sentry
package/GETSTARTED.md ADDED
File without changes
package/GUIDES.md ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ @rxap/nest-sentry
2
+ ======
3
+
4
+ [![npm version](https://img.shields.io/npm/v/@rxap/nest-sentry?style=flat-square)](https://www.npmjs.com/package/@rxap/nest-sentry)
5
+ [![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](https://commitizen.github.io/cz-cli/)
6
+ [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
7
+ ![Libraries.io dependency status for latest release, scoped npm package](https://img.shields.io/librariesio/release/npm/@rxap/nest-sentry)
8
+ ![npm](https://img.shields.io/npm/dm/@rxap/nest-sentry)
9
+ ![NPM](https://img.shields.io/npm/l/@rxap/nest-sentry)
10
+
11
+ >
12
+
13
+ - [Installation](#installation)
14
+
15
+ # Installation
16
+
17
+ ```
18
+ yarn add @rxap/nest-sentry
19
+ ```
20
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "schematics": {},
3
+ "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json"
4
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Merzough Münker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/migration.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "schematics": {},
3
+ "$schema": "../../node_modules/@angular-devkit/schematics/collection-schema.json"
4
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@rxap/nest-sentry",
3
+ "version": "9.0.1",
4
+ "type": "commonjs",
5
+ "schematics": "./collection.json",
6
+ "ng-update": {
7
+ "migrations": "./migration.json",
8
+ "packageGroup": [
9
+ "@rxap/nest-sentry"
10
+ ]
11
+ },
12
+ "ng-add": {
13
+ "save": "dependencies"
14
+ },
15
+ "private": false,
16
+ "author": "Merzough Münker",
17
+ "homepage": "https://gitlab.com/rxap/nest/-/blob/master/libs/sentry",
18
+ "repository": "git@gitlab.com:rxap/nest.git",
19
+ "keywords": [],
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://gitlab.com/rxap/nest/-/issues",
23
+ "email": "incoming+rxap-nest-27853796-issue-@incoming.gitlab.com"
24
+ },
25
+ "publishConfig": {
26
+ "directory": "../../dist/libs/sentry",
27
+ "access": "public"
28
+ },
29
+ "peerDependencies": {
30
+ "@nestjs/common": "^9.2.1",
31
+ "@sentry/core": "^7.28.1",
32
+ "@sentry/node": "^7.28.1",
33
+ "rxjs": "^7.5.4",
34
+ "@sentry/types": "7.28.1"
35
+ },
36
+ "dependencies": {
37
+ "tslib": "^2.3.0"
38
+ },
39
+ "gitHead": "9d9243a1bc4241b63f64a879db34da022c554c01",
40
+ "main": "./src/index.js",
41
+ "types": "./src/index.d.ts"
42
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './lib/tokens';
2
+ export * from './lib/sentry.interceptor';
3
+ export * from './lib/sentry.interfaces';
4
+ export * from './lib/sentry.module';
5
+ export * from './lib/sentry.service';
6
+ export * from './lib/sentry.logger';
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/tokens"), exports);
5
+ tslib_1.__exportStar(require("./lib/sentry.interceptor"), exports);
6
+ tslib_1.__exportStar(require("./lib/sentry.interfaces"), exports);
7
+ tslib_1.__exportStar(require("./lib/sentry.module"), exports);
8
+ tslib_1.__exportStar(require("./lib/sentry.service"), exports);
9
+ tslib_1.__exportStar(require("./lib/sentry.logger"), exports);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/sentry/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,mEAAyC;AACzC,kEAAwC;AACxC,8DAAoC;AACpC,+DAAqC;AACrC,8DAAoC"}
@@ -0,0 +1,15 @@
1
+ import { CallHandler, ExecutionContext, HttpException, NestInterceptor } from '@nestjs/common';
2
+ import { Scope } from '@sentry/core';
3
+ import { Observable } from 'rxjs';
4
+ import { SentryInterceptorOptions } from './sentry.interfaces';
5
+ import { SentryService } from './sentry.service';
6
+ export declare class SentryInterceptor implements NestInterceptor {
7
+ protected readonly client: SentryService;
8
+ protected readonly options?: SentryInterceptorOptions;
9
+ intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
10
+ protected captureException(context: ExecutionContext, scope: Scope, exception: HttpException): void;
11
+ private captureHttpException;
12
+ private captureRpcException;
13
+ private captureWsException;
14
+ private shouldReport;
15
+ }
@@ -0,0 +1,75 @@
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 node_1 = require("@sentry/node");
7
+ const operators_1 = require("rxjs/operators");
8
+ const sentry_service_1 = require("./sentry.service");
9
+ const tokens_1 = require("./tokens");
10
+ let SentryInterceptor = class SentryInterceptor {
11
+ intercept(context, next) {
12
+ // first param would be for events, second is for errors
13
+ return next.handle().pipe((0, operators_1.tap)({
14
+ error: (exception) => {
15
+ if (this.shouldReport(exception)) {
16
+ this.client.instance().withScope((scope) => {
17
+ return this.captureException(context, scope, exception);
18
+ });
19
+ }
20
+ },
21
+ }));
22
+ }
23
+ captureException(context, scope, exception) {
24
+ switch (context.getType()) {
25
+ case 'http':
26
+ return this.captureHttpException(scope, context.switchToHttp(), exception);
27
+ case 'rpc':
28
+ return this.captureRpcException(scope, context.switchToRpc(), exception);
29
+ case 'ws':
30
+ return this.captureWsException(scope, context.switchToWs(), exception);
31
+ }
32
+ }
33
+ captureHttpException(scope, http, exception) {
34
+ const data = (0, node_1.addRequestDataToEvent)({}, http.getRequest(), { include: this.options });
35
+ scope.setExtra('req', data.request);
36
+ if (data.extra) {
37
+ scope.setExtras(data.extra);
38
+ }
39
+ if (data.user) {
40
+ scope.setUser(data.user);
41
+ }
42
+ this.client.instance().captureException(exception);
43
+ }
44
+ captureRpcException(scope, rpc, exception) {
45
+ scope.setExtra('rpc_data', rpc.getData());
46
+ this.client.instance().captureException(exception);
47
+ }
48
+ captureWsException(scope, ws, exception) {
49
+ scope.setExtra('ws_client', ws.getClient());
50
+ scope.setExtra('ws_data', ws.getData());
51
+ this.client.instance().captureException(exception);
52
+ }
53
+ shouldReport(exception) {
54
+ var _a;
55
+ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.filters)) {
56
+ return true;
57
+ }
58
+ return this.options.filters
59
+ .some(({ type, filter }) => !(exception instanceof type && (!filter || filter(exception))));
60
+ }
61
+ };
62
+ tslib_1.__decorate([
63
+ (0, common_1.Inject)(sentry_service_1.SentryService),
64
+ tslib_1.__metadata("design:type", sentry_service_1.SentryService)
65
+ ], SentryInterceptor.prototype, "client", void 0);
66
+ tslib_1.__decorate([
67
+ (0, common_1.Optional)(),
68
+ (0, common_1.Inject)(tokens_1.SENTRY_INTERCEPTOR_OPTIONS),
69
+ tslib_1.__metadata("design:type", Object)
70
+ ], SentryInterceptor.prototype, "options", void 0);
71
+ SentryInterceptor = tslib_1.__decorate([
72
+ (0, common_1.Injectable)()
73
+ ], SentryInterceptor);
74
+ exports.SentryInterceptor = SentryInterceptor;
75
+ //# sourceMappingURL=sentry.interceptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.interceptor.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/sentry.interceptor.ts"],"names":[],"mappings":";;;;AAAA,2CAQwB;AAGxB,uCAAqD;AAErD,8CAAqC;AAGrC,qDAAiD;AACjD,qCAAsD;AAI/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAS5B,SAAS,CAAC,OAAyB,EAAE,IAAiB;QACpD,wDAAwD;QACxD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,eAAG,EAAC;YACF,KAAK,EAAE,CAAC,SAAwB,EAAE,EAAE;gBAClC,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;oBAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;wBACzC,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;oBAC1D,CAAC,CA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AAC,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAEO,kBAAkB,CACxB,KAAY,EACZ,EAAmB,EACnB,SAAkB;QAElB,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAEO,YAAY,CAAC,SAAkB;;QACrC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAA,EAAE;YAC1B,OAAO,IAAI,CAAC;SACb;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO;aAC1B,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,YAAY,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;CACF,CAAA;AAzFC;IAAC,IAAA,eAAM,EAAC,8BAAa,CAAC;sCACM,8BAAa;iDAAC;AAE1C;IAAC,IAAA,iBAAQ,GAAE;IACV,IAAA,eAAM,EAAC,mCAA0B,CAAC;;kDACkB;AAP1C,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CA2F7B;AA3FY,8CAAiB"}
@@ -0,0 +1,40 @@
1
+ import { ConsoleLoggerOptions } from '@nestjs/common';
2
+ import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
3
+ import { SeverityLevel } from '@sentry/node';
4
+ import { AddRequestDataToEventOptions } from '@sentry/node/types/requestdata';
5
+ import { Integration, Options } from '@sentry/types';
6
+ export interface SentryCloseOptions {
7
+ enabled: boolean;
8
+ timeout?: number;
9
+ }
10
+ export declare type SentryModuleOptions = Omit<Options, 'integrations'> & {
11
+ integrations?: Integration[];
12
+ close?: SentryCloseOptions;
13
+ } & ConsoleLoggerOptions;
14
+ export interface SentryOptionsFactory {
15
+ createSentryModuleOptions(): Promise<SentryModuleOptions> | SentryModuleOptions;
16
+ }
17
+ export interface SentryModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
18
+ inject?: any[];
19
+ useClass?: Type<SentryOptionsFactory>;
20
+ useExisting?: Type<SentryOptionsFactory>;
21
+ useFactory?: (...args: any[]) => Promise<SentryModuleOptions> | SentryModuleOptions;
22
+ }
23
+ export interface SentryFilterFunction {
24
+ (exception: any): boolean;
25
+ }
26
+ export interface SentryInterceptorOptionsFilter {
27
+ type: any;
28
+ filter?: SentryFilterFunction;
29
+ }
30
+ export declare type SentryInterceptorOptions = AddRequestDataToEventOptions['include'] & {
31
+ filters?: SentryInterceptorOptionsFilter[];
32
+ tags?: {
33
+ [key: string]: string;
34
+ };
35
+ extra?: {
36
+ [key: string]: any;
37
+ };
38
+ fingerprint?: string[];
39
+ level?: SeverityLevel;
40
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=sentry.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.interfaces.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/sentry.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { ConsoleLogger } from '@nestjs/common';
2
+ import { SentryModuleOptions } from './sentry.interfaces';
3
+ export declare class SentryLogger extends ConsoleLogger {
4
+ readonly opts?: SentryModuleOptions | undefined;
5
+ constructor(opts?: SentryModuleOptions | undefined);
6
+ log(message: string, context?: string, asBreadcrumb?: boolean): void;
7
+ error(message: string, stack?: string, context?: string): void;
8
+ warn(message: string, context?: string, asBreadcrumb?: boolean): void;
9
+ debug(message: string, context?: string, asBreadcrumb?: boolean): void;
10
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SentryLogger = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const common_1 = require("@nestjs/common");
6
+ const Sentry = require("@sentry/node");
7
+ const tokens_1 = require("./tokens");
8
+ let SentryLogger = class SentryLogger extends common_1.ConsoleLogger {
9
+ constructor(opts) {
10
+ super();
11
+ this.opts = opts;
12
+ }
13
+ log(message, context, asBreadcrumb) {
14
+ var _a;
15
+ super.log(message, context);
16
+ if (((_a = this.opts) === null || _a === void 0 ? void 0 : _a.logLevels) && !this.opts.logLevels.includes('log')) {
17
+ return;
18
+ }
19
+ try {
20
+ asBreadcrumb ?
21
+ Sentry.addBreadcrumb({
22
+ message,
23
+ level: 'log',
24
+ data: {
25
+ context
26
+ }
27
+ }) :
28
+ Sentry.captureMessage(message, {
29
+ level: 'log',
30
+ });
31
+ }
32
+ catch (err) { }
33
+ }
34
+ error(message, stack, context) {
35
+ var _a;
36
+ super.error(message, stack, context);
37
+ if (((_a = this.opts) === null || _a === void 0 ? void 0 : _a.logLevels) && !this.opts.logLevels.includes('error')) {
38
+ return;
39
+ }
40
+ try {
41
+ Sentry.captureMessage(message, { level: 'error' });
42
+ }
43
+ catch (err) { }
44
+ }
45
+ warn(message, context, asBreadcrumb) {
46
+ var _a;
47
+ super.warn(message, context);
48
+ if (((_a = this.opts) === null || _a === void 0 ? void 0 : _a.logLevels) && !this.opts.logLevels.includes('warn')) {
49
+ return;
50
+ }
51
+ try {
52
+ asBreadcrumb ?
53
+ Sentry.addBreadcrumb({
54
+ message,
55
+ level: 'warning',
56
+ data: {
57
+ context
58
+ }
59
+ }) :
60
+ Sentry.captureMessage(message, { level: 'warning' });
61
+ }
62
+ catch (err) { }
63
+ }
64
+ debug(message, context, asBreadcrumb) {
65
+ var _a;
66
+ super.debug(message, context);
67
+ if (((_a = this.opts) === null || _a === void 0 ? void 0 : _a.logLevels) && !this.opts.logLevels.includes('debug')) {
68
+ return;
69
+ }
70
+ try {
71
+ asBreadcrumb ?
72
+ Sentry.addBreadcrumb({
73
+ message,
74
+ level: 'debug',
75
+ data: {
76
+ context
77
+ }
78
+ }) :
79
+ Sentry.captureMessage(message, { level: 'debug' });
80
+ }
81
+ catch (err) { }
82
+ }
83
+ };
84
+ SentryLogger = tslib_1.__decorate([
85
+ (0, common_1.Injectable)(),
86
+ tslib_1.__param(0, (0, common_1.Inject)(tokens_1.SENTRY_MODULE_OPTIONS)),
87
+ tslib_1.__metadata("design:paramtypes", [Object])
88
+ ], SentryLogger);
89
+ exports.SentryLogger = SentryLogger;
90
+ //# sourceMappingURL=sentry.logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.logger.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/sentry.logger.ts"],"names":[],"mappings":";;;;AAAA,2CAAmE;AACnE,uCAAuC;AAEvC,qCAAiD;AAG1C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,sBAAa;IAE7C,YAES,IAA0B;QAEjC,KAAK,EAAE,CAAC;QAFD,SAAI,GAAJ,IAAI,CAAsB;IAGnC,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,OAAgB,EAAE,YAAsB;;QAC3D,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,SAAS,KAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAChE,OAAO;SACR;QACD,IAAI;YACF,YAAY,CAAC,CAAC;gBACd,MAAM,CAAC,aAAa,CAAC;oBACnB,OAAO;oBACP,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE;wBACJ,OAAO;qBACR;iBACF,CAAC,CAAC,CAAC;gBACJ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE;oBAC7B,KAAK,EAAE,KAAK;iBACb,CA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,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAClE,OAAO;SACR;QACD,IAAI;YACF,YAAY,CAAC,CAAC;gBACd,MAAM,CAAC,aAAa,CAAC;oBACnB,OAAO;oBACP,KAAK,EAAE,OAAO;oBACd,IAAI,EAAE;wBACJ,OAAO;qBACR;iBACF,CAAC,CAAC,CAAC;gBACJ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;SACpD;QAAC,OAAO,GAAG,EAAE,GAAE;IAClB,CAAC;CAEF,CAAA;AA3EY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAIR,mBAAA,IAAA,eAAM,EAAC,8BAAqB,CAAC,CAAA;;GAHrB,YAAY,CA2ExB;AA3EY,oCAAY"}
@@ -0,0 +1,8 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { SentryModuleAsyncOptions, SentryModuleOptions } from './sentry.interfaces';
3
+ export declare class SentryModule {
4
+ static forRoot(options: SentryModuleOptions): DynamicModule;
5
+ static forRootAsync(options: SentryModuleAsyncOptions): DynamicModule;
6
+ private static createAsyncProviders;
7
+ private static createAsyncOptionsProvider;
8
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var SentryModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SentryModule = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const tokens_1 = require("./tokens");
8
+ const sentry_logger_1 = require("./sentry.logger");
9
+ const sentry_service_1 = require("./sentry.service");
10
+ let SentryModule = SentryModule_1 = class SentryModule {
11
+ static forRoot(options) {
12
+ return {
13
+ exports: [sentry_service_1.SentryService],
14
+ module: SentryModule_1,
15
+ providers: [
16
+ {
17
+ provide: tokens_1.SENTRY_MODULE_OPTIONS,
18
+ useValue: options,
19
+ },
20
+ ],
21
+ };
22
+ }
23
+ static forRootAsync(options) {
24
+ return {
25
+ exports: [sentry_service_1.SentryService],
26
+ imports: options.imports,
27
+ module: SentryModule_1,
28
+ providers: [
29
+ ...this.createAsyncProviders(options),
30
+ ],
31
+ };
32
+ }
33
+ static createAsyncProviders(options) {
34
+ if (options.useExisting || options.useFactory) {
35
+ return [this.createAsyncOptionsProvider(options)];
36
+ }
37
+ const useClass = options.useClass;
38
+ return [
39
+ this.createAsyncOptionsProvider(options),
40
+ {
41
+ provide: useClass,
42
+ useClass,
43
+ },
44
+ ];
45
+ }
46
+ static createAsyncOptionsProvider(options) {
47
+ if (options.useFactory) {
48
+ return {
49
+ inject: options.inject || [],
50
+ provide: tokens_1.SENTRY_MODULE_OPTIONS,
51
+ useFactory: options.useFactory,
52
+ };
53
+ }
54
+ const inject = [
55
+ (options.useClass || options.useExisting),
56
+ ];
57
+ return {
58
+ provide: tokens_1.SENTRY_MODULE_OPTIONS,
59
+ useFactory: (optionsFactory) => tslib_1.__awaiter(this, void 0, void 0, function* () { return yield optionsFactory.createSentryModuleOptions(); }),
60
+ inject,
61
+ };
62
+ }
63
+ };
64
+ SentryModule = SentryModule_1 = tslib_1.__decorate([
65
+ (0, common_1.Module)({
66
+ providers: [sentry_logger_1.SentryLogger, sentry_service_1.SentryService],
67
+ exports: [sentry_logger_1.SentryLogger, sentry_service_1.SentryService]
68
+ })
69
+ ], SentryModule);
70
+ exports.SentryModule = SentryModule;
71
+ //# sourceMappingURL=sentry.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.module.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/sentry.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuE;AACvE,qCAAiD;AAEjD,mDAA+C;AAC/C,qDAAiD;AAM1C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAChB,MAAM,CAAC,OAAO,CAAC,OAA4B;QAChD,OAAO;YACL,OAAO,EAAE,CAAC,8BAAa,CAAC;YACxB,MAAM,EAAE,cAAY;YACpB,SAAS,EAAE;gBACT;oBACE,OAAO,EAA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CAAE,4BAAY,EAAE,8BAAa,CAAE;QAC1C,OAAO,EAAE,CAAE,4BAAY,EAAE,8BAAa,CAAE;KACzC,CAAC;GACW,YAAY,CAgExB;AAhEY,oCAAY"}
@@ -0,0 +1,9 @@
1
+ import { OnApplicationShutdown } from '@nestjs/common';
2
+ import * as Sentry from '@sentry/node';
3
+ import { SentryModuleOptions } from './sentry.interfaces';
4
+ export declare class SentryService implements OnApplicationShutdown {
5
+ readonly opts?: SentryModuleOptions | undefined;
6
+ constructor(opts?: SentryModuleOptions | undefined);
7
+ instance(): typeof Sentry;
8
+ onApplicationShutdown(signal?: string): Promise<void>;
9
+ }
@@ -0,0 +1,51 @@
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 Sentry = require("@sentry/node");
7
+ const tokens_1 = require("./tokens");
8
+ let SentryService = class SentryService {
9
+ constructor(opts) {
10
+ this.opts = opts;
11
+ if (!(opts === null || opts === void 0 ? void 0 : opts.dsn)) {
12
+ throw new Error('Could not create SentryService instance. The required option dsn is not defined');
13
+ }
14
+ const { integrations = [] } = opts, sentryOptions = tslib_1.__rest(opts, ["integrations"]);
15
+ Sentry.init(Object.assign(Object.assign({}, sentryOptions), { integrations: [
16
+ new Sentry.Integrations.OnUncaughtException({
17
+ onFatalError: (err) => tslib_1.__awaiter(this, void 0, void 0, function* () {
18
+ // console.error('uncaughtException, not cool!')
19
+ // console.error(err);
20
+ if (err.name === 'SentryError') {
21
+ console.log(err);
22
+ }
23
+ else {
24
+ Sentry.getCurrentHub().getClient().captureException(err);
25
+ process.exit(1);
26
+ }
27
+ }),
28
+ }),
29
+ new Sentry.Integrations.OnUnhandledRejection({ mode: 'warn' }),
30
+ ...integrations,
31
+ ] }));
32
+ }
33
+ instance() {
34
+ return Sentry;
35
+ }
36
+ onApplicationShutdown(signal) {
37
+ var _a, _b, _c;
38
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
39
+ if (((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.close) === null || _b === void 0 ? void 0 : _b.enabled) === true) {
40
+ yield Sentry.close((_c = this.opts) === null || _c === void 0 ? void 0 : _c.close.timeout);
41
+ }
42
+ });
43
+ }
44
+ };
45
+ SentryService = tslib_1.__decorate([
46
+ (0, common_1.Injectable)(),
47
+ tslib_1.__param(0, (0, common_1.Inject)(tokens_1.SENTRY_MODULE_OPTIONS)),
48
+ tslib_1.__metadata("design:paramtypes", [Object])
49
+ ], SentryService);
50
+ exports.SentryService = SentryService;
51
+ //# sourceMappingURL=sentry.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.service.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/sentry.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAmE;AAGnE,uCAAuC;AACvC,qCAAiD;AAI1C,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAEW,IAA0B;QAA1B,SAAI,GAAJ,IAAI,CAAsB;QAEnC,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,CAAA,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;SACpG;QACD,MAAM,EAAE,YAAY,GAAG,EAAE,KAAuB,IAAI,EAAtB,aAAa,kBAAK,IAAI,EAA9C,gBAAuC,CAAO,CAAC;QACrD,MAAM,CAAC,IAAI,iCACN,aAAa,KAChB,YAAY,EAAE;gBACZ,IAAI,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC;oBAC1C,YAAY,EAAE,CAAO,GAAG,EAAE,EAAE;wBAC1B,gDAAgD;wBAChD,sBAAsB;wBACtB,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,EAAE;4BAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;yBAClB;6BAAM;4BAEH,MAAM,CAAC,aAAa,EAAE,CAAC,SAAS,EAGjC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;4BACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;yBACjB;oBACH,CAAC,CAAA;iBACF,CAAC;gBACF,IAAI,MAAM,CAAC,YAAY,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC9D,GAAG,YAAY;aAChB,IACD,CAAC;IACL,CAAC;IAED,QAAQ;QACN,OAAO,MAAM,CAAC;IAChB,CAAC;IAEK,qBAAqB,CAAC,MAAe;;;YACzC,IAAI,CAAA,MAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,0CAAE,OAAO,MAAK,IAAI,EAAE;gBACtC,MAAM,MAAM,CAAC,KAAK,CAAC,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,OAAO,CAAC,CAAC;aAC9C;;KACF;CAEF,CAAA;AA5CY,aAAa;IADzB,IAAA,mBAAU,GAAE;IAGR,mBAAA,IAAA,eAAM,EAAC,8BAAqB,CAAC,CAAA;;GAFrB,aAAa,CA4CzB;AA5CY,sCAAa"}
@@ -0,0 +1,2 @@
1
+ export declare const SENTRY_MODULE_OPTIONS: unique symbol;
2
+ export declare const SENTRY_INTERCEPTOR_OPTIONS: unique symbol;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SENTRY_INTERCEPTOR_OPTIONS = exports.SENTRY_MODULE_OPTIONS = void 0;
4
+ exports.SENTRY_MODULE_OPTIONS = Symbol('SentryModuleOptions');
5
+ exports.SENTRY_INTERCEPTOR_OPTIONS = Symbol('SENTRY_INTERCEPTOR_OPTIONS');
6
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../../libs/sentry/src/lib/tokens.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACtD,QAAA,0BAA0B,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAA"}