Skip to content

Commit 397aacd

Browse files
isaacsclaude
andcommitted
fix(astro): Re-export the new portable Node exports, and add export tests
Node now exports `moduleMetadataIntegration`, `instrumentPostgresJsSql`, `instrumentCreateReactAgent` and `awsIntegration`. `@sentry/astro` lists Node's exports by name in its server entry, because it cannot use `export *` there, so these four names were missing at runtime. Its types entry does re-export all of Node, so TypeScript accepted imports that then failed when the server bundle loaded. The consistent exports E2E check would also have failed. The server entry now re-exports them. New integration tests use `parameterize` from the public entry of Deno and Cloudflare, the two runtimes that did not export it before, and check that the event carries the message template and its values. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent bb90222 commit 397aacd

5 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/cloudflare';
2+
3+
interface Env {
4+
SENTRY_DSN: string;
5+
}
6+
7+
export default Sentry.withSentry(
8+
(env: Env) => ({
9+
dsn: env.SENTRY_DSN,
10+
}),
11+
{
12+
async fetch(_request, _env, _ctx) {
13+
const userId = 42;
14+
Sentry.captureMessage(Sentry.parameterize`User ${userId} logged in`);
15+
return new Response('ok');
16+
},
17+
},
18+
);
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "worker-name",
3+
"compatibility_date": "2025-06-17",
4+
"main": "index.ts",
5+
"compatibility_flags": ["nodejs_compat"],
6+
}
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,

0 commit comments

Comments
 (0)