@envelop/sentry 5.0.0 → 5.1.0-alpha-20230210074029-bceea042
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 -7
- package/cjs/index.js +7 -2
- package/esm/index.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
## `@envelop/sentry`
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This plugin collects errors and performance tracing for your execution flow, and reports it to [Sentry](https://sentry.io).
|
|
4
4
|
|
|
5
5
|
This is how it looks like in Sentry for error tracking:
|
|
6
6
|
|
|
7
|
-

|
|
8
|
+

|
|
9
9
|
|
|
10
10
|
> The operation name, document, variables are collected on errors, and the breadcrumbs that led to the error. You can also add any custom values that you need.
|
|
11
11
|
|
|
12
12
|
And for performance tracking:
|
|
13
13
|
|
|
14
|
-

|
|
15
|
+

|
|
16
16
|
|
|
17
17
|
> You can get information about each resolver (including field and type names), it's execution time and arguments. Also, in case of an error, the performance log and info are attached automatically to the reported Sentry error.
|
|
18
18
|
|
|
19
19
|
## Getting Started
|
|
20
20
|
|
|
21
|
-
```
|
|
21
|
+
```sh
|
|
22
22
|
yarn add @sentry/node @sentry/tracing @envelop/sentry
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
1. Start by creating an account and a project in https://sentry.io
|
|
25
|
+
1. Start by creating an account and a project in https://sentry.io
|
|
26
26
|
2. Follow the instructions to setup your Sentry instance in your application.
|
|
27
27
|
3. Setup Sentry global instance configuration.
|
|
28
28
|
4. Setup the Envelop plugin.
|
package/cjs/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const useSentry = (options = {}) => {
|
|
|
16
16
|
const renameTransaction = pick('renameTransaction', false);
|
|
17
17
|
const skipOperation = pick('skip', () => false);
|
|
18
18
|
const skipError = pick('skipError', exports.defaultSkipError);
|
|
19
|
+
const printedDocumentsCache = new WeakMap();
|
|
19
20
|
const eventIdKey = options.eventIdKey === null ? null : 'sentryEventId';
|
|
20
21
|
function addEventId(err, eventId) {
|
|
21
22
|
if (eventIdKey !== null && eventId !== null) {
|
|
@@ -32,7 +33,11 @@ const useSentry = (options = {}) => {
|
|
|
32
33
|
// @ts-expect-error TODO: not sure how we will make it dev friendly
|
|
33
34
|
o => o.kind === graphql_1.Kind.OPERATION_DEFINITION);
|
|
34
35
|
const operationType = rootOperation.operation;
|
|
35
|
-
|
|
36
|
+
let document = printedDocumentsCache.get(args.document);
|
|
37
|
+
if (!document) {
|
|
38
|
+
document = (0, graphql_1.print)(args.document);
|
|
39
|
+
printedDocumentsCache.set(args.document, document);
|
|
40
|
+
}
|
|
36
41
|
const opName = args.operationName || rootOperation.name?.value || 'Anonymous Operation';
|
|
37
42
|
const addedTags = (options.appendTags && options.appendTags(args)) || {};
|
|
38
43
|
const traceparentData = (options.traceparentData && options.traceparentData(args)) || {};
|
|
@@ -70,7 +75,7 @@ const useSentry = (options = {}) => {
|
|
|
70
75
|
if (!span) {
|
|
71
76
|
// eslint-disable-next-line no-console
|
|
72
77
|
console.warn([
|
|
73
|
-
`Flag "startTransaction" is
|
|
78
|
+
`Flag "startTransaction" is disabled but Sentry failed to find a transaction.`,
|
|
74
79
|
`Try to create a transaction before GraphQL execution phase is started.`,
|
|
75
80
|
].join('\n'));
|
|
76
81
|
return {};
|
package/esm/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export const useSentry = (options = {}) => {
|
|
|
12
12
|
const renameTransaction = pick('renameTransaction', false);
|
|
13
13
|
const skipOperation = pick('skip', () => false);
|
|
14
14
|
const skipError = pick('skipError', defaultSkipError);
|
|
15
|
+
const printedDocumentsCache = new WeakMap();
|
|
15
16
|
const eventIdKey = options.eventIdKey === null ? null : 'sentryEventId';
|
|
16
17
|
function addEventId(err, eventId) {
|
|
17
18
|
if (eventIdKey !== null && eventId !== null) {
|
|
@@ -28,7 +29,11 @@ export const useSentry = (options = {}) => {
|
|
|
28
29
|
// @ts-expect-error TODO: not sure how we will make it dev friendly
|
|
29
30
|
o => o.kind === Kind.OPERATION_DEFINITION);
|
|
30
31
|
const operationType = rootOperation.operation;
|
|
31
|
-
|
|
32
|
+
let document = printedDocumentsCache.get(args.document);
|
|
33
|
+
if (!document) {
|
|
34
|
+
document = print(args.document);
|
|
35
|
+
printedDocumentsCache.set(args.document, document);
|
|
36
|
+
}
|
|
32
37
|
const opName = args.operationName || rootOperation.name?.value || 'Anonymous Operation';
|
|
33
38
|
const addedTags = (options.appendTags && options.appendTags(args)) || {};
|
|
34
39
|
const traceparentData = (options.traceparentData && options.traceparentData(args)) || {};
|
|
@@ -66,7 +71,7 @@ export const useSentry = (options = {}) => {
|
|
|
66
71
|
if (!span) {
|
|
67
72
|
// eslint-disable-next-line no-console
|
|
68
73
|
console.warn([
|
|
69
|
-
`Flag "startTransaction" is
|
|
74
|
+
`Flag "startTransaction" is disabled but Sentry failed to find a transaction.`,
|
|
70
75
|
`Try to create a transaction before GraphQL execution phase is started.`,
|
|
71
76
|
].join('\n'));
|
|
72
77
|
return {};
|