Skip to content

Commit 7b7341e

Browse files
committed
feat(core): Consolidate bun and node types with BaseWinterTCOptions
1 parent 29ed4da commit 7b7341e

File tree

5 files changed

+81
-139
lines changed

5 files changed

+81
-139
lines changed

packages/bun/src/types.ts

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,11 @@
1-
import type { BaseTransportOptions, ClientOptions, Options, TracePropagationTargets } from '@sentry/core';
1+
import type { BaseTransportOptions, BaseWinterTCOptions, ClientOptions, Options } from '@sentry/core';
22

3-
export interface BaseBunOptions {
4-
/**
5-
* List of strings/regex controlling to which outgoing requests
6-
* the SDK will attach tracing headers.
7-
*
8-
* By default the SDK will attach those headers to all outgoing
9-
* requests. If this option is provided, the SDK will match the
10-
* request URL of outgoing requests against the items in this
11-
* array, and only attach tracing headers if a match was found.
12-
*
13-
* @example
14-
* ```js
15-
* Sentry.init({
16-
* tracePropagationTargets: ['api.site.com'],
17-
* });
18-
* ```
19-
*/
20-
tracePropagationTargets?: TracePropagationTargets;
21-
22-
/** Sets an optional server name (device name) */
23-
serverName?: string;
24-
25-
/**
26-
* If you use Spotlight by Sentry during development, use
27-
* this option to forward captured Sentry events to Spotlight.
28-
*
29-
* Either set it to true, or provide a specific Spotlight Sidecar URL.
30-
*
31-
* More details: https://spotlightjs.com/
32-
*
33-
* IMPORTANT: Only set this option to `true` while developing, not in production!
34-
*/
35-
spotlight?: boolean | string;
36-
37-
/**
38-
* If this is set to true, the SDK will not set up OpenTelemetry automatically.
39-
* In this case, you _have_ to ensure to set it up correctly yourself, including:
40-
* * The `SentrySpanProcessor`
41-
* * The `SentryPropagator`
42-
* * The `SentryContextManager`
43-
* * The `SentrySampler`
44-
*
45-
* If you are registering your own OpenTelemetry Loader Hooks (or `import-in-the-middle` hooks), it is also recommended to set the `registerEsmLoaderHooks` option to false.
46-
*/
47-
skipOpenTelemetrySetup?: boolean;
48-
49-
/** Callback that is executed when a fatal global error occurs. */
50-
onFatalError?(this: void, error: Error): void;
51-
}
3+
/**
4+
* Base options for the Sentry Bun SDK.
5+
* Extends the common WinterTC options shared with Node.js and other server-side SDKs.
6+
*/
7+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
8+
export interface BaseBunOptions extends BaseWinterTCOptions {}
529

5310
/**
5411
* Configuration options for the Sentry Bun SDK

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export type { Extra, Extras } from './types-hoist/extra';
386386
export type { Integration, IntegrationFn } from './types-hoist/integration';
387387
export type { Mechanism } from './types-hoist/mechanism';
388388
export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './types-hoist/misc';
389-
export type { ClientOptions, CoreOptions as Options } from './types-hoist/options';
389+
export type { BaseWinterTCOptions, ClientOptions, CoreOptions as Options } from './types-hoist/options';
390390
export type { Package } from './types-hoist/package';
391391
export type { PolymorphicEvent, PolymorphicRequest } from './types-hoist/polymorphics';
392392
export type {

packages/core/src/types-hoist/options.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,67 @@ import type { StackLineParser, StackParser } from './stacktrace';
1111
import type { TracePropagationTargets } from './tracing';
1212
import type { BaseTransportOptions, Transport } from './transport';
1313

14+
/**
15+
* Base options for WinterTC-compatible server-side JavaScript runtimes.
16+
* This interface contains common configuration options shared between
17+
* Node.js, Bun, and other WinterTC-compliant runtime SDKs.
18+
*
19+
* @see https://wintercg.org/
20+
*/
21+
export interface BaseWinterTCOptions {
22+
/**
23+
* List of strings/regex controlling to which outgoing requests
24+
* the SDK will attach tracing headers.
25+
*
26+
* By default the SDK will attach those headers to all outgoing
27+
* requests. If this option is provided, the SDK will match the
28+
* request URL of outgoing requests against the items in this
29+
* array, and only attach tracing headers if a match was found.
30+
*
31+
* @example
32+
* ```js
33+
* Sentry.init({
34+
* tracePropagationTargets: ['api.site.com'],
35+
* });
36+
* ```
37+
*/
38+
tracePropagationTargets?: TracePropagationTargets;
39+
40+
/**
41+
* Sets an optional server name (device name).
42+
*
43+
* This is useful for identifying which server or instance is sending events.
44+
*/
45+
serverName?: string;
46+
47+
/**
48+
* If you use Spotlight by Sentry during development, use
49+
* this option to forward captured Sentry events to Spotlight.
50+
*
51+
* Either set it to true, or provide a specific Spotlight Sidecar URL.
52+
*
53+
* More details: https://spotlightjs.com/
54+
*
55+
* IMPORTANT: Only set this option to `true` while developing, not in production!
56+
*/
57+
spotlight?: boolean | string;
58+
59+
/**
60+
* If this is set to true, the SDK will not set up OpenTelemetry automatically.
61+
* In this case, you _have_ to ensure to set it up correctly yourself, including:
62+
* * The `SentrySpanProcessor`
63+
* * The `SentryPropagator`
64+
* * The `SentryContextManager`
65+
* * The `SentrySampler`
66+
*/
67+
skipOpenTelemetrySetup?: boolean;
68+
69+
/**
70+
* Callback that is executed when a fatal global error occurs.
71+
*/
72+
onFatalError?(this: void, error: Error): void;
73+
}
74+
1475
/**
1576
* A filter object for ignoring spans.
1677
* At least one of the properties (`op` or `name`) must be set.

packages/node-core/src/types.ts

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
import type { Span as WriteableSpan } from '@opentelemetry/api';
22
import type { Instrumentation } from '@opentelemetry/instrumentation';
33
import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base';
4-
import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core';
4+
import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core';
55
import type { NodeTransportOptions } from './transports';
66

7-
export interface BaseNodeOptions {
8-
/**
9-
* List of strings/regex controlling to which outgoing requests
10-
* the SDK will attach tracing headers.
11-
*
12-
* By default the SDK will attach those headers to all outgoing
13-
* requests. If this option is provided, the SDK will match the
14-
* request URL of outgoing requests against the items in this
15-
* array, and only attach tracing headers if a match was found.
16-
*
17-
* @example
18-
* ```js
19-
* Sentry.init({
20-
* tracePropagationTargets: ['api.site.com'],
21-
* });
22-
* ```
23-
*/
24-
tracePropagationTargets?: TracePropagationTargets;
25-
7+
/**
8+
* Base options for the Sentry Node SDK.
9+
* Extends the common WinterTC options shared with Bun and other server-side SDKs.
10+
*/
11+
export interface BaseNodeOptions extends BaseWinterTCOptions {
2612
/**
2713
* Sets profiling sample rate when @sentry/profiling-node is installed
2814
*
@@ -71,28 +57,13 @@ export interface BaseNodeOptions {
7157
*/
7258
includeServerName?: boolean;
7359

74-
/** Sets an optional server name (device name) */
75-
serverName?: string;
76-
7760
/**
7861
* Include local variables with stack traces.
7962
*
8063
* Requires the `LocalVariables` integration.
8164
*/
8265
includeLocalVariables?: boolean;
8366

84-
/**
85-
* If you use Spotlight by Sentry during development, use
86-
* this option to forward captured Sentry events to Spotlight.
87-
*
88-
* Either set it to true, or provide a specific Spotlight Sidecar URL.
89-
*
90-
* More details: https://spotlightjs.com/
91-
*
92-
* IMPORTANT: Only set this option to `true` while developing, not in production!
93-
*/
94-
spotlight?: boolean | string;
95-
9667
/**
9768
* Provide an array of OpenTelemetry Instrumentations that should be registered.
9869
*
@@ -144,9 +115,6 @@ export interface BaseNodeOptions {
144115
* problems.
145116
*/
146117
shutdownTimeout?: number;
147-
148-
/** Callback that is executed when a fatal global error occurs. */
149-
onFatalError?(this: void, error: Error): void;
150118
}
151119

152120
/**

packages/node/src/types.ts

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
import type { Span as WriteableSpan } from '@opentelemetry/api';
22
import type { Instrumentation } from '@opentelemetry/instrumentation';
33
import type { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base';
4-
import type { ClientOptions, Options, SamplingContext, Scope, Span, TracePropagationTargets } from '@sentry/core';
4+
import type { BaseWinterTCOptions, ClientOptions, Options, SamplingContext, Scope, Span } from '@sentry/core';
55
import type { NodeTransportOptions } from '@sentry/node-core';
66

7-
export interface BaseNodeOptions {
8-
/**
9-
* List of strings/regex controlling to which outgoing requests
10-
* the SDK will attach tracing headers.
11-
*
12-
* By default the SDK will attach those headers to all outgoing
13-
* requests. If this option is provided, the SDK will match the
14-
* request URL of outgoing requests against the items in this
15-
* array, and only attach tracing headers if a match was found.
16-
*
17-
* @example
18-
* ```js
19-
* Sentry.init({
20-
* tracePropagationTargets: ['api.site.com'],
21-
* });
22-
* ```
23-
*/
24-
tracePropagationTargets?: TracePropagationTargets;
25-
7+
/**
8+
* Base options for the Sentry Node SDK.
9+
* Extends the common WinterTC options shared with Bun and other server-side SDKs.
10+
*/
11+
export interface BaseNodeOptions extends BaseWinterTCOptions {
2612
/**
2713
* Sets profiling sample rate when @sentry/profiling-node is installed
2814
*
@@ -74,40 +60,13 @@ export interface BaseNodeOptions {
7460
*/
7561
includeServerName?: boolean;
7662

77-
/** Sets an optional server name (device name) */
78-
serverName?: string;
79-
8063
/**
8164
* Include local variables with stack traces.
8265
*
8366
* Requires the `LocalVariables` integration.
8467
*/
8568
includeLocalVariables?: boolean;
8669

87-
/**
88-
* If you use Spotlight by Sentry during development, use
89-
* this option to forward captured Sentry events to Spotlight.
90-
*
91-
* Either set it to true, or provide a specific Spotlight Sidecar URL.
92-
*
93-
* More details: https://spotlightjs.com/
94-
*
95-
* IMPORTANT: Only set this option to `true` while developing, not in production!
96-
*/
97-
spotlight?: boolean | string;
98-
99-
/**
100-
* If this is set to true, the SDK will not set up OpenTelemetry automatically.
101-
* In this case, you _have_ to ensure to set it up correctly yourself, including:
102-
* * The `SentrySpanProcessor`
103-
* * The `SentryPropagator`
104-
* * The `SentryContextManager`
105-
* * The `SentrySampler`
106-
*
107-
* If you are registering your own OpenTelemetry Loader Hooks (or `import-in-the-middle` hooks), it is also recommended to set the `registerEsmLoaderHooks` option to false.
108-
*/
109-
skipOpenTelemetrySetup?: boolean;
110-
11170
/**
11271
* Provide an array of OpenTelemetry Instrumentations that should be registered.
11372
*
@@ -159,9 +118,6 @@ export interface BaseNodeOptions {
159118
* problems.
160119
*/
161120
shutdownTimeout?: number;
162-
163-
/** Callback that is executed when a fatal global error occurs. */
164-
onFatalError?(this: void, error: Error): void;
165121
}
166122

167123
/**

0 commit comments

Comments
 (0)