Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/astro/src/server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import type { Span, SpanAttributes } from '@sentry/core';
import {
addNonEnumerableProperty,
flushIfServerless,
getIsolationScope,
getRootSpan,
objectify,
Expand All @@ -11,6 +10,7 @@ import {
stripUrlQueryAndFragment,
winterCGRequestToRequestData,
} from '@sentry/core';
import { flushIfServerless } from '@sentry-internal/server-utils';
import {
captureException,
continueTrace,
Expand Down
1 change: 1 addition & 0 deletions packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"access": "public"
},
"dependencies": {
"@sentry-internal/server-utils": "10.54.0",
"@sentry/core": "10.54.0",
"@sentry/node": "10.54.0"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/bun/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ServerRuntimeClientOptions } from '@sentry/core';
import { applySdkMetadata, ServerRuntimeClient } from '@sentry/core';
import type { ServerRuntimeClientOptions } from '@sentry-internal/server-utils';
import { applySdkMetadata } from '@sentry/core';
import { ServerRuntimeClient } from '@sentry-internal/server-utils';
import * as os from 'os';
import type { BunClientOptions } from './types';

Expand Down
1 change: 1 addition & 0 deletions packages/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"dependencies": {
"@opentelemetry/api": "^1.9.1",
"@sentry-internal/server-utils": "10.54.0",
"@sentry/core": "10.54.0"
},
"peerDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions packages/cloudflare/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { ClientOptions, Options, ServerRuntimeClientOptions } from '@sentry/core';
import { applySdkMetadata, debug, ServerRuntimeClient } from '@sentry/core';
import type { ClientOptions, Options } from '@sentry/core';
import type { ServerRuntimeClientOptions } from '@sentry-internal/server-utils';
import { applySdkMetadata, debug } from '@sentry/core';
import { ServerRuntimeClient } from '@sentry-internal/server-utils';
import { DEBUG_BUILD } from './debug-build';
import type { makeFlushLock } from './flush';
import type { CloudflareTransportOptions } from './transport';
Expand Down
8 changes: 5 additions & 3 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ export {
moduleMetadataIntegration,
supabaseIntegration,
instrumentSupabaseClient,
instrumentPostgresJsSql,
zodErrorsIntegration,
consoleIntegration,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
trpcMiddleware,
spanToJSON,
spanToTraceHeader,
spanToBaggageHeader,
updateSpanName,
wrapMcpServerWithSentry,
consoleLoggingIntegration,
createConsolaReporter,
createLangChainCallbackHandler,
Expand All @@ -112,6 +109,11 @@ export {
instrumentLangGraph,
instrumentCreateReactAgent,
} from '@sentry/core';
export {
instrumentPostgresJsSql,
trpcMiddleware,
wrapMcpServerWithSentry,
} from '@sentry-internal/server-utils';

export { withSentry } from './withSentry';
export { instrumentDurableObjectWithSentry } from './durableobject';
Expand Down
3 changes: 2 additions & 1 deletion packages/cloudflare/src/vendor/stacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
// SOFTWARE.

import type { StackLineParser, StackLineParserFn, StackParser } from '@sentry/core';
import { basename, createStackParser, nodeStackLineParser } from '@sentry/core';
import { basename, createStackParser } from '@sentry/core';
import { nodeStackLineParser } from '@sentry-internal/server-utils';

type GetModuleFn = (filename: string | undefined) => string | undefined;

Expand Down
50 changes: 1 addition & 49 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,13 @@
"files": [
"/build",
"browser.js",
"browser.d.ts",
"server.js",
"server.d.ts"
"browser.d.ts"
],
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
"./package.json": "./package.json",
"./server": {
"import": {
"types": "./build/types/server.d.ts",
"default": "./build/esm/server.js"
},
"require": {
"types": "./build/types/server.d.ts",
"default": "./build/cjs/server.js"
}
},
"./browser": {
"import": {
"types": "./build/types/browser.d.ts",
Expand Down Expand Up @@ -59,9 +47,6 @@
],
"browser": [
"build/types-ts3.8/browser.d.ts"
],
"server": [
"build/types-ts3.8/server.d.ts"
]
}
},
Expand Down Expand Up @@ -92,40 +77,7 @@
"extends": "../../package.json"
},
"sideEffects": false,
"dependencies": {
"@sentry-internal/server-utils": "10.54.0"
},
"devDependencies": {
"zod": "^3.24.1"
},
"nx": {
"targets": {
"build:transpile": {
"dependsOn": []
},
"build:types": {
"dependsOn": []
},
"build:dev": {
"dependsOn": []
},
"build:tarball": {
"dependsOn": [
"build:transpile",
"build:types"
]
},
"test:unit": {
"dependsOn": [
"build:transpile",
"build:types"
]
},
"lint": {
"dependsOn": [
"build:types"
]
}
}
}
}
2 changes: 1 addition & 1 deletion packages/core/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ const settings = {
export default makeNPMConfigVariants(
makeBaseNPMConfig({
...settings,
entrypoints: ['src/index.ts', 'src/server.ts', 'src/browser.ts'],
entrypoints: ['src/index.ts', 'src/browser.ts'],
}),
);
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './shared-exports';
export * from './server-exports';
export * from './browser-exports';
11 changes: 10 additions & 1 deletion packages/core/src/shared-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ export * as logger from './logs/public-api';
export { consoleLoggingIntegration } from './logs/console-integration';
export {
_INTERNAL_captureMetric,
_INTERNAL_flushMetricsBuffer,
_INTERNAL_captureSerializedMetric,
_INTERNAL_flushMetricsBuffer,
_INTERNAL_getMetricBuffer,
} from './metrics/internal';
export * as metrics from './metrics/public-api';
export type { MetricOptions } from './metrics/public-api';
Expand Down Expand Up @@ -543,3 +544,11 @@ export {
safeMathRandom as _INTERNAL_safeMathRandom,
safeDateNow as _INTERNAL_safeDateNow,
} from './utils/randomSafeContext';

// Exposed so that `@sentry-internal/server-utils` can build `ServerRuntimeClient`
// on top of `Client` without copying these internal helpers.
export { DEFAULT_TRANSPORT_BUFFER_SIZE } from './transports/base';
export { addUserAgentToTransportHeaders } from './transports/userAgent';
export { _getTraceInfoFromScope } from './utils/trace-info';
export { safeUnref as _INTERNAL_safeUnref } from './utils/timer';
export { isNodeEnv, loadModule } from './utils/node';
89 changes: 0 additions & 89 deletions packages/core/src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,95 +12,6 @@ import type { StackLineParser, StackParser } from './stacktrace';
import type { TracePropagationTargets } from './tracing';
import type { BaseTransportOptions, Transport } from './transport';

/**
* Base options for WinterTC-compatible server-side JavaScript runtimes.
* This interface contains common configuration options shared between
* SDKs.
*/
export interface ServerRuntimeOptions {
/**
* List of strings/regex controlling to which outgoing requests
* the SDK will attach tracing headers.
*
* By default the SDK will attach those headers to all outgoing
* requests. If this option is provided, the SDK will match the
* request URL of outgoing requests against the items in this
* array, and only attach tracing headers if a match was found.
*
* @example
* ```js
* Sentry.init({
* tracePropagationTargets: ['api.site.com'],
* });
* ```
*/
tracePropagationTargets?: TracePropagationTargets;

/**
* Sets an optional server name (device name).
*
* This is useful for identifying which server or instance is sending events.
*/
serverName?: string;

/**
* If you use Spotlight by Sentry during development, use
* this option to forward captured Sentry events to Spotlight.
*
* Either set it to true, or provide a specific Spotlight Sidecar URL.
*
* More details: https://spotlightjs.com/
*
* IMPORTANT: Only set this option to `true` while developing, not in production!
*/
spotlight?: boolean | string;

/**
* If set to `false`, the SDK will not automatically detect the `serverName`.
*
* This is useful if you are using the SDK in a CLI app or Electron where the
* hostname might be considered PII.
*
* @default true
*/
includeServerName?: boolean;

/**
* By default, the SDK will try to identify problems with your instrumentation setup and warn you about it.
* If you want to disable these warnings, set this to `true`.
*/
disableInstrumentationWarnings?: boolean;

/**
* Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause
* problems for sending events from command line applications. Setting it too
* high can cause the application to block for users with network connectivity
* problems.
*/
shutdownTimeout?: number;

/**
* Configures in which interval client reports will be flushed. Defaults to `60_000` (milliseconds).
*/
clientReportFlushInterval?: number;

/**
* The max. duration in seconds that the SDK will wait for parent spans to be finished before discarding a span.
* The SDK will automatically clean up spans that have no finished parent after this duration.
* This is necessary to prevent memory leaks in case of parent spans that are never finished or otherwise dropped/missing.
* However, if you have very long-running spans in your application, a shorter duration might cause spans to be discarded too early.
* In this case, you can increase this duration to a value that fits your expected data.
*
* Defaults to 300 seconds (5 minutes).
*/
maxSpanWaitDuration?: number;

/**
* Callback that is executed when a fatal global error occurs.
*/
onFatalError?(this: void, error: Error): void;
}

/**
* Allowed attribute value matchers in `ignoreSpans` filters.
* String span attributes use pattern matching (substring or RegExp).
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/anr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { StackFrame } from '../types/stackframe';
import type { StackFrame } from '@sentry/core';
import { UNKNOWN_FUNCTION } from '@sentry/core';
import { filenameIsInApp } from './node-stack-trace';
import { UNKNOWN_FUNCTION } from './stacktrace';

type WatchdogReturn = {
/** Resets the watchdog timer */
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/utils/flushIfServerless.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { flush } from '../exports';
import { debug } from './debug-logger';
import { debug, flush, GLOBAL_OBJ } from '@sentry/core';
import { vercelWaitUntil } from './vercelWaitUntil';
import { GLOBAL_OBJ } from './worldwide';

type MinimalCloudflareContext = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
15 changes: 13 additions & 2 deletions packages/core/src/utils/node-stack-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import type { StackLineParser, StackLineParserFn } from '../types/stacktrace';
import { normalizeStackTracePath, UNKNOWN_FUNCTION } from './stacktrace';
import type { StackLineParser, StackLineParserFn } from '@sentry/core';
import { UNKNOWN_FUNCTION } from '@sentry/core';

export type GetModuleFn = (filename: string | undefined) => string | undefined;

// Vendored from `@sentry/core`'s private `utils/stacktrace.ts`. Strips a leading
// `file://` and the extra leading slash on Windows paths so stack frame
// filenames match the runtime paths users care about.
function normalizeStackTracePath(path: string | undefined): string | undefined {
let filename = path?.startsWith('file://') ? path.slice(7) : path;
if (filename?.match(/\/[A-Z]:/)) {
filename = filename.slice(1);
}
return filename;
}

/**
* Does this filename look like it's part of the app code?
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/vercelWaitUntil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL_OBJ } from './worldwide';
import { GLOBAL_OBJ } from '@sentry/core';

declare const EdgeRuntime: string | undefined;

Expand Down
14 changes: 12 additions & 2 deletions packages/core/test/lib/integrations/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ import {
createTransport,
GLOBAL_OBJ,
moduleMetadataIntegration,
nodeStackLineParser,
parseEnvelope,
setCurrentClient,
type StackLineParser,
} from '../../../src';
import type { Event } from '../../../src/types/event';

// Minimal Node-style stack-line parser. Sufficient for the `Error().stack` lines
// generated below; the full Node parser now lives in `@sentry-internal/server-utils`.
const nodeStackLineFixture: StackLineParser = [
90,
(line: string) => {
const m = line.match(/at (?:async )?(?:(.+?)\s+\()?(.+):(\d+):(\d+)\)?/);
return m ? { function: m[1], filename: m[2], lineno: +m[3]!, colno: +m[4]! } : undefined;
},
];
import { getDefaultTestClientOptions, TestClient } from '../../mocks/client';

const stackParser = createStackParser(nodeStackLineParser());
const stackParser = createStackParser(nodeStackLineFixture);

const stack = new Error().stack || '';

Expand Down
Loading
Loading