Skip to content

Commit cc7db73

Browse files
authored
fix(astro): Ensure server-side exports work correctly (#12453)
Fix a server-side re-export problem of `@sentry/node` exports in the Astro SDK. It seems that the `export * from '@sentry/node'` "overruled" the explicit exports. So this patch changes our export statements to: - only export explicit, named exports in the JS server side entry point - continue exporting all types via the `*` export in the types entry point fixes #12410
1 parent 1014da2 commit cc7db73

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

packages/astro/src/index.server.ts

+27-3
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,35 @@ export {
9292
setupHapiErrorHandler,
9393
spotlightIntegration,
9494
addOpenTelemetryInstrumentation,
95+
metrics,
96+
NodeClient,
97+
addIntegration,
98+
anrIntegration,
99+
captureConsoleIntegration,
100+
captureSession,
101+
connectIntegration,
102+
createGetModuleFromFilename,
103+
debugIntegration,
104+
dedupeIntegration,
105+
endSession,
106+
extraErrorDataIntegration,
107+
getAutoPerformanceIntegrations,
108+
httpIntegration,
109+
initOpenTelemetry,
110+
koaIntegration,
111+
nativeNodeFetchIntegration,
112+
rewriteFramesIntegration,
113+
sessionTimingIntegration,
114+
setupConnectErrorHandler,
115+
setupKoaErrorHandler,
116+
spanToBaggageHeader,
117+
spanToJSON,
118+
spanToTraceHeader,
119+
startSession,
120+
trpcMiddleware,
121+
zodErrorsIntegration,
95122
} from '@sentry/node';
96123

97-
// We can still leave this for the carrier init and type exports
98-
export * from '@sentry/node';
99-
100124
export { init } from './server/sdk';
101125

102126
export default sentryAstro;

packages/astro/src/index.types.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// exports in this file - which we do below.
44
export * from './index.client';
55
export * from './index.server';
6+
export * from '@sentry/node';
7+
8+
import type { NodeOptions } from '@sentry/node';
69

710
import type { Integration, Options, StackParser } from '@sentry/types';
811

@@ -11,7 +14,7 @@ import type * as serverSdk from './index.server';
1114
import sentryAstro from './index.server';
1215

1316
/** Initializes Sentry Astro SDK */
14-
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
17+
export declare function init(options: Options | clientSdk.BrowserOptions | NodeOptions): void;
1518

1619
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
1720
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
@@ -29,5 +32,5 @@ export declare const continueTrace: typeof clientSdk.continueTrace;
2932

3033
export declare const Span: clientSdk.Span;
3134

32-
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;
35+
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk;
3336
export default sentryAstro;

packages/astro/src/server/sdk.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function init(options: NodeOptions): void {
1010
const opts = {
1111
...options,
1212
};
13+
1314
applySdkMetadata(opts, 'astro', ['astro', 'node']);
1415

1516
initNodeSdk(opts);

0 commit comments

Comments
 (0)