@vendure/sentry-plugin 2.1.4
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/README.md +7 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/src/api/admin-test.resolver.d.ts +10 -0
- package/lib/src/api/admin-test.resolver.js +56 -0
- package/lib/src/api/admin-test.resolver.js.map +1 -0
- package/lib/src/api/api-extensions.d.ts +1 -0
- package/lib/src/api/api-extensions.js +20 -0
- package/lib/src/api/api-extensions.js.map +1 -0
- package/lib/src/api/error-test.service.d.ts +6 -0
- package/lib/src/api/error-test.service.js +28 -0
- package/lib/src/api/error-test.service.js.map +1 -0
- package/lib/src/constants.d.ts +3 -0
- package/lib/src/constants.js +7 -0
- package/lib/src/constants.js.map +1 -0
- package/lib/src/sentry-apollo-plugin.d.ts +11 -0
- package/lib/src/sentry-apollo-plugin.js +51 -0
- package/lib/src/sentry-apollo-plugin.js.map +1 -0
- package/lib/src/sentry-context.middleware.d.ts +10 -0
- package/lib/src/sentry-context.middleware.js +41 -0
- package/lib/src/sentry-context.middleware.js.map +1 -0
- package/lib/src/sentry-plugin.d.ts +96 -0
- package/lib/src/sentry-plugin.js +151 -0
- package/lib/src/sentry-plugin.js.map +1 -0
- package/lib/src/sentry.filter.d.ts +7 -0
- package/lib/src/sentry.filter.js +42 -0
- package/lib/src/sentry.filter.js.map +1 -0
- package/lib/src/sentry.service.d.ts +13 -0
- package/lib/src/sentry.service.js +73 -0
- package/lib/src/sentry.service.js.map +1 -0
- package/lib/src/types.d.ts +23 -0
- package/lib/src/types.js +4 -0
- package/lib/src/types.js.map +1 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Vendure Sentry Plugin
|
|
2
|
+
|
|
3
|
+
Integrates your Vendure server with the [Sentry](https://sentry.io/) application monitoring service.
|
|
4
|
+
|
|
5
|
+
`npm install @vendure/sentry-plugin`
|
|
6
|
+
|
|
7
|
+
For documentation, see [docs.vendure.io/typescript-api/core-plugins/sentry-plugin/](https://docs.vendure.io/typescript-api/core-plugins/sentry-plugin/)
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/sentry-plugin"), exports);
|
|
18
|
+
__exportStar(require("./src/sentry.service"), exports);
|
|
19
|
+
__exportStar(require("./src/types"), exports);
|
|
20
|
+
__exportStar(require("./src/constants"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,uDAAqC;AACrC,8CAA4B;AAC5B,kDAAgC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SentryService } from '../sentry.service';
|
|
2
|
+
import { ErrorTestService } from './error-test.service';
|
|
3
|
+
export declare class SentryAdminTestResolver {
|
|
4
|
+
private sentryService;
|
|
5
|
+
private errorTestService;
|
|
6
|
+
constructor(sentryService: SentryService, errorTestService: ErrorTestService);
|
|
7
|
+
createTestError(args: {
|
|
8
|
+
errorType: string;
|
|
9
|
+
}): Promise<number | true | undefined>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SentryAdminTestResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const sentry_service_1 = require("../sentry.service");
|
|
19
|
+
const error_test_service_1 = require("./error-test.service");
|
|
20
|
+
let SentryAdminTestResolver = class SentryAdminTestResolver {
|
|
21
|
+
constructor(sentryService, errorTestService) {
|
|
22
|
+
this.sentryService = sentryService;
|
|
23
|
+
this.errorTestService = errorTestService;
|
|
24
|
+
}
|
|
25
|
+
async createTestError(args) {
|
|
26
|
+
switch (args.errorType) {
|
|
27
|
+
case 'UNCAUGHT_ERROR':
|
|
28
|
+
return a / 10;
|
|
29
|
+
case 'THROWN_ERROR':
|
|
30
|
+
throw new core_1.UserInputError('SentryPlugin Test Error');
|
|
31
|
+
case 'CAPTURED_ERROR':
|
|
32
|
+
this.sentryService.captureException(new Error('SentryPlugin Direct error'));
|
|
33
|
+
return true;
|
|
34
|
+
case 'CAPTURED_MESSAGE':
|
|
35
|
+
this.sentryService.captureMessage('Captured message');
|
|
36
|
+
return true;
|
|
37
|
+
case 'DATABASE_ERROR':
|
|
38
|
+
await this.errorTestService.createDatabaseError();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Allow)(core_1.Permission.SuperAdmin),
|
|
45
|
+
(0, graphql_1.Mutation)(),
|
|
46
|
+
__param(0, (0, graphql_1.Args)()),
|
|
47
|
+
__metadata("design:type", Function),
|
|
48
|
+
__metadata("design:paramtypes", [Object]),
|
|
49
|
+
__metadata("design:returntype", Promise)
|
|
50
|
+
], SentryAdminTestResolver.prototype, "createTestError", null);
|
|
51
|
+
SentryAdminTestResolver = __decorate([
|
|
52
|
+
(0, graphql_1.Resolver)(),
|
|
53
|
+
__metadata("design:paramtypes", [sentry_service_1.SentryService, error_test_service_1.ErrorTestService])
|
|
54
|
+
], SentryAdminTestResolver);
|
|
55
|
+
exports.SentryAdminTestResolver = SentryAdminTestResolver;
|
|
56
|
+
//# sourceMappingURL=admin-test.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-test.resolver.js","sourceRoot":"","sources":["../../../src/api/admin-test.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA2D;AAC3D,wCAAkE;AAElE,sDAAkD;AAClD,6DAAwD;AAKjD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAChC,YAAoB,aAA4B,EAAU,gBAAkC;QAAxE,kBAAa,GAAb,aAAa,CAAe;QAAU,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAI1F,AAAN,KAAK,CAAC,eAAe,CAAS,IAA2B;QACrD,QAAQ,IAAI,CAAC,SAAS,EAAE;YACpB,KAAK,gBAAgB;gBACjB,OAAO,CAAC,GAAG,EAAE,CAAC;YAClB,KAAK,cAAc;gBACf,MAAM,IAAI,qBAAc,CAAC,yBAAyB,CAAC,CAAC;YACxD,KAAK,gBAAgB;gBACjB,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;gBAC5E,OAAO,IAAI,CAAC;YAChB,KAAK,kBAAkB;gBACnB,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;gBACtD,OAAO,IAAI,CAAC;YAChB,KAAK,gBAAgB;gBACjB,MAAM,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;gBAClD,OAAO,IAAI,CAAC;SACnB;IACL,CAAC;CACJ,CAAA;AAjBS;IAFL,IAAA,YAAK,EAAC,iBAAU,CAAC,UAAU,CAAC;IAC5B,IAAA,kBAAQ,GAAE;IACY,WAAA,IAAA,cAAI,GAAE,CAAA;;;;8DAgB5B;AArBQ,uBAAuB;IADnC,IAAA,kBAAQ,GAAE;qCAE4B,8BAAa,EAA4B,qCAAgB;GADnF,uBAAuB,CAsBnC;AAtBY,0DAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testApiExtensions: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.testApiExtensions = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
exports.testApiExtensions = (0, graphql_tag_1.default) `
|
|
9
|
+
enum TestErrorType {
|
|
10
|
+
UNCAUGHT_ERROR
|
|
11
|
+
THROWN_ERROR
|
|
12
|
+
CAPTURED_ERROR
|
|
13
|
+
CAPTURED_MESSAGE
|
|
14
|
+
DATABASE_ERROR
|
|
15
|
+
}
|
|
16
|
+
extend type Mutation {
|
|
17
|
+
createTestError(errorType: TestErrorType!): Boolean
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
//# sourceMappingURL=api-extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-extensions.js","sourceRoot":"","sources":["../../../src/api/api-extensions.ts"],"names":[],"mappings":";;;;;;AAAA,8DAA8B;AAEjB,QAAA,iBAAiB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;CAWnC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.ErrorTestService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@vendure/core");
|
|
15
|
+
let ErrorTestService = class ErrorTestService {
|
|
16
|
+
constructor(connection) {
|
|
17
|
+
this.connection = connection;
|
|
18
|
+
}
|
|
19
|
+
createDatabaseError() {
|
|
20
|
+
return this.connection.rawConnection.query('SELECT * FROM non_existent_table');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
ErrorTestService = __decorate([
|
|
24
|
+
(0, common_1.Injectable)(),
|
|
25
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection])
|
|
26
|
+
], ErrorTestService);
|
|
27
|
+
exports.ErrorTestService = ErrorTestService;
|
|
28
|
+
//# sourceMappingURL=error-test.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-test.service.js","sourceRoot":"","sources":["../../../src/api/error-test.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wCAAwD;AAGjD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACzB,YAAoB,UAAmC;QAAnC,eAAU,GAAV,UAAU,CAAyB;IAAG,CAAC;IAE3D,mBAAmB;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACnF,CAAC;CACJ,CAAA;AANY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAEuB,8BAAuB;GAD9C,gBAAgB,CAM5B;AANY,4CAAgB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loggerCtx = exports.SENTRY_TRANSACTION_KEY = exports.SENTRY_PLUGIN_OPTIONS = void 0;
|
|
4
|
+
exports.SENTRY_PLUGIN_OPTIONS = 'SENTRY_PLUGIN_OPTIONS';
|
|
5
|
+
exports.SENTRY_TRANSACTION_KEY = 'SENTRY_PLUGIN_TRANSACTION';
|
|
6
|
+
exports.loggerCtx = 'SentryPlugin';
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,sBAAsB,GAAG,2BAA2B,CAAC;AACrD,QAAA,SAAS,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ApolloServerPlugin, GraphQLRequestListener, GraphQLRequestContext } from '@apollo/server';
|
|
2
|
+
/**
|
|
3
|
+
* Based on https://github.com/ntegral/nestjs-sentry/issues/97#issuecomment-1252446807
|
|
4
|
+
*/
|
|
5
|
+
export declare class SentryApolloPlugin implements ApolloServerPlugin {
|
|
6
|
+
private options;
|
|
7
|
+
constructor(options: {
|
|
8
|
+
enableTracing: boolean;
|
|
9
|
+
});
|
|
10
|
+
requestDidStart({ request, contextValue, }: GraphQLRequestContext<any>): Promise<GraphQLRequestListener<any>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SentryApolloPlugin = void 0;
|
|
4
|
+
const node_1 = require("@sentry/node");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Based on https://github.com/ntegral/nestjs-sentry/issues/97#issuecomment-1252446807
|
|
8
|
+
*/
|
|
9
|
+
class SentryApolloPlugin {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
async requestDidStart({ request, contextValue, }) {
|
|
14
|
+
const { enableTracing } = this.options;
|
|
15
|
+
const transaction = contextValue.req[constants_1.SENTRY_TRANSACTION_KEY];
|
|
16
|
+
if (request.operationName) {
|
|
17
|
+
if (enableTracing) {
|
|
18
|
+
// set the transaction Name if we have named queries
|
|
19
|
+
transaction === null || transaction === void 0 ? void 0 : transaction.setName(request.operationName);
|
|
20
|
+
}
|
|
21
|
+
(0, node_1.setContext)('Graphql Request', {
|
|
22
|
+
operation_name: request.operationName,
|
|
23
|
+
variables: request.variables,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
// hook for transaction finished
|
|
28
|
+
async willSendResponse(context) {
|
|
29
|
+
transaction === null || transaction === void 0 ? void 0 : transaction.finish();
|
|
30
|
+
},
|
|
31
|
+
async executionDidStart() {
|
|
32
|
+
return {
|
|
33
|
+
// hook for each new resolver
|
|
34
|
+
willResolveField({ info }) {
|
|
35
|
+
if (enableTracing) {
|
|
36
|
+
const span = transaction === null || transaction === void 0 ? void 0 : transaction.startChild({
|
|
37
|
+
op: 'resolver',
|
|
38
|
+
description: `${info.parentType.name}.${info.fieldName}`,
|
|
39
|
+
});
|
|
40
|
+
return () => {
|
|
41
|
+
span === null || span === void 0 ? void 0 : span.finish();
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.SentryApolloPlugin = SentryApolloPlugin;
|
|
51
|
+
//# sourceMappingURL=sentry-apollo-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-apollo-plugin.js","sourceRoot":"","sources":["../../src/sentry-apollo-plugin.ts"],"names":[],"mappings":";;;AAOA,uCAAuD;AAEvD,2CAAqD;AAErD;;GAEG;AACH,MAAa,kBAAkB;IAC3B,YAAoB,OAAmC;QAAnC,YAAO,GAAP,OAAO,CAA4B;IAAG,CAAC;IAE3D,KAAK,CAAC,eAAe,CAAC,EAClB,OAAO,EACP,YAAY,GACa;QACzB,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACvC,MAAM,WAAW,GAA4B,YAAY,CAAC,GAAG,CAAC,kCAAsB,CAAC,CAAC;QACtF,IAAI,OAAO,CAAC,aAAa,EAAE;YACvB,IAAI,aAAa,EAAE;gBACf,oDAAoD;gBACpD,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;aAC/C;YACD,IAAA,iBAAU,EAAC,iBAAiB,EAAE;gBAC1B,cAAc,EAAE,OAAO,CAAC,aAAa;gBACrC,SAAS,EAAE,OAAO,CAAC,SAAS;aAC/B,CAAC,CAAC;SACN;QAED,OAAO;YACH,gCAAgC;YAChC,KAAK,CAAC,gBAAgB,CAAC,OAAO;gBAC1B,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE,CAAC;YAC1B,CAAC;YACD,KAAK,CAAC,iBAAiB;gBACnB,OAAO;oBACH,6BAA6B;oBAC7B,gBAAgB,CAAC,EAAE,IAAI,EAAE;wBACrB,IAAI,aAAa,EAAE;4BACf,MAAM,IAAI,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,CAAC;gCACjC,EAAE,EAAE,UAAU;gCACd,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;6BAC3D,CAAC,CAAC;4BACH,OAAO,GAAG,EAAE;gCACR,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,EAAE,CAAC;4BACnB,CAAC,CAAC;yBACL;oBACL,CAAC;iBACJ,CAAC;YACN,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AA3CD,gDA2CC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
2
|
+
import { Request, Response, NextFunction } from 'express';
|
|
3
|
+
import { SentryService } from './sentry.service';
|
|
4
|
+
import { SentryPluginOptions } from './types';
|
|
5
|
+
export declare class SentryContextMiddleware implements NestMiddleware {
|
|
6
|
+
private options;
|
|
7
|
+
private sentryService;
|
|
8
|
+
constructor(options: SentryPluginOptions, sentryService: SentryService);
|
|
9
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SentryContextMiddleware = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const constants_1 = require("./constants");
|
|
18
|
+
const sentry_service_1 = require("./sentry.service");
|
|
19
|
+
let SentryContextMiddleware = class SentryContextMiddleware {
|
|
20
|
+
constructor(options, sentryService) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.sentryService = sentryService;
|
|
23
|
+
}
|
|
24
|
+
use(req, res, next) {
|
|
25
|
+
if (this.options.enableTracing) {
|
|
26
|
+
const transaction = this.sentryService.startTransaction({
|
|
27
|
+
op: 'resolver',
|
|
28
|
+
name: `GraphQLTransaction`,
|
|
29
|
+
});
|
|
30
|
+
req[constants_1.SENTRY_TRANSACTION_KEY] = transaction;
|
|
31
|
+
}
|
|
32
|
+
next();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
SentryContextMiddleware = __decorate([
|
|
36
|
+
(0, common_1.Injectable)(),
|
|
37
|
+
__param(0, (0, common_1.Inject)(constants_1.SENTRY_PLUGIN_OPTIONS)),
|
|
38
|
+
__metadata("design:paramtypes", [Object, sentry_service_1.SentryService])
|
|
39
|
+
], SentryContextMiddleware);
|
|
40
|
+
exports.SentryContextMiddleware = SentryContextMiddleware;
|
|
41
|
+
//# sourceMappingURL=sentry-context.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-context.middleware.js","sourceRoot":"","sources":["../../src/sentry-context.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AAGpE,2CAA4E;AAC5E,qDAAiD;AAI1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAChC,YAC2C,OAA4B,EAC3D,aAA4B;QADG,YAAO,GAAP,OAAO,CAAqB;QAC3D,kBAAa,GAAb,aAAa,CAAe;IACrC,CAAC;IAEJ,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC;gBACpD,EAAE,EAAE,UAAU;gBACd,IAAI,EAAE,oBAAoB;aAC7B,CAAC,CAAC;YACH,GAAG,CAAC,kCAAsB,CAAC,GAAG,WAAW,CAAC;SAC7C;QACD,IAAI,EAAE,CAAC;IACX,CAAC;CACJ,CAAA;AAhBY,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,iCAAqB,CAAC,CAAA;6CACP,8BAAa;GAH/B,uBAAuB,CAgBnC;AAhBY,0DAAuB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
|
+
import { SentryPluginOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* This plugin integrates the [Sentry](https://sentry.io) error tracking & performance monitoring
|
|
6
|
+
* service with your Vendure server. In addition to capturing errors, it also provides built-in
|
|
7
|
+
* support for [tracing](https://docs.sentry.io/product/sentry-basics/concepts/tracing/) as well as
|
|
8
|
+
* enriching your Sentry events with additional context about the request.
|
|
9
|
+
*
|
|
10
|
+
* ## Pre-requisites
|
|
11
|
+
*
|
|
12
|
+
* This plugin depends on access to Sentry, which can be self-hosted or used as a cloud service.
|
|
13
|
+
*
|
|
14
|
+
* If using the hosted SaaS option, you must have a Sentry account and a project set up ([sign up here](https://sentry.io/signup/)). When setting up your project,
|
|
15
|
+
* select the "Node.js" platform and no framework.
|
|
16
|
+
*
|
|
17
|
+
* Once set up, you will be given a [Data Source Name (DSN)](https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/)
|
|
18
|
+
* which you will need to provide to the plugin.
|
|
19
|
+
*
|
|
20
|
+
* ## Installation
|
|
21
|
+
*
|
|
22
|
+
* Install this plugin as well as the `@sentry/node` package:
|
|
23
|
+
*
|
|
24
|
+
* ```sh
|
|
25
|
+
* npm install --save \@vendure/sentry-plugin \@sentry/node
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Configuration
|
|
29
|
+
*
|
|
30
|
+
* Before using the plugin, you must configure it with the DSN provided by Sentry:
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { VendureConfig } from '\@vendure/core';
|
|
34
|
+
* import { SentryPlugin } from '\@vendure/sentry-plugin';
|
|
35
|
+
*
|
|
36
|
+
* export const config: VendureConfig = {
|
|
37
|
+
* // ...
|
|
38
|
+
* plugins: [
|
|
39
|
+
* // ...
|
|
40
|
+
* // highlight-start
|
|
41
|
+
* SentryPlugin.init({
|
|
42
|
+
* dsn: process.env.SENTRY_DSN,
|
|
43
|
+
* // Optional configuration
|
|
44
|
+
* includeErrorTestMutation: true,
|
|
45
|
+
* enableTracing: true,
|
|
46
|
+
* // you can also pass in any of the options from \@sentry/node
|
|
47
|
+
* // for instance:
|
|
48
|
+
* tracesSampleRate: 1.0,
|
|
49
|
+
* }),
|
|
50
|
+
* // highlight-end
|
|
51
|
+
* ],
|
|
52
|
+
* };
|
|
53
|
+
*```
|
|
54
|
+
*
|
|
55
|
+
* ## Tracing
|
|
56
|
+
*
|
|
57
|
+
* This plugin includes built-in support for [tracing](https://docs.sentry.io/product/sentry-basics/concepts/tracing/), which allows you to see the performance of your
|
|
58
|
+
* GraphQL resolvers in the Sentry dashboard. To enable tracing, set the `enableTracing` option to `true` as shown above.
|
|
59
|
+
*
|
|
60
|
+
* ## Instrumenting your own code
|
|
61
|
+
*
|
|
62
|
+
* You may want to add your own custom spans to your code. To do so, you can use the `Sentry` object
|
|
63
|
+
* just as you would in any Node application. For example:
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* import * as Sentry from "\@sentry/node";
|
|
67
|
+
*
|
|
68
|
+
* export class MyService {
|
|
69
|
+
* async myMethod() {
|
|
70
|
+
* Sentry.setContext('My Custom Context,{
|
|
71
|
+
* key: 'value',
|
|
72
|
+
* });
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* ## Error test mutation
|
|
78
|
+
*
|
|
79
|
+
* To test whether your Sentry configuration is working correctly, you can set the `includeErrorTestMutation` option to `true`. This will add a mutation to the Admin API
|
|
80
|
+
* which will throw an error of the type specified in the `errorType` argument. For example:
|
|
81
|
+
*
|
|
82
|
+
* ```graphql
|
|
83
|
+
* mutation CreateTestError {
|
|
84
|
+
* createTestError(errorType: DATABASE_ERROR)
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* You should then be able to see the error in your Sentry dashboard (it may take a couple of minutes to appear).
|
|
89
|
+
*
|
|
90
|
+
* @docsCategory core plugins/SentryPlugin
|
|
91
|
+
*/
|
|
92
|
+
export declare class SentryPlugin implements NestModule {
|
|
93
|
+
static options: SentryPluginOptions;
|
|
94
|
+
configure(consumer: MiddlewareConsumer): any;
|
|
95
|
+
static init(options: SentryPluginOptions): typeof SentryPlugin;
|
|
96
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
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 SentryPlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SentryPlugin = void 0;
|
|
11
|
+
const core_1 = require("@nestjs/core");
|
|
12
|
+
const core_2 = require("@vendure/core");
|
|
13
|
+
const admin_test_resolver_1 = require("./api/admin-test.resolver");
|
|
14
|
+
const api_extensions_1 = require("./api/api-extensions");
|
|
15
|
+
const error_test_service_1 = require("./api/error-test.service");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
17
|
+
const sentry_apollo_plugin_1 = require("./sentry-apollo-plugin");
|
|
18
|
+
const sentry_context_middleware_1 = require("./sentry-context.middleware");
|
|
19
|
+
const sentry_filter_1 = require("./sentry.filter");
|
|
20
|
+
const sentry_service_1 = require("./sentry.service");
|
|
21
|
+
const SentryOptionsProvider = {
|
|
22
|
+
provide: constants_1.SENTRY_PLUGIN_OPTIONS,
|
|
23
|
+
useFactory: () => SentryPlugin.options,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @description
|
|
27
|
+
* This plugin integrates the [Sentry](https://sentry.io) error tracking & performance monitoring
|
|
28
|
+
* service with your Vendure server. In addition to capturing errors, it also provides built-in
|
|
29
|
+
* support for [tracing](https://docs.sentry.io/product/sentry-basics/concepts/tracing/) as well as
|
|
30
|
+
* enriching your Sentry events with additional context about the request.
|
|
31
|
+
*
|
|
32
|
+
* ## Pre-requisites
|
|
33
|
+
*
|
|
34
|
+
* This plugin depends on access to Sentry, which can be self-hosted or used as a cloud service.
|
|
35
|
+
*
|
|
36
|
+
* If using the hosted SaaS option, you must have a Sentry account and a project set up ([sign up here](https://sentry.io/signup/)). When setting up your project,
|
|
37
|
+
* select the "Node.js" platform and no framework.
|
|
38
|
+
*
|
|
39
|
+
* Once set up, you will be given a [Data Source Name (DSN)](https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/)
|
|
40
|
+
* which you will need to provide to the plugin.
|
|
41
|
+
*
|
|
42
|
+
* ## Installation
|
|
43
|
+
*
|
|
44
|
+
* Install this plugin as well as the `@sentry/node` package:
|
|
45
|
+
*
|
|
46
|
+
* ```sh
|
|
47
|
+
* npm install --save \@vendure/sentry-plugin \@sentry/node
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* ## Configuration
|
|
51
|
+
*
|
|
52
|
+
* Before using the plugin, you must configure it with the DSN provided by Sentry:
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { VendureConfig } from '\@vendure/core';
|
|
56
|
+
* import { SentryPlugin } from '\@vendure/sentry-plugin';
|
|
57
|
+
*
|
|
58
|
+
* export const config: VendureConfig = {
|
|
59
|
+
* // ...
|
|
60
|
+
* plugins: [
|
|
61
|
+
* // ...
|
|
62
|
+
* // highlight-start
|
|
63
|
+
* SentryPlugin.init({
|
|
64
|
+
* dsn: process.env.SENTRY_DSN,
|
|
65
|
+
* // Optional configuration
|
|
66
|
+
* includeErrorTestMutation: true,
|
|
67
|
+
* enableTracing: true,
|
|
68
|
+
* // you can also pass in any of the options from \@sentry/node
|
|
69
|
+
* // for instance:
|
|
70
|
+
* tracesSampleRate: 1.0,
|
|
71
|
+
* }),
|
|
72
|
+
* // highlight-end
|
|
73
|
+
* ],
|
|
74
|
+
* };
|
|
75
|
+
*```
|
|
76
|
+
*
|
|
77
|
+
* ## Tracing
|
|
78
|
+
*
|
|
79
|
+
* This plugin includes built-in support for [tracing](https://docs.sentry.io/product/sentry-basics/concepts/tracing/), which allows you to see the performance of your
|
|
80
|
+
* GraphQL resolvers in the Sentry dashboard. To enable tracing, set the `enableTracing` option to `true` as shown above.
|
|
81
|
+
*
|
|
82
|
+
* ## Instrumenting your own code
|
|
83
|
+
*
|
|
84
|
+
* You may want to add your own custom spans to your code. To do so, you can use the `Sentry` object
|
|
85
|
+
* just as you would in any Node application. For example:
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* import * as Sentry from "\@sentry/node";
|
|
89
|
+
*
|
|
90
|
+
* export class MyService {
|
|
91
|
+
* async myMethod() {
|
|
92
|
+
* Sentry.setContext('My Custom Context,{
|
|
93
|
+
* key: 'value',
|
|
94
|
+
* });
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* ## Error test mutation
|
|
100
|
+
*
|
|
101
|
+
* To test whether your Sentry configuration is working correctly, you can set the `includeErrorTestMutation` option to `true`. This will add a mutation to the Admin API
|
|
102
|
+
* which will throw an error of the type specified in the `errorType` argument. For example:
|
|
103
|
+
*
|
|
104
|
+
* ```graphql
|
|
105
|
+
* mutation CreateTestError {
|
|
106
|
+
* createTestError(errorType: DATABASE_ERROR)
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* You should then be able to see the error in your Sentry dashboard (it may take a couple of minutes to appear).
|
|
111
|
+
*
|
|
112
|
+
* @docsCategory core plugins/SentryPlugin
|
|
113
|
+
*/
|
|
114
|
+
let SentryPlugin = SentryPlugin_1 = class SentryPlugin {
|
|
115
|
+
configure(consumer) {
|
|
116
|
+
consumer.apply(sentry_context_middleware_1.SentryContextMiddleware).forRoutes('*');
|
|
117
|
+
}
|
|
118
|
+
static init(options) {
|
|
119
|
+
this.options = options;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
SentryPlugin.options = {};
|
|
124
|
+
SentryPlugin = SentryPlugin_1 = __decorate([
|
|
125
|
+
(0, core_2.VendurePlugin)({
|
|
126
|
+
imports: [core_2.PluginCommonModule],
|
|
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
|
+
],
|
|
136
|
+
configuration: config => {
|
|
137
|
+
config.apiOptions.apolloServerPlugins.push(new sentry_apollo_plugin_1.SentryApolloPlugin({
|
|
138
|
+
enableTracing: !!SentryPlugin_1.options.enableTracing,
|
|
139
|
+
}));
|
|
140
|
+
return config;
|
|
141
|
+
},
|
|
142
|
+
adminApiExtensions: {
|
|
143
|
+
schema: () => (SentryPlugin_1.options.includeErrorTestMutation ? api_extensions_1.testApiExtensions : undefined),
|
|
144
|
+
resolvers: () => (SentryPlugin_1.options.includeErrorTestMutation ? [admin_test_resolver_1.SentryAdminTestResolver] : []),
|
|
145
|
+
},
|
|
146
|
+
exports: [sentry_service_1.SentryService],
|
|
147
|
+
compatibility: '^2.0.0',
|
|
148
|
+
})
|
|
149
|
+
], SentryPlugin);
|
|
150
|
+
exports.SentryPlugin = SentryPlugin;
|
|
151
|
+
//# sourceMappingURL=sentry-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-plugin.js","sourceRoot":"","sources":["../../src/sentry-plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,uCAA0C;AAC1C,wCAAkE;AAElE,mEAAoE;AACpE,yDAAyD;AACzD,iEAA4D;AAC5D,2CAAoD;AACpD,iEAA4D;AAC5D,2EAAsE;AACtE,mDAAyD;AACzD,qDAAiD;AAGjD,MAAM,qBAAqB,GAAG;IAC1B,OAAO,EAAE,iCAAqB;IAC9B,UAAU,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO;CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AA2BI,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;IA1BxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE;YACP,qBAAqB;YACrB,8BAAa;YACb,qCAAgB;YAChB;gBACI,OAAO,EAAE,iBAAU;gBACnB,QAAQ,EAAE,sCAAsB;aACnC;SACJ;QACD,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,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
2
|
+
import * as Sentry from '@sentry/node';
|
|
3
|
+
import { CaptureContext, TransactionContext } from '@sentry/types';
|
|
4
|
+
import { SentryPluginOptions } from './types';
|
|
5
|
+
export declare class SentryService implements OnApplicationBootstrap, OnApplicationShutdown {
|
|
6
|
+
private options;
|
|
7
|
+
constructor(options: SentryPluginOptions);
|
|
8
|
+
onApplicationBootstrap(): any;
|
|
9
|
+
onApplicationShutdown(): Promise<boolean>;
|
|
10
|
+
captureException(exception: Error): void;
|
|
11
|
+
captureMessage(message: string, captureContext?: CaptureContext): void;
|
|
12
|
+
startTransaction(context: TransactionContext): Sentry.Transaction;
|
|
13
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.SentryService = void 0;
|
|
39
|
+
const common_1 = require("@nestjs/common");
|
|
40
|
+
const Sentry = __importStar(require("@sentry/node"));
|
|
41
|
+
const constants_1 = require("./constants");
|
|
42
|
+
let SentryService = class SentryService {
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.options = options;
|
|
45
|
+
}
|
|
46
|
+
onApplicationBootstrap() {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const integrations = (_a = this.options.integrations) !== null && _a !== void 0 ? _a : [
|
|
49
|
+
new Sentry.Integrations.Http({ tracing: true }),
|
|
50
|
+
...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
|
|
51
|
+
];
|
|
52
|
+
Sentry.init(Object.assign(Object.assign({}, this.options), { tracesSampleRate: (_b = this.options.tracesSampleRate) !== null && _b !== void 0 ? _b : 1.0, integrations, dsn: this.options.dsn }));
|
|
53
|
+
}
|
|
54
|
+
onApplicationShutdown() {
|
|
55
|
+
return Sentry.close();
|
|
56
|
+
}
|
|
57
|
+
captureException(exception) {
|
|
58
|
+
Sentry.captureException(exception);
|
|
59
|
+
}
|
|
60
|
+
captureMessage(message, captureContext) {
|
|
61
|
+
Sentry.captureMessage(message, captureContext);
|
|
62
|
+
}
|
|
63
|
+
startTransaction(context) {
|
|
64
|
+
return Sentry.startTransaction(context);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
SentryService = __decorate([
|
|
68
|
+
(0, common_1.Injectable)(),
|
|
69
|
+
__param(0, (0, common_1.Inject)(constants_1.SENTRY_PLUGIN_OPTIONS)),
|
|
70
|
+
__metadata("design:paramtypes", [Object])
|
|
71
|
+
], SentryService);
|
|
72
|
+
exports.SentryService = SentryService;
|
|
73
|
+
//# sourceMappingURL=sentry.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry.service.js","sourceRoot":"","sources":["../../src/sentry.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAmG;AACnG,qDAAuC;AAGvC,2CAAoD;AAI7C,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,YAAmD,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;IAAG,CAAC;IAEnF,sBAAsB;;QAClB,MAAM,YAAY,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,YAAY,mCAAI;YAC9C,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC/C,GAAG,MAAM,CAAC,iDAAiD,EAAE;SAChE,CAAC;QACF,MAAM,CAAC,IAAI,iCACJ,IAAI,CAAC,OAAO,KACf,gBAAgB,EAAE,MAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,mCAAI,GAAG,EACtD,YAAY,EACZ,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IACvB,CAAC;IACP,CAAC;IAED,qBAAqB;QACjB,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB,CAAC,SAAgB;QAC7B,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,cAAc,CAAC,OAAe,EAAE,cAA+B;QAC3D,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACnD,CAAC;IAED,gBAAgB,CAAC,OAA2B;QACxC,OAAO,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACJ,CAAA;AA/BY,aAAa;IADzB,IAAA,mBAAU,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,iCAAqB,CAAC,CAAA;;GADjC,aAAa,CA+BzB;AA/BY,sCAAa"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Transaction } from '@sentry/node';
|
|
2
|
+
import { NodeOptions } from '@sentry/node/types/types';
|
|
3
|
+
import { SENTRY_TRANSACTION_KEY } from './constants';
|
|
4
|
+
/**
|
|
5
|
+
* @description
|
|
6
|
+
* Configuration options for the {@link SentryPlugin}.
|
|
7
|
+
*
|
|
8
|
+
* @docsCategory core plugins/SentryPlugin
|
|
9
|
+
*/
|
|
10
|
+
export interface SentryPluginOptions extends NodeOptions {
|
|
11
|
+
/**
|
|
12
|
+
* @description
|
|
13
|
+
* The [Data Source Name](https://docs.sentry.io/product/sentry-basics/concepts/dsn-explainer/) for your Sentry instance.
|
|
14
|
+
*/
|
|
15
|
+
dsn: string;
|
|
16
|
+
enableTracing?: boolean;
|
|
17
|
+
includeErrorTestMutation?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare module 'express' {
|
|
20
|
+
interface Request {
|
|
21
|
+
[SENTRY_TRANSACTION_KEY]: Transaction | undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/lib/src/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;AAGA,2CAAqD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vendure/sentry-plugin",
|
|
3
|
+
"version": "2.1.4",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
12
|
+
"build": "rimraf lib && tsc -p ./tsconfig.build.json",
|
|
13
|
+
"lint": "eslint --fix ."
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://www.vendure.io",
|
|
16
|
+
"funding": "https://github.com/sponsors/michaelbromley",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@sentry/node": "^7.85.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vendure/common": "^2.1.4",
|
|
25
|
+
"@vendure/core": "^2.1.4",
|
|
26
|
+
"@sentry/node": "^7.85.0"
|
|
27
|
+
}
|
|
28
|
+
}
|