@sentry/node 9.39.0 → 9.41.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.
Files changed (68) hide show
  1. package/build/cjs/index.js +9 -7
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/tracing/express-v5/utils.js +1 -1
  4. package/build/cjs/integrations/tracing/express-v5/utils.js.map +1 -1
  5. package/build/cjs/integrations/tracing/express.js +1 -1
  6. package/build/cjs/integrations/tracing/express.js.map +1 -1
  7. package/build/cjs/integrations/tracing/fastify/index.js +58 -12
  8. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing/hapi/index.js +1 -1
  10. package/build/cjs/integrations/tracing/hapi/index.js.map +1 -1
  11. package/build/cjs/integrations/tracing/index.js +3 -0
  12. package/build/cjs/integrations/tracing/index.js.map +1 -1
  13. package/build/cjs/integrations/tracing/koa.js +1 -1
  14. package/build/cjs/integrations/tracing/koa.js.map +1 -1
  15. package/build/cjs/integrations/tracing/openai/index.js +79 -0
  16. package/build/cjs/integrations/tracing/openai/index.js.map +1 -0
  17. package/build/cjs/integrations/tracing/openai/instrumentation.js +81 -0
  18. package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -0
  19. package/build/cjs/integrations/tracing/postgresjs.js +1 -1
  20. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  21. package/build/cjs/integrations/tracing/vercelai/instrumentation.js +15 -2
  22. package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  23. package/build/cjs/sdk/initOtel.js +5 -5
  24. package/build/cjs/sdk/initOtel.js.map +1 -1
  25. package/build/cjs/utils/redisCache.js +2 -2
  26. package/build/cjs/utils/redisCache.js.map +1 -1
  27. package/build/esm/index.js +1 -0
  28. package/build/esm/index.js.map +1 -1
  29. package/build/esm/integrations/tracing/express-v5/utils.js +1 -1
  30. package/build/esm/integrations/tracing/express-v5/utils.js.map +1 -1
  31. package/build/esm/integrations/tracing/express.js +2 -2
  32. package/build/esm/integrations/tracing/express.js.map +1 -1
  33. package/build/esm/integrations/tracing/fastify/index.js +59 -13
  34. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  35. package/build/esm/integrations/tracing/hapi/index.js +2 -2
  36. package/build/esm/integrations/tracing/hapi/index.js.map +1 -1
  37. package/build/esm/integrations/tracing/index.js +3 -0
  38. package/build/esm/integrations/tracing/index.js.map +1 -1
  39. package/build/esm/integrations/tracing/koa.js +2 -2
  40. package/build/esm/integrations/tracing/koa.js.map +1 -1
  41. package/build/esm/integrations/tracing/openai/index.js +76 -0
  42. package/build/esm/integrations/tracing/openai/index.js.map +1 -0
  43. package/build/esm/integrations/tracing/openai/instrumentation.js +79 -0
  44. package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -0
  45. package/build/esm/integrations/tracing/postgresjs.js +2 -2
  46. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  47. package/build/esm/integrations/tracing/vercelai/instrumentation.js +16 -3
  48. package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  49. package/build/esm/package.json +1 -1
  50. package/build/esm/sdk/initOtel.js +9 -9
  51. package/build/esm/sdk/initOtel.js.map +1 -1
  52. package/build/esm/utils/redisCache.js +2 -2
  53. package/build/esm/utils/redisCache.js.map +1 -1
  54. package/build/types/index.d.ts +1 -0
  55. package/build/types/index.d.ts.map +1 -1
  56. package/build/types/integrations/tracing/fastify/index.d.ts +38 -2
  57. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -1
  58. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  59. package/build/types/integrations/tracing/openai/index.d.ts +60 -0
  60. package/build/types/integrations/tracing/openai/index.d.ts.map +1 -0
  61. package/build/types/integrations/tracing/openai/instrumentation.d.ts +20 -0
  62. package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -0
  63. package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -1
  64. package/build/types-ts3.8/index.d.ts +1 -0
  65. package/build/types-ts3.8/integrations/tracing/fastify/index.d.ts +38 -2
  66. package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +60 -0
  67. package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +20 -0
  68. package/package.json +4 -4
@@ -1,6 +1,40 @@
1
1
  import { Instrumentation, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
2
  import { FastifyInstance, FastifyReply, FastifyRequest } from './types';
3
3
  import { FastifyInstrumentationV3 } from './v3/instrumentation';
4
+ /**
5
+ * Options for the Fastify integration.
6
+ *
7
+ * `shouldHandleError` - Callback method deciding whether error should be captured and sent to Sentry
8
+ * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
9
+ * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
10
+ *
11
+ * @example
12
+ *
13
+ * ```javascript
14
+ * Sentry.init({
15
+ * integrations: [
16
+ * Sentry.fastifyIntegration({
17
+ * shouldHandleError(_error, _request, reply) {
18
+ * return reply.statusCode >= 500;
19
+ * },
20
+ * });
21
+ * },
22
+ * });
23
+ * ```
24
+ *
25
+ */
26
+ interface FastifyIntegrationOptions {
27
+ /**
28
+ * Callback method deciding whether error should be captured and sent to Sentry
29
+ * This is used on Fastify v5 where Sentry handles errors in the diagnostics channel.
30
+ * Fastify v3 and v4 use `setupFastifyErrorHandler` instead.
31
+ *
32
+ * @param error Captured Fastify error
33
+ * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)
34
+ * @param reply Fastify reply (or any object containing at least statusCode)
35
+ */
36
+ shouldHandleError: (error: Error, request: FastifyRequest, reply: FastifyReply) => boolean;
37
+ }
4
38
  interface FastifyHandlerOptions {
5
39
  /**
6
40
  * Callback method deciding whether error should be captured and sent to Sentry
@@ -11,6 +45,7 @@ interface FastifyHandlerOptions {
11
45
  *
12
46
  * @example
13
47
  *
48
+ *
14
49
  * ```javascript
15
50
  * setupFastifyErrorHandler(app, {
16
51
  * shouldHandleError(_error, _request, reply) {
@@ -19,6 +54,7 @@ interface FastifyHandlerOptions {
19
54
  * });
20
55
  * ```
21
56
  *
57
+ *
22
58
  * If using TypeScript, you can cast the request and reply to get full type safety.
23
59
  *
24
60
  * ```typescript
@@ -38,7 +74,7 @@ interface FastifyHandlerOptions {
38
74
  export declare const instrumentFastifyV3: ((options?: unknown) => FastifyInstrumentationV3) & {
39
75
  id: string;
40
76
  };
41
- export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyHandlerOptions>) & {
77
+ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<InstrumentationConfig & FastifyIntegrationOptions>) & {
42
78
  id: string;
43
79
  };
44
80
  /**
@@ -57,7 +93,7 @@ export declare const instrumentFastify: ((options?: unknown) => Instrumentation<
57
93
  * })
58
94
  * ```
59
95
  */
60
- export declare const fastifyIntegration: () => import("@sentry/core").Integration;
96
+ export declare const fastifyIntegration: (options?: Partial<FastifyIntegrationOptions> | undefined) => import("@sentry/core").Integration;
61
97
  /**
62
98
  * Add an Fastify error handler to capture errors to Sentry.
63
99
  *
@@ -0,0 +1,60 @@
1
+ import { OpenAiOptions } from '@sentry/core';
2
+ import { SentryOpenAiInstrumentation } from './instrumentation';
3
+ export declare const instrumentOpenAi: ((options?: unknown) => SentryOpenAiInstrumentation) & {
4
+ id: string;
5
+ };
6
+ /**
7
+ * Adds Sentry tracing instrumentation for the OpenAI SDK.
8
+ *
9
+ * This integration is enabled by default.
10
+ *
11
+ * When configured, this integration automatically instruments OpenAI SDK client instances
12
+ * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.
13
+ *
14
+ * @example
15
+ * ```javascript
16
+ * import * as Sentry from '@sentry/node';
17
+ *
18
+ * Sentry.init({
19
+ * integrations: [Sentry.openAIIntegration()],
20
+ * });
21
+ * ```
22
+ *
23
+ * ## Options
24
+ *
25
+ * - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)
26
+ * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
27
+ *
28
+ * ### Default Behavior
29
+ *
30
+ * By default, the integration will:
31
+ * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
32
+ * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * // Record inputs and outputs when sendDefaultPii is false
37
+ * Sentry.init({
38
+ * integrations: [
39
+ * Sentry.openAIIntegration({
40
+ * recordInputs: true,
41
+ * recordOutputs: true
42
+ * })
43
+ * ],
44
+ * });
45
+ *
46
+ * // Never record inputs/outputs regardless of sendDefaultPii
47
+ * Sentry.init({
48
+ * sendDefaultPii: true,
49
+ * integrations: [
50
+ * Sentry.openAIIntegration({
51
+ * recordInputs: false,
52
+ * recordOutputs: false
53
+ * })
54
+ * ],
55
+ * });
56
+ * ```
57
+ *
58
+ */
59
+ export declare const openAIIntegration: (options?: OpenAiOptions | undefined) => import("@sentry/core").Integration;
60
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { InstrumentationConfig, InstrumentationModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';
2
+ import { Integration, OpenAiOptions } from '@sentry/core';
3
+ export interface OpenAiIntegration extends Integration {
4
+ options: OpenAiOptions;
5
+ }
6
+ /**
7
+ * Sentry OpenAI instrumentation using OpenTelemetry.
8
+ */
9
+ export declare class SentryOpenAiInstrumentation extends InstrumentationBase<InstrumentationConfig> {
10
+ constructor(config?: InstrumentationConfig);
11
+ /**
12
+ * Initializes the instrumentation by defining the modules to be patched.
13
+ */
14
+ init(): InstrumentationModuleDefinition;
15
+ /**
16
+ * Core patch logic applying instrumentation to the OpenAI client constructor.
17
+ */
18
+ private _patch;
19
+ }
20
+ //# sourceMappingURL=instrumentation.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "9.39.0",
3
+ "version": "9.41.0",
4
4
  "description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
@@ -95,9 +95,9 @@
95
95
  "@opentelemetry/sdk-trace-base": "^1.30.1",
96
96
  "@opentelemetry/semantic-conventions": "^1.34.0",
97
97
  "@prisma/instrumentation": "6.11.1",
98
- "@sentry/core": "9.39.0",
99
- "@sentry/node-core": "9.39.0",
100
- "@sentry/opentelemetry": "9.39.0",
98
+ "@sentry/core": "9.41.0",
99
+ "@sentry/node-core": "9.41.0",
100
+ "@sentry/opentelemetry": "9.41.0",
101
101
  "import-in-the-middle": "^1.14.2",
102
102
  "minimatch": "^9.0.0"
103
103
  },