@envelop/sentry 7.1.1 → 8.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/sentry",
3
- "version": "7.1.1",
3
+ "version": "8.0.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@envelop/core": "^5.0.0",
@@ -1,8 +1,7 @@
1
- import { ExecutionArgs } from 'graphql';
2
- import { isOriginalGraphQLError, type Plugin } from '@envelop/core';
1
+ import { isOriginalGraphQLError, TypedExecutionArgs, type Plugin } from '@envelop/core';
3
2
  import * as Sentry from '@sentry/node';
4
3
  import type { TraceparentData } from '@sentry/types';
5
- export type SentryPluginOptions = {
4
+ export type SentryPluginOptions<PluginContext extends Record<string, any>> = {
6
5
  /**
7
6
  * Starts a new transaction for every GraphQL Operation.
8
7
  * When disabled, an already existing Transaction will be used.
@@ -38,34 +37,34 @@ export type SentryPluginOptions = {
38
37
  /**
39
38
  * Adds custom tags to every Transaction.
40
39
  */
41
- appendTags?: (args: ExecutionArgs) => Record<string, unknown>;
40
+ appendTags?: (args: TypedExecutionArgs<PluginContext>) => Record<string, unknown>;
42
41
  /**
43
42
  * Callback to set context information onto the scope.
44
43
  */
45
- configureScope?: (args: ExecutionArgs, scope: Sentry.Scope) => void;
44
+ configureScope?: (args: TypedExecutionArgs<PluginContext>, scope: Sentry.Scope) => void;
46
45
  /**
47
46
  * Produces a name of Transaction (only when "renameTransaction" or "startTransaction" are enabled) and description of created Span.
48
47
  *
49
48
  * @default operation's name or "Anonymous Operation" when missing)
50
49
  */
51
- transactionName?: (args: ExecutionArgs) => string;
50
+ transactionName?: (args: TypedExecutionArgs<PluginContext>) => string;
52
51
  /**
53
52
  * Produces tracing data for Transaction
54
53
  *
55
54
  * @default is empty
56
55
  */
57
- traceparentData?: (args: ExecutionArgs) => TraceparentData | undefined;
56
+ traceparentData?: (args: TypedExecutionArgs<PluginContext>) => TraceparentData | undefined;
58
57
  /**
59
58
  * Produces a "op" (operation) of created Span.
60
59
  *
61
60
  * @default execute
62
61
  */
63
- operationName?: (args: ExecutionArgs) => string;
62
+ operationName?: (args: TypedExecutionArgs<PluginContext>) => string;
64
63
  /**
65
64
  * Indicates whether or not to skip the entire Sentry flow for given GraphQL operation.
66
65
  * By default, no operations are skipped.
67
66
  */
68
- skip?: (args: ExecutionArgs) => boolean;
67
+ skip?: (args: TypedExecutionArgs<PluginContext>) => boolean;
69
68
  /**
70
69
  * Indicates whether or not to skip Sentry exception reporting for a given error.
71
70
  * By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.
@@ -73,4 +72,4 @@ export type SentryPluginOptions = {
73
72
  skipError?: (args: Error) => boolean;
74
73
  };
75
74
  export declare const defaultSkipError: typeof isOriginalGraphQLError;
76
- export declare const useSentry: (options?: SentryPluginOptions) => Plugin;
75
+ export declare const useSentry: <PluginContext extends Record<string, any> = {}>(options?: SentryPluginOptions<PluginContext>) => Plugin<PluginContext>;
@@ -1,8 +1,7 @@
1
- import { ExecutionArgs } from 'graphql';
2
- import { isOriginalGraphQLError, type Plugin } from '@envelop/core';
1
+ import { isOriginalGraphQLError, TypedExecutionArgs, type Plugin } from '@envelop/core';
3
2
  import * as Sentry from '@sentry/node';
4
3
  import type { TraceparentData } from '@sentry/types';
5
- export type SentryPluginOptions = {
4
+ export type SentryPluginOptions<PluginContext extends Record<string, any>> = {
6
5
  /**
7
6
  * Starts a new transaction for every GraphQL Operation.
8
7
  * When disabled, an already existing Transaction will be used.
@@ -38,34 +37,34 @@ export type SentryPluginOptions = {
38
37
  /**
39
38
  * Adds custom tags to every Transaction.
40
39
  */
41
- appendTags?: (args: ExecutionArgs) => Record<string, unknown>;
40
+ appendTags?: (args: TypedExecutionArgs<PluginContext>) => Record<string, unknown>;
42
41
  /**
43
42
  * Callback to set context information onto the scope.
44
43
  */
45
- configureScope?: (args: ExecutionArgs, scope: Sentry.Scope) => void;
44
+ configureScope?: (args: TypedExecutionArgs<PluginContext>, scope: Sentry.Scope) => void;
46
45
  /**
47
46
  * Produces a name of Transaction (only when "renameTransaction" or "startTransaction" are enabled) and description of created Span.
48
47
  *
49
48
  * @default operation's name or "Anonymous Operation" when missing)
50
49
  */
51
- transactionName?: (args: ExecutionArgs) => string;
50
+ transactionName?: (args: TypedExecutionArgs<PluginContext>) => string;
52
51
  /**
53
52
  * Produces tracing data for Transaction
54
53
  *
55
54
  * @default is empty
56
55
  */
57
- traceparentData?: (args: ExecutionArgs) => TraceparentData | undefined;
56
+ traceparentData?: (args: TypedExecutionArgs<PluginContext>) => TraceparentData | undefined;
58
57
  /**
59
58
  * Produces a "op" (operation) of created Span.
60
59
  *
61
60
  * @default execute
62
61
  */
63
- operationName?: (args: ExecutionArgs) => string;
62
+ operationName?: (args: TypedExecutionArgs<PluginContext>) => string;
64
63
  /**
65
64
  * Indicates whether or not to skip the entire Sentry flow for given GraphQL operation.
66
65
  * By default, no operations are skipped.
67
66
  */
68
- skip?: (args: ExecutionArgs) => boolean;
67
+ skip?: (args: TypedExecutionArgs<PluginContext>) => boolean;
69
68
  /**
70
69
  * Indicates whether or not to skip Sentry exception reporting for a given error.
71
70
  * By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.
@@ -73,4 +72,4 @@ export type SentryPluginOptions = {
73
72
  skipError?: (args: Error) => boolean;
74
73
  };
75
74
  export declare const defaultSkipError: typeof isOriginalGraphQLError;
76
- export declare const useSentry: (options?: SentryPluginOptions) => Plugin;
75
+ export declare const useSentry: <PluginContext extends Record<string, any> = {}>(options?: SentryPluginOptions<PluginContext>) => Plugin<PluginContext>;