@envelop/newrelic 3.2.0 → 3.2.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/README.md CHANGED
@@ -44,6 +44,7 @@ const getEnveloped = envelop({
44
44
  trackResolvers: true, // default `false`. When set to `true`, track resolvers as segments to monitor their performance
45
45
  includeResolverArgs: false, // default `false`. When set to `true`, includes all the arguments passed to resolvers with their values
46
46
  rootFieldsNaming: true, // default `false`. When set to `true` append the names of operation root fields to the transaction name
47
+ skipError: error => { ... return true; }, // a function that allows you to skip reporting a given error to NewRelic. By default custom `EnvelopError`s will be skipped
47
48
  operationNameProperty: 'id', // default empty. When passed will check for the property name passed, within the document object. Will eventually use its value as operation name. Useful for custom document properties (e.g. queryId/hash)
48
49
  }),
49
50
  ],
@@ -62,9 +63,9 @@ Below is a quick example of how you can use RegEx to set up white/black listing
62
63
 
63
64
  ```ts
64
65
  useNewRelic({
65
- includeExecuteVariables: /^(client.*|application.*)$.*$/i, // whitelist, track only variables whose name starts with client or application (e.g. clientName, applicationId)
66
+ includeExecuteVariables: /client|application/i, // whitelist, track only variables whose name contains "client" or "application" (e.g. clientName, applicationId, xApplicationId)
66
67
  trackResolvers: true, // track resolvers, since we also want to track resolvers' arguments
67
- includeResolverArgs: /^(?!(name|email|password)$).*$/, // blacklist, track all arguments whose name does not match 'name', 'email' nor 'password'
68
+ includeResolverArgs: /^(?!name|email|password).*/i, // blacklist, track all arguments whose name does not match 'name', 'email' nor 'password'
68
69
  }),
69
70
  ```
70
71
 
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from '@envelop/core';
2
+ import { GraphQLError } from 'graphql';
2
3
  export declare type UseNewRelicOptions = {
3
4
  includeOperationDocument?: boolean;
4
5
  includeExecuteVariables?: boolean | RegExp;
@@ -8,10 +9,10 @@ export declare type UseNewRelicOptions = {
8
9
  rootFieldsNaming?: boolean;
9
10
  operationNameProperty?: string;
10
11
  /**
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.
12
+ * Indicates whether or not to skip reporting a given error to NewRelic.
13
+ * By default, this plugin skips all `EnvelopError` errors and does not report them to NewRelic.
13
14
  */
14
- skipError?: (args: Error) => boolean;
15
+ skipError?: (error: GraphQLError) => boolean;
15
16
  };
16
- export declare function defaultSkipError(error: Error): boolean;
17
+ export declare function defaultSkipError(error: GraphQLError): boolean;
17
18
  export declare const useNewRelic: (rawOptions?: UseNewRelicOptions | undefined) => Plugin;
package/index.js CHANGED
@@ -50,7 +50,7 @@ const DEFAULT_OPTIONS = {
50
50
  skipError: defaultSkipError,
51
51
  };
52
52
  function defaultSkipError(error) {
53
- return error instanceof core.EnvelopError;
53
+ return error.originalError instanceof core.EnvelopError;
54
54
  }
55
55
  const useNewRelic = (rawOptions) => {
56
56
  const options = {
@@ -128,14 +128,9 @@ const useNewRelic = (rawOptions) => {
128
128
  resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack));
129
129
  }
130
130
  return ({ result }) => {
131
- var _a;
132
131
  if (options.includeRawResult) {
133
132
  resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result));
134
133
  }
135
- if (result instanceof Error && !((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, result))) {
136
- const transaction = instrumentationApi.tracer.getTransaction();
137
- instrumentationApi.agent.errors.add(transaction, JSON.stringify(result));
138
- }
139
134
  resolverSegment.end();
140
135
  };
141
136
  }
@@ -144,6 +139,7 @@ const useNewRelic = (rawOptions) => {
144
139
  onResolverCalled,
145
140
  onExecuteDone({ result }) {
146
141
  const sendResult = (singularResult) => {
142
+ var _a;
147
143
  if (singularResult.data && options.includeRawResult) {
148
144
  spanContext.addCustomAttribute(AttributeName.EXECUTION_RESULT, JSON.stringify(singularResult));
149
145
  }
@@ -151,6 +147,8 @@ const useNewRelic = (rawOptions) => {
151
147
  const agent = instrumentationApi.agent;
152
148
  const transaction = instrumentationApi.tracer.getTransaction();
153
149
  for (const error of singularResult.errors) {
150
+ if ((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, error))
151
+ continue;
154
152
  agent.errors.add(transaction, JSON.stringify(error));
155
153
  }
156
154
  }
package/index.mjs CHANGED
@@ -27,7 +27,7 @@ const DEFAULT_OPTIONS = {
27
27
  skipError: defaultSkipError,
28
28
  };
29
29
  function defaultSkipError(error) {
30
- return error instanceof EnvelopError;
30
+ return error.originalError instanceof EnvelopError;
31
31
  }
32
32
  const useNewRelic = (rawOptions) => {
33
33
  const options = {
@@ -105,14 +105,9 @@ const useNewRelic = (rawOptions) => {
105
105
  resolverSegment.addAttribute(AttributeName.RESOLVER_ARGS, JSON.stringify(resolverArgsToTrack));
106
106
  }
107
107
  return ({ result }) => {
108
- var _a;
109
108
  if (options.includeRawResult) {
110
109
  resolverSegment.addAttribute(AttributeName.RESOLVER_RESULT, JSON.stringify(result));
111
110
  }
112
- if (result instanceof Error && !((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, result))) {
113
- const transaction = instrumentationApi.tracer.getTransaction();
114
- instrumentationApi.agent.errors.add(transaction, JSON.stringify(result));
115
- }
116
111
  resolverSegment.end();
117
112
  };
118
113
  }
@@ -121,6 +116,7 @@ const useNewRelic = (rawOptions) => {
121
116
  onResolverCalled,
122
117
  onExecuteDone({ result }) {
123
118
  const sendResult = (singularResult) => {
119
+ var _a;
124
120
  if (singularResult.data && options.includeRawResult) {
125
121
  spanContext.addCustomAttribute(AttributeName.EXECUTION_RESULT, JSON.stringify(singularResult));
126
122
  }
@@ -128,6 +124,8 @@ const useNewRelic = (rawOptions) => {
128
124
  const agent = instrumentationApi.agent;
129
125
  const transaction = instrumentationApi.tracer.getTransaction();
130
126
  for (const error of singularResult.errors) {
127
+ if ((_a = options.skipError) === null || _a === void 0 ? void 0 : _a.call(options, error))
128
+ continue;
131
129
  agent.errors.add(transaction, JSON.stringify(error));
132
130
  }
133
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/newrelic",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@envelop/core": "^2.1.0",