@envelop/newrelic 1.2.1 → 1.3.1-alpha-33ac2d1.0

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/index.d.ts CHANGED
@@ -7,5 +7,11 @@ export declare type UseNewRelicOptions = {
7
7
  includeResolverArgs?: boolean | RegExp;
8
8
  rootFieldsNaming?: boolean;
9
9
  operationNameProperty?: string;
10
+ /**
11
+ * Indicates whether or not to skip Sentry exception reporting for a given error.
12
+ * By default, this plugin skips all `EnvelopError` errors and does not report it to Sentry.
13
+ */
14
+ skipError?: (args: Error) => boolean;
10
15
  };
16
+ export declare function defaultSkipError(error: Error): boolean;
11
17
  export declare const useNewRelic: (rawOptions?: UseNewRelicOptions | undefined) => Plugin;
package/index.js CHANGED
@@ -32,7 +32,11 @@ const DEFAULT_OPTIONS = {
32
32
  includeResolverArgs: false,
33
33
  rootFieldsNaming: false,
34
34
  operationNameProperty: '',
35
+ skipError: defaultSkipError,
35
36
  };
37
+ function defaultSkipError(error) {
38
+ return error instanceof core.EnvelopError;
39
+ }
36
40
  const useNewRelic = (rawOptions) => {
37
41
  const options = {
38
42
  ...DEFAULT_OPTIONS,
@@ -101,10 +105,11 @@ const useNewRelic = (rawOptions) => {
101
105
  resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack));
102
106
  }
103
107
  return ({ result }) => {
108
+ var _a;
104
109
  if (options.includeRawResult) {
105
110
  resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result));
106
111
  }
107
- if (result instanceof Error) {
112
+ if (result instanceof Error && !((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, result))) {
108
113
  const transaction = instrumentationApi.tracer.getTransaction();
109
114
  instrumentationApi.agent.errors.add(transaction, JSON.stringify(result));
110
115
  }
@@ -157,4 +162,5 @@ function filterPropertiesByRegex(initialObject, pattern) {
157
162
  return filteredObject;
158
163
  }
159
164
 
165
+ exports.defaultSkipError = defaultSkipError;
160
166
  exports.useNewRelic = useNewRelic;
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import newRelic from 'newrelic';
2
- import { isAsyncIterable } from '@envelop/core';
2
+ import { EnvelopError, isAsyncIterable } from '@envelop/core';
3
3
  import { Kind, print } from 'graphql';
4
4
 
5
5
  const { shim: instrumentationApi } = newRelic;
@@ -26,7 +26,11 @@ const DEFAULT_OPTIONS = {
26
26
  includeResolverArgs: false,
27
27
  rootFieldsNaming: false,
28
28
  operationNameProperty: '',
29
+ skipError: defaultSkipError,
29
30
  };
31
+ function defaultSkipError(error) {
32
+ return error instanceof EnvelopError;
33
+ }
30
34
  const useNewRelic = (rawOptions) => {
31
35
  const options = {
32
36
  ...DEFAULT_OPTIONS,
@@ -95,10 +99,11 @@ const useNewRelic = (rawOptions) => {
95
99
  resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack));
96
100
  }
97
101
  return ({ result }) => {
102
+ var _a;
98
103
  if (options.includeRawResult) {
99
104
  resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result));
100
105
  }
101
- if (result instanceof Error) {
106
+ if (result instanceof Error && !((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, result))) {
102
107
  const transaction = instrumentationApi.tracer.getTransaction();
103
108
  instrumentationApi.agent.errors.add(transaction, JSON.stringify(result));
104
109
  }
@@ -151,4 +156,4 @@ function filterPropertiesByRegex(initialObject, pattern) {
151
156
  return filteredObject;
152
157
  }
153
158
 
154
- export { useNewRelic };
159
+ export { defaultSkipError, useNewRelic };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/newrelic",
3
- "version": "1.2.1",
3
+ "version": "1.3.1-alpha-33ac2d1.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^1.6.1",
6
+ "@envelop/core": "1.6.6-alpha-33ac2d1.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
8
8
  "newrelic": "^7 || ^8.0.0"
9
9
  },
@@ -28,6 +28,7 @@
28
28
  "./*": {
29
29
  "require": "./*.js",
30
30
  "import": "./*.mjs"
31
- }
31
+ },
32
+ "./package.json": "./package.json"
32
33
  }
33
34
  }