@vendure/sentry-plugin 2.2.0-next.1 → 2.2.0-next.2
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/lib/src/sentry-error-handler-strategy.d.ts +12 -0
- package/lib/src/sentry-error-handler-strategy.js +40 -0
- package/lib/src/sentry-error-handler-strategy.js.map +1 -0
- package/lib/src/sentry-plugin.js +7 -15
- package/lib/src/sentry-plugin.js.map +1 -1
- package/package.json +4 -4
- package/lib/src/sentry.filter.d.ts +0 -7
- package/lib/src/sentry.filter.js +0 -42
- package/lib/src/sentry.filter.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { ErrorHandlerStrategy, Injector, Job } from '@vendure/core';
|
|
3
|
+
export declare class SentryErrorHandlerStrategy implements ErrorHandlerStrategy {
|
|
4
|
+
private sentryService;
|
|
5
|
+
init(injector: Injector): void;
|
|
6
|
+
handleServerError(exception: Error, { host }: {
|
|
7
|
+
host: ArgumentsHost;
|
|
8
|
+
}): void;
|
|
9
|
+
handleWorkerError(exception: Error, { job }: {
|
|
10
|
+
job: Job;
|
|
11
|
+
}): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SentryErrorHandlerStrategy = void 0;
|
|
4
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
5
|
+
const node_1 = require("@sentry/node");
|
|
6
|
+
const core_1 = require("@vendure/core");
|
|
7
|
+
const sentry_service_1 = require("./sentry.service");
|
|
8
|
+
class SentryErrorHandlerStrategy {
|
|
9
|
+
init(injector) {
|
|
10
|
+
this.sentryService = injector.get(sentry_service_1.SentryService);
|
|
11
|
+
}
|
|
12
|
+
handleServerError(exception, { host }) {
|
|
13
|
+
// We only care about errors which have at least a Warn log level
|
|
14
|
+
const shouldLogError = exception instanceof core_1.I18nError ? exception.logLevel <= core_1.LogLevel.Warn : true;
|
|
15
|
+
if (shouldLogError) {
|
|
16
|
+
if ((host === null || host === void 0 ? void 0 : host.getType()) === 'graphql') {
|
|
17
|
+
const gqlContext = graphql_1.GqlExecutionContext.create(host);
|
|
18
|
+
const info = gqlContext.getInfo();
|
|
19
|
+
(0, node_1.setContext)('GraphQL Error Context', {
|
|
20
|
+
fieldName: info.fieldName,
|
|
21
|
+
path: info.path,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const variables = exception.variables;
|
|
25
|
+
if (variables) {
|
|
26
|
+
(0, node_1.setContext)('GraphQL Error Variables', variables);
|
|
27
|
+
}
|
|
28
|
+
this.sentryService.captureException(exception);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
handleWorkerError(exception, { job }) {
|
|
32
|
+
(0, node_1.setContext)('Worker Context', {
|
|
33
|
+
queueName: job.queueName,
|
|
34
|
+
jobId: job.id,
|
|
35
|
+
});
|
|
36
|
+
this.sentryService.captureException(exception);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.SentryErrorHandlerStrategy = SentryErrorHandlerStrategy;
|
|
40
|
+
//# sourceMappingURL=sentry-error-handler-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-error-handler-strategy.js","sourceRoot":"","sources":["../../src/sentry-error-handler-strategy.ts"],"names":[],"mappings":";;;AACA,6CAAsE;AACtE,uCAA0C;AAC1C,wCAAyF;AAEzF,qDAAiD;AAEjD,MAAa,0BAA0B;IAGnC,IAAI,CAAC,QAAkB;QACnB,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,GAAG,CAAC,8BAAa,CAAC,CAAC;IACrD,CAAC;IAED,iBAAiB,CAAC,SAAgB,EAAE,EAAE,IAAI,EAA2B;QACjE,iEAAiE;QACjE,MAAM,cAAc,GAAG,SAAS,YAAY,gBAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,IAAI,eAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACnG,IAAI,cAAc,EAAE;YAChB,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,EAAkB,MAAK,SAAS,EAAE;gBAC/C,MAAM,UAAU,GAAG,6BAAmB,CAAC,MAAM,CAAC,IAAwB,CAAC,CAAC;gBACxE,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;gBAClC,IAAA,iBAAU,EAAC,uBAAuB,EAAE;oBAChC,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;iBAClB,CAAC,CAAC;aACN;YACD,MAAM,SAAS,GAAI,SAAiB,CAAC,SAAS,CAAC;YAC/C,IAAI,SAAS,EAAE;gBACX,IAAA,iBAAU,EAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;aACpD;YACD,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;SAClD;IACL,CAAC;IAED,iBAAiB,CAAC,SAAgB,EAAE,EAAE,GAAG,EAAgB;QACrD,IAAA,iBAAU,EAAC,gBAAgB,EAAE;YACzB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,KAAK,EAAE,GAAG,CAAC,EAAE;SAChB,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACJ;AAlCD,gEAkCC"}
|
package/lib/src/sentry-plugin.js
CHANGED
|
@@ -8,15 +8,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var SentryPlugin_1;
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.SentryPlugin = void 0;
|
|
11
|
-
const core_1 = require("@
|
|
12
|
-
const core_2 = require("@vendure/core");
|
|
11
|
+
const core_1 = require("@vendure/core");
|
|
13
12
|
const admin_test_resolver_1 = require("./api/admin-test.resolver");
|
|
14
13
|
const api_extensions_1 = require("./api/api-extensions");
|
|
15
14
|
const error_test_service_1 = require("./api/error-test.service");
|
|
16
15
|
const constants_1 = require("./constants");
|
|
17
16
|
const sentry_apollo_plugin_1 = require("./sentry-apollo-plugin");
|
|
18
17
|
const sentry_context_middleware_1 = require("./sentry-context.middleware");
|
|
19
|
-
const
|
|
18
|
+
const sentry_error_handler_strategy_1 = require("./sentry-error-handler-strategy");
|
|
20
19
|
const sentry_service_1 = require("./sentry.service");
|
|
21
20
|
const SentryOptionsProvider = {
|
|
22
21
|
provide: constants_1.SENTRY_PLUGIN_OPTIONS,
|
|
@@ -122,21 +121,14 @@ let SentryPlugin = SentryPlugin_1 = class SentryPlugin {
|
|
|
122
121
|
};
|
|
123
122
|
SentryPlugin.options = {};
|
|
124
123
|
SentryPlugin = SentryPlugin_1 = __decorate([
|
|
125
|
-
(0,
|
|
126
|
-
imports: [
|
|
127
|
-
providers: [
|
|
128
|
-
SentryOptionsProvider,
|
|
129
|
-
sentry_service_1.SentryService,
|
|
130
|
-
error_test_service_1.ErrorTestService,
|
|
131
|
-
{
|
|
132
|
-
provide: core_1.APP_FILTER,
|
|
133
|
-
useClass: sentry_filter_1.SentryExceptionsFilter,
|
|
134
|
-
},
|
|
135
|
-
],
|
|
124
|
+
(0, core_1.VendurePlugin)({
|
|
125
|
+
imports: [core_1.PluginCommonModule],
|
|
126
|
+
providers: [SentryOptionsProvider, sentry_service_1.SentryService, error_test_service_1.ErrorTestService],
|
|
136
127
|
configuration: config => {
|
|
137
128
|
config.apiOptions.apolloServerPlugins.push(new sentry_apollo_plugin_1.SentryApolloPlugin({
|
|
138
129
|
enableTracing: !!SentryPlugin_1.options.enableTracing,
|
|
139
130
|
}));
|
|
131
|
+
config.systemOptions.errorHandlers.push(new sentry_error_handler_strategy_1.SentryErrorHandlerStrategy());
|
|
140
132
|
return config;
|
|
141
133
|
},
|
|
142
134
|
adminApiExtensions: {
|
|
@@ -144,7 +136,7 @@ SentryPlugin = SentryPlugin_1 = __decorate([
|
|
|
144
136
|
resolvers: () => (SentryPlugin_1.options.includeErrorTestMutation ? [admin_test_resolver_1.SentryAdminTestResolver] : []),
|
|
145
137
|
},
|
|
146
138
|
exports: [sentry_service_1.SentryService],
|
|
147
|
-
compatibility: '^2.
|
|
139
|
+
compatibility: '^2.2.0',
|
|
148
140
|
})
|
|
149
141
|
], SentryPlugin);
|
|
150
142
|
exports.SentryPlugin = SentryPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-plugin.js","sourceRoot":"","sources":["../../src/sentry-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"sentry-plugin.js","sourceRoot":"","sources":["../../src/sentry-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,wCAAkE;AAElE,mEAAoE;AACpE,yDAAyD;AACzD,iEAA4D;AAC5D,2CAAoD;AACpD,iEAA4D;AAC5D,2EAAsE;AACtE,mFAA6E;AAC7E,qDAAiD;AAGjD,MAAM,qBAAqB,GAAG;IAC1B,OAAO,EAAE,iCAAqB;IAC9B,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO;CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAoBI,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGrB,SAAS,CAAC,QAA4B;QAClC,QAAQ,CAAC,KAAK,CAAC,mDAAuB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;;AATM,oBAAO,GAAwB,EAAS,CAAC;AADvC,YAAY;IAnBxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,CAAC,qBAAqB,EAAE,8BAAa,EAAE,qCAAgB,CAAC;QACnE,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CACtC,IAAI,yCAAkB,CAAC;gBACnB,aAAa,EAAE,CAAC,CAAC,cAAY,CAAC,OAAO,CAAC,aAAa;aACtD,CAAC,CACL,CAAC;YACF,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,0DAA0B,EAAE,CAAC,CAAC;YAC1E,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,kBAAkB,EAAE;YAChB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,cAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,kCAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7F,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,cAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,6CAAuB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACpG;QACD,OAAO,EAAE,CAAC,8BAAa,CAAC;QACxB,aAAa,EAAE,QAAQ;KAC1B,CAAC;GACW,YAAY,CAWxB;AAXY,oCAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/sentry-plugin",
|
|
3
|
-
"version": "2.2.0-next.
|
|
3
|
+
"version": "2.2.0-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@sentry/node": "^7.85.0",
|
|
25
|
-
"@vendure/common": "2.2.0-next.
|
|
26
|
-
"@vendure/core": "2.2.0-next.
|
|
25
|
+
"@vendure/common": "2.2.0-next.2",
|
|
26
|
+
"@vendure/core": "2.2.0-next.2"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "4c145666b147a13b38e3d19422727743d0a8218e"
|
|
29
29
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
|
|
2
|
-
import { SentryService } from './sentry.service';
|
|
3
|
-
export declare class SentryExceptionsFilter implements ExceptionFilter {
|
|
4
|
-
private readonly sentryService;
|
|
5
|
-
constructor(sentryService: SentryService);
|
|
6
|
-
catch(exception: Error, host: ArgumentsHost): void;
|
|
7
|
-
}
|
package/lib/src/sentry.filter.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.SentryExceptionsFilter = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const graphql_1 = require("@nestjs/graphql");
|
|
15
|
-
const node_1 = require("@sentry/node");
|
|
16
|
-
const sentry_service_1 = require("./sentry.service");
|
|
17
|
-
let SentryExceptionsFilter = class SentryExceptionsFilter {
|
|
18
|
-
constructor(sentryService) {
|
|
19
|
-
this.sentryService = sentryService;
|
|
20
|
-
}
|
|
21
|
-
catch(exception, host) {
|
|
22
|
-
if (host.getType() === 'graphql') {
|
|
23
|
-
const gqlContext = graphql_1.GqlExecutionContext.create(host);
|
|
24
|
-
const info = gqlContext.getInfo();
|
|
25
|
-
(0, node_1.setContext)('GraphQL Error Context', {
|
|
26
|
-
fieldName: info.fieldName,
|
|
27
|
-
path: info.path,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const variables = exception.variables;
|
|
31
|
-
if (variables) {
|
|
32
|
-
(0, node_1.setContext)('GraphQL Error Variables', variables);
|
|
33
|
-
}
|
|
34
|
-
this.sentryService.captureException(exception);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
SentryExceptionsFilter = __decorate([
|
|
38
|
-
(0, common_1.Catch)(),
|
|
39
|
-
__metadata("design:paramtypes", [sentry_service_1.SentryService])
|
|
40
|
-
], SentryExceptionsFilter);
|
|
41
|
-
exports.SentryExceptionsFilter = SentryExceptionsFilter;
|
|
42
|
-
//# sourceMappingURL=sentry.filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.filter.js","sourceRoot":"","sources":["../../src/sentry.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2CAAyD;AACzD,6CAAsE;AACtE,uCAA0C;AAE1C,qDAAiD;AAG1C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAC/B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,SAAgB,EAAE,IAAmB;QACvC,IAAI,IAAI,CAAC,OAAO,EAAkB,KAAK,SAAS,EAAE;YAC9C,MAAM,UAAU,GAAG,6BAAmB,CAAC,MAAM,CAAC,IAAwB,CAAC,CAAC;YACxE,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;YAClC,IAAA,iBAAU,EAAC,uBAAuB,EAAE;gBAChC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,IAAI,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CAAC;SACN;QACD,MAAM,SAAS,GAAI,SAAiB,CAAC,SAAS,CAAC;QAC/C,IAAI,SAAS,EAAE;YACX,IAAA,iBAAU,EAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;SACpD;QACD,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAlBY,sBAAsB;IADlC,IAAA,cAAK,GAAE;qCAEwC,8BAAa;GADhD,sBAAsB,CAkBlC;AAlBY,wDAAsB"}
|