From 85c00da518b8218a5a89a315d09a78d99271930e Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 5 Mar 2026 12:18:44 +0100 Subject: [PATCH 1/2] feat(effect): Add client/server entrypoints without functionality --- packages/effect/package.json | 58 ++++++++++++++---- packages/effect/rollup.npm.config.mjs | 30 ++++++--- packages/effect/src/client/index.ts | 30 +++++++++ packages/effect/src/index.client.ts | 4 ++ packages/effect/src/index.server.ts | 4 ++ packages/effect/src/index.ts | 87 --------------------------- packages/effect/src/index.types.ts | 14 +++++ packages/effect/src/server/index.ts | 32 ++++++++++ packages/effect/test/index.test.ts | 2 +- packages/effect/tsconfig.json | 1 + yarn.lock | 14 ++++- 11 files changed, 166 insertions(+), 110 deletions(-) create mode 100644 packages/effect/src/client/index.ts create mode 100644 packages/effect/src/index.client.ts create mode 100644 packages/effect/src/index.server.ts delete mode 100644 packages/effect/src/index.ts create mode 100644 packages/effect/src/index.types.ts create mode 100644 packages/effect/src/server/index.ts diff --git a/packages/effect/package.json b/packages/effect/package.json index dbee14b478a8..c088def04907 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -12,26 +12,44 @@ "files": [ "/build" ], - "main": "build/cjs/index.js", - "module": "build/esm/index.js", - "types": "build/types/index.d.ts", + "main": "build/cjs/index.server.js", + "module": "build/esm/index.server.js", + "browser": "build/esm/index.client.js", + "types": "build/types/index.types.d.ts", "exports": { "./package.json": "./package.json", ".": { - "import": { - "types": "./build/types/index.d.ts", - "default": "./build/esm/index.js" + "types": "./build/types/index.types.d.ts", + "browser": { + "import": "./build/esm/index.client.js", + "require": "./build/cjs/index.client.js" }, - "require": { - "types": "./build/types/index.d.ts", - "default": "./build/cjs/index.js" + "node": { + "import": "./build/esm/index.server.js", + "require": "./build/cjs/index.server.js" } + }, + "./server": { + "types": "./build/types/index.server.d.ts", + "import": "./build/esm/index.server.js", + "require": "./build/cjs/index.server.js" + }, + "./client": { + "types": "./build/types/index.client.d.ts", + "import": "./build/esm/index.client.js", + "require": "./build/cjs/index.client.js" } }, "typesVersions": { "<5.0": { - "build/types/index.d.ts": [ - "build/types-ts3.8/index.d.ts" + "build/types/index.types.d.ts": [ + "build/types-ts3.8/index.types.d.ts" + ], + "build/types/index.server.d.ts": [ + "build/types-ts3.8/index.server.d.ts" + ], + "build/types/index.client.d.ts": [ + "build/types-ts3.8/index.client.d.ts" ] } }, @@ -39,7 +57,21 @@ "access": "public" }, "dependencies": { - "@sentry/core": "10.42.0" + "@sentry/browser": "10.42.0", + "@sentry/core": "10.42.0", + "@sentry/node-core": "10.42.0" + }, + "peerDependencies": { + "effect": "^3.0.0" + }, + "peerDependenciesMeta": { + "effect": { + "optional": false + } + }, + "devDependencies": { + "@effect/vitest": "^0.23.9", + "effect": "^3.19.19" }, "scripts": { "build": "run-p build:transpile build:types", @@ -52,7 +84,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:tarball": "npm pack", - "circularDepCheck": "madge --circular src/index.ts", + "circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts", "clean": "rimraf build coverage sentry-effect-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", diff --git a/packages/effect/rollup.npm.config.mjs b/packages/effect/rollup.npm.config.mjs index ca36da81392f..211157646473 100644 --- a/packages/effect/rollup.npm.config.mjs +++ b/packages/effect/rollup.npm.config.mjs @@ -1,11 +1,25 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils'; -export default makeNPMConfigVariants( - makeBaseNPMConfig({ - packageSpecificConfig: { - output: { - preserveModulesRoot: 'src', - }, +const baseConfig = makeBaseNPMConfig({ + entrypoints: ['src/index.server.ts', 'src/index.client.ts'], + packageSpecificConfig: { + output: { + preserveModulesRoot: 'src', }, - }), -); + }, +}); + +const defaultExternal = baseConfig.external || []; +baseConfig.external = id => { + if (defaultExternal.includes(id)) { + return true; + } + + if (id === 'effect' || id.startsWith('effect/') || id.startsWith('@sentry/')) { + return true; + } + + return false; +}; + +export default makeNPMConfigVariants(baseConfig); diff --git a/packages/effect/src/client/index.ts b/packages/effect/src/client/index.ts new file mode 100644 index 000000000000..f2a4ce7bec9b --- /dev/null +++ b/packages/effect/src/client/index.ts @@ -0,0 +1,30 @@ +import type { BrowserOptions } from '@sentry/browser'; +import * as EffectLayer from 'effect/Layer'; + +/** + * Options for the Sentry Effect client layer. + */ +export type EffectClientLayerOptions = BrowserOptions; + +/** + * Creates an empty Effect Layer + * + * @example + * ```typescript + * import * as Sentry from '@sentry/effect/client'; + * import { Layer, Effect } from 'effect'; + * + * const ApiClientWithSentry = ApiClientLive.pipe( + * Layer.provide(Sentry.effectLayer({ + * dsn: '__DSN__', + * integrations: [Sentry.browserTracingIntegration()], + * tracesSampleRate: 1.0, + * })), + * ); + * + * Effect.runPromise(Effect.provide(myEffect, ApiClientWithSentry)); + * ``` + */ +export function effectLayer(_: EffectClientLayerOptions): EffectLayer.Layer { + return EffectLayer.empty; +} diff --git a/packages/effect/src/index.client.ts b/packages/effect/src/index.client.ts new file mode 100644 index 000000000000..b5b4833026df --- /dev/null +++ b/packages/effect/src/index.client.ts @@ -0,0 +1,4 @@ +export * from '@sentry/browser'; + +export { effectLayer } from './client/index'; +export type { EffectClientLayerOptions } from './client/index'; diff --git a/packages/effect/src/index.server.ts b/packages/effect/src/index.server.ts new file mode 100644 index 000000000000..f9aa4d562c6f --- /dev/null +++ b/packages/effect/src/index.server.ts @@ -0,0 +1,4 @@ +export * from '@sentry/node-core/light'; + +export { effectLayer } from './server/index'; +export type { EffectServerLayerOptions } from './server/index'; diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts deleted file mode 100644 index 88781f88051a..000000000000 --- a/packages/effect/src/index.ts +++ /dev/null @@ -1,87 +0,0 @@ -export type { - Breadcrumb, - BreadcrumbHint, - Context, - Contexts, - RequestEventData, - SdkInfo, - Event, - EventHint, - ErrorEvent, - Exception, - SeverityLevel, - StackFrame, - Stacktrace, - Thread, - User, - Session, - CaptureContext, - ExclusiveEventHintOrCaptureContext, - Log, - LogSeverityLevel, - Span, -} from '@sentry/core'; - -export { - addEventProcessor, - addBreadcrumb, - addIntegration, - captureException, - captureEvent, - captureFeedback, - captureMessage, - close, - createTransport, - lastEventId, - flush, - getClient, - isInitialized, - isEnabled, - getCurrentScope, - getIsolationScope, - getGlobalScope, - setCurrentClient, - Scope, - continueTrace, - getTraceData, - suppressTracing, - SDK_VERSION, - setContext, - setExtra, - setExtras, - setTag, - setTags, - setUser, - withScope, - withIsolationScope, - functionToStringIntegration, - eventFiltersIntegration, - dedupeIntegration, - parameterize, - startSession, - captureSession, - endSession, - spanToJSON, - spanToTraceHeader, - spanToBaggageHeader, - updateSpanName, - metrics, - getActiveSpan, - getRootSpan, - startSpan, - startInactiveSpan, - startSpanManual, - withActiveSpan, - startNewTrace, - getSpanDescendants, - setMeasurement, - getSpanStatusFromHttpCode, - setHttpStatus, -} from '@sentry/core'; - -export { - SEMANTIC_ATTRIBUTE_SENTRY_OP, - SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, - SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, - SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, -} from '@sentry/core'; diff --git a/packages/effect/src/index.types.ts b/packages/effect/src/index.types.ts new file mode 100644 index 000000000000..7ef66238bfe6 --- /dev/null +++ b/packages/effect/src/index.types.ts @@ -0,0 +1,14 @@ +/* eslint-disable import/export */ + +// We export everything from both the client part of the SDK and from the server part. +// Some of the exports collide, which is not allowed, unless we redefine the colliding +// exports in this file - which we do below. +import type * as EffectLayer from 'effect/Layer'; +import type { EffectClientLayerOptions } from './index.client'; +import type { EffectServerLayerOptions } from './index.server'; + +export * from './client/index'; +export * from './server/index'; + +/** Creates an Effect Layer that initializes Sentry and integrates tracing, logging, and metrics. */ +export declare function effectLayer(options: EffectClientLayerOptions | EffectServerLayerOptions): EffectLayer.Layer; diff --git a/packages/effect/src/server/index.ts b/packages/effect/src/server/index.ts new file mode 100644 index 000000000000..91281ea96486 --- /dev/null +++ b/packages/effect/src/server/index.ts @@ -0,0 +1,32 @@ +import type { NodeOptions } from '@sentry/node-core'; +import * as EffectLayer from 'effect/Layer'; + +/** + * Options for the Sentry Effect server layer. + */ +export type EffectServerLayerOptions = NodeOptions; + +/** + * Creates an empty Effect Layer + * + * @example + * ```typescript + * import * as Sentry from '@sentry/effect/server'; + * import { NodeRuntime } from '@effect/platform-node'; + * import { Layer } from 'effect'; + * import { HttpLive } from './Http.js'; + * + * const MainLive = HttpLive.pipe( + * Layer.provide(Sentry.effectLayer({ + * dsn: '__DSN__', + * enableLogs: true, + * enableMetrics: true, + * })), + * ); + * + * MainLive.pipe(Layer.launch, NodeRuntime.runMain); + * ``` + */ +export function effectLayer(_: EffectServerLayerOptions): EffectLayer.Layer { + return EffectLayer.empty; +} diff --git a/packages/effect/test/index.test.ts b/packages/effect/test/index.test.ts index f774de6eaf24..950ec06fb670 100644 --- a/packages/effect/test/index.test.ts +++ b/packages/effect/test/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import * as index from '../src'; +import * as index from '../src/index.client'; describe('effect index export', () => { it('has correct exports', () => { diff --git a/packages/effect/tsconfig.json b/packages/effect/tsconfig.json index ee81c1a20817..d49b053b37f8 100644 --- a/packages/effect/tsconfig.json +++ b/packages/effect/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "module": "esnext", + "moduleResolution": "bundler", "outDir": "build" }, "include": ["src/**/*"] diff --git a/yarn.lock b/yarn.lock index ac89a4468d6a..af2910e4f916 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3269,6 +3269,11 @@ dependencies: "@edge-runtime/primitives" "6.0.0" +"@effect/vitest@^0.23.9": + version "0.23.13" + resolved "https://registry.yarnpkg.com/@effect/vitest/-/vitest-0.23.13.tgz#17edf9d8e3443f080ff8fe93bd37b023612a07a4" + integrity sha512-F3x2phMXuVzqWexdcYp8v0z1qQHkKxp2UaHNbqZaEjPEp8FBz/iMwbi6iS/oIWzLfGF8XqdP8BGJptvGIJONNw== + "@ember-data/rfc395-data@^0.0.4": version "0.0.4" resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843" @@ -14877,6 +14882,14 @@ effect@3.16.12: "@standard-schema/spec" "^1.0.0" fast-check "^3.23.1" +effect@^3.19.19: + version "3.19.19" + resolved "https://registry.yarnpkg.com/effect/-/effect-3.19.19.tgz#643a5a4b7445cc924a28270bc6cd1a5c8facd27e" + integrity sha512-Yc8U/SVXo2dHnaP7zNBlAo83h/nzSJpi7vph6Hzyl4ulgMBIgPmz3UzOjb9sBgpFE00gC0iETR244sfXDNLHRg== + dependencies: + "@standard-schema/spec" "^1.0.0" + fast-check "^3.23.1" + ejs@^3.1.7: version "3.1.8" resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.8.tgz#758d32910c78047585c7ef1f92f9ee041c1c190b" @@ -28096,7 +28109,6 @@ stylus@0.59.0, stylus@^0.59.0: sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills: version "3.36.0" - uid fd682f6129e507c00bb4e6319cc5d6b767e36061 resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061" dependencies: "@jridgewell/gen-mapping" "^0.3.2" From 90184af647c3f74b5b8a689e88b70933e3c9fe11 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 5 Mar 2026 13:01:44 +0100 Subject: [PATCH 2/2] fixup! feat(effect): Add client/server entrypoints without functionality --- packages/effect/src/index.types.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/effect/src/index.types.ts b/packages/effect/src/index.types.ts index 7ef66238bfe6..e0a6e9512eeb 100644 --- a/packages/effect/src/index.types.ts +++ b/packages/effect/src/index.types.ts @@ -3,12 +3,24 @@ // We export everything from both the client part of the SDK and from the server part. // Some of the exports collide, which is not allowed, unless we redefine the colliding // exports in this file - which we do below. +import type { Client, Integration, Options, StackParser } from '@sentry/core'; import type * as EffectLayer from 'effect/Layer'; -import type { EffectClientLayerOptions } from './index.client'; -import type { EffectServerLayerOptions } from './index.server'; +import type * as clientSdk from './index.client'; +import type * as serverSdk from './index.server'; -export * from './client/index'; -export * from './server/index'; +export * from './index.client'; +export * from './index.server'; -/** Creates an Effect Layer that initializes Sentry and integrates tracing, logging, and metrics. */ -export declare function effectLayer(options: EffectClientLayerOptions | EffectServerLayerOptions): EffectLayer.Layer; +export type { EffectClientLayerOptions } from './index.client'; +export type { EffectServerLayerOptions } from './index.server'; + +export declare function effectLayer( + options: clientSdk.EffectClientLayerOptions | serverSdk.EffectServerLayerOptions, +): EffectLayer.Layer; + +export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): Client | undefined; +export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration; +export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration; +export declare const getDefaultIntegrations: (options: Options) => Integration[]; +export declare const defaultStackParser: StackParser; +export declare const logger: typeof clientSdk.logger | typeof serverSdk.logger;