Skip to content

Commit bd2b387

Browse files
isaacsclaude
andauthored
feat(node, bun, deno, cloudflare): Align portable exports across server SDKs (#25583)
The server SDKs export different sets of helpers from `@sentry/core` and `@sentry/server-utils`, although the helpers work on each runtime. A user who moves between runtimes, or follows docs written for another one, finds a helper missing. Two of the gaps also hide default integrations: Node and Bun add `awsIntegration` to their defaults, and Deno adds `fastifyIntegration`, but they did not export them. A user who sets `defaultIntegrations` could not add them back. - Node and Bun now export `moduleMetadataIntegration`, `instrumentPostgresJsSql`, `instrumentCreateReactAgent`, `awsIntegration` and the `FlueOptions` type. `@sentry/aws-serverless` and `@sentry/google-cloud-serverless` re-export the new Node values, as the consistent exports check requires. - Deno and Cloudflare now export `parameterize` and `instrumentStateGraphCompile`, so all four runtimes export the same LangGraph helpers. - Bun and Cloudflare now export the `Log` and `LogSeverityLevel` types. - Deno now exports `fastifyIntegration`. Cloudflare's channel integrations (express, pg and so on) are separate work, because they need a warning when the vite plugin is missing. Fixes #25574 Fixes JS-3972 --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 7dfffba commit bd2b387

15 files changed

Lines changed: 117 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ Work in this release was contributed by @faizansaiyed123, @itisrmk, @kunal649, @
1414

1515
`ignoreStaticAssets` defaults to `true`, so workers no longer create spans for `GET` requests to common static assets such as `favicon.ico`, `robots.txt` or `*.js` files. To keep these spans, set `httpServerIntegration({ ignoreStaticAssets: false })`. Request spans also follow the client's tracing configuration by default, so the SDK does not start them when tracing is disabled. If `ignoreRequestBody` throws, the request no longer fails, and the SDK skips the body.
1616

17+
- **feat(node, bun, deno, cloudflare): Align portable exports across server SDKs**
18+
19+
Node, Bun, Deno and Cloudflare now export the same helpers from `@sentry/core` and `@sentry/server-utils` where they work on that runtime:
20+
21+
- Node and Bun now export `moduleMetadataIntegration`, `instrumentPostgresJsSql`, `instrumentCreateReactAgent`, `awsIntegration` and the `FlueOptions` type. `awsIntegration` was already in their default integrations.
22+
- Deno and Cloudflare now export `parameterize` and `instrumentStateGraphCompile`.
23+
- Bun and Cloudflare now export the `Log` and `LogSeverityLevel` types.
24+
- Deno now exports `fastifyIntegration`, which was already in its default integrations.
25+
1726
## 11.9.0
1827

1928
### Important Changes
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as Sentry from '@sentry/cloudflare';
2+
3+
interface Env {
4+
SENTRY_DSN: string;
5+
}
6+
7+
// A plain worker. The `@sentry/cloudflare/vite` plugin wraps it with `withSentry` at build time,
8+
// with the options from `instrument.server.ts`.
9+
export default {
10+
async fetch(): Promise<Response> {
11+
const userId = 42;
12+
Sentry.captureMessage(Sentry.parameterize`User ${userId} logged in`);
13+
return new Response('ok');
14+
},
15+
} satisfies ExportedHandler<Env>;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineCloudflareOptions } from '@sentry/cloudflare';
2+
3+
export default defineCloudflareOptions((env: { SENTRY_DSN: string }) => ({
4+
dsn: env.SENTRY_DSN,
5+
}));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Event } from '@sentry/core';
2+
import { expect, it } from 'vitest';
3+
import { createRunner } from '../../../runner';
4+
5+
it('parameterize from the public entry sends a message template and its values', async ({ signal }) => {
6+
const runner = createRunner(__dirname)
7+
.expect(envelope => {
8+
const event = envelope[1]?.[0]?.[1] as Event;
9+
expect(event.logentry).toEqual({ message: 'User %s logged in', params: [42] });
10+
})
11+
.start(signal);
12+
13+
await runner.makeRequest('get', '/');
14+
await runner.completed();
15+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { cloudflare } from '@cloudflare/vite-plugin';
2+
import { sentryCloudflareVitePlugin } from '@sentry/cloudflare/vite';
3+
import { defineConfig } from 'vite';
4+
5+
export default defineConfig({
6+
plugins: [cloudflare(), sentryCloudflareVitePlugin()],
7+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "../../../node_modules/wrangler/config-schema.json",
3+
"name": "cloudflare-public-api-parameterize",
4+
// `main` points at the source entry. The Sentry Vite plugin builds from it, and the runner serves
5+
// the built output.
6+
"main": "index.ts",
7+
"compatibility_date": "2025-06-17",
8+
"compatibility_flags": ["nodejs_compat"],
9+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// <reference lib="deno.ns" />
2+
3+
import * as Sentry from '@sentry/deno';
4+
import { assertEquals } from 'https://deno.land/std@0.212.0/assert/assert_equals.ts';
5+
import { errorSink, resetGlobals, withTimeout } from '../../src/index.ts';
6+
7+
Deno.test('parameterize from the public entry sends a message template and its values', async () => {
8+
resetGlobals();
9+
const sink = errorSink();
10+
11+
Sentry.init({
12+
dsn: 'https://username@domain/123',
13+
beforeSend: sink.beforeSend,
14+
});
15+
16+
const userId = 42;
17+
Sentry.captureMessage(Sentry.parameterize`User ${userId} logged in`);
18+
19+
const event = await withTimeout(
20+
sink.waitFor(e => e.logentry?.message === 'User %s logged in'),
21+
5_000,
22+
'parameterized message event',
23+
);
24+
assertEquals(event.logentry, { message: 'User %s logged in', params: [42] });
25+
});

‎packages/astro/src/index.server.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
addIntegration,
1414
amqplibIntegration,
1515
anthropicAIIntegration,
16+
awsIntegration,
1617
// eslint-disable-next-line typescript/no-deprecated
1718
anrIntegration,
1819
googleGenAIIntegration,
@@ -102,6 +103,7 @@ export {
102103
langChainIntegration,
103104
langGraphIntegration,
104105
createFlueInstrumentation,
106+
instrumentPostgresJsSql,
105107
mastraIntegration,
106108
piDurableIntegration,
107109
mcpServerIntegration,
@@ -177,6 +179,8 @@ export {
177179
instrumentLangChainEmbeddings,
178180
instrumentStateGraph,
179181
instrumentStateGraphCompile,
182+
instrumentCreateReactAgent,
183+
moduleMetadataIntegration,
180184
zodErrorsIntegration,
181185
profiler,
182186
logger,

‎packages/aws-serverless/src/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export {
22
addEventProcessor,
33
addBreadcrumb,
44
addIntegration,
5+
moduleMetadataIntegration,
56
captureException,
67
captureEvent,
78
captureMessage,
@@ -71,6 +72,7 @@ export {
7172
mcpServerIntegration,
7273
SentryMastraExporter,
7374
createFlueInstrumentation,
75+
instrumentPostgresJsSql,
7476
modulesIntegration,
7577
nodeRuntimeMetricsIntegration,
7678
type NodeRuntimeMetricsOptions,
@@ -159,6 +161,7 @@ export {
159161
instrumentGoogleGenAIClient,
160162
instrumentStateGraph,
161163
instrumentStateGraphCompile,
164+
instrumentCreateReactAgent,
162165
zodErrorsIntegration,
163166
profiler,
164167
amqplibIntegration,

‎packages/bun/src/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type {
1010
Exception,
1111
Session,
1212
SeverityLevel,
13+
Log,
14+
LogSeverityLevel,
1315
Span,
1416
StackFrame,
1517
Stacktrace,
@@ -25,6 +27,7 @@ export {
2527
addEventProcessor,
2628
addBreadcrumb,
2729
addIntegration,
30+
moduleMetadataIntegration,
2831
captureException,
2932
captureEvent,
3033
captureMessage,
@@ -93,6 +96,7 @@ export {
9396
mcpServerIntegration,
9497
SentryMastraExporter,
9598
createFlueInstrumentation,
99+
instrumentPostgresJsSql,
96100
modulesIntegration,
97101
contextLinesIntegration,
98102
nodeContextIntegration,
@@ -176,6 +180,8 @@ export {
176180
instrumentGoogleGenAIClient,
177181
instrumentStateGraph,
178182
instrumentStateGraphCompile,
183+
instrumentCreateReactAgent,
184+
awsIntegration,
179185
zodErrorsIntegration,
180186
profiler,
181187
amqplibIntegration,

0 commit comments

Comments
 (0)