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
6 changes: 6 additions & 0 deletions dev-packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/effect':
access: $all
publish: $all
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/ember':
access: $all
publish: $all
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"packages/core",
"packages/cloudflare",
"packages/deno",
"packages/effect",
"packages/ember",
"packages/eslint-config-sdk",
"packages/eslint-plugin-sdk",
Expand Down
15 changes: 15 additions & 0 deletions packages/effect/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
node: true,
},
overrides: [
{
files: ['vite.config.ts', 'vitest.config.ts'],
parserOptions: {
project: ['tsconfig.vite.json'],
},
},
],
extends: ['../../.eslintrc.js'],
};
21 changes: 21 additions & 0 deletions packages/effect/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Functional Software Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions packages/effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Official Sentry SDK for Effect.ts (Alpha)

[![npm version](https://img.shields.io/npm/v/@sentry/effect.svg)](https://www.npmjs.com/package/@sentry/effect)
[![npm dm](https://img.shields.io/npm/dm/@sentry/effect.svg)](https://www.npmjs.com/package/@sentry/effect)
[![npm dt](https://img.shields.io/npm/dt/@sentry/effect.svg)](https://www.npmjs.com/package/@sentry/effect)

> NOTICE: This package is in alpha state and may be subject to breaking changes.

## Getting Started

This SDK does not have docs yet. Stay tuned.

## Usage

```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);
```

The `effectLayer` function initializes Sentry and returns an Effect Layer that provides:

- Distributed tracing with automatic HTTP header extraction/injection
- Effect spans traced as Sentry spans
- Effect logs forwarded to Sentry (when `enableLogs` is set)
- Effect metrics sent to Sentry (when `enableMetrics` is set)

## Links

<!-- - [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/effect/) -->

- [Sentry.io](https://sentry.io/?utm_source=github&utm_medium=npm_effect)
- [Sentry Discord Server](https://discord.gg/Ww9hbqr)
- [Stack Overflow](https://stackoverflow.com/questions/tagged/sentry)
99 changes: 99 additions & 0 deletions packages/effect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"name": "@sentry/effect",
"version": "10.42.0",
"description": "Official Sentry SDK for Effect",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/effect",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=18"
},
"files": [
"/build"
],
"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",
".": {
"types": "./build/types/index.types.d.ts",
"browser": {
"import": "./build/esm/index.client.js",
"require": "./build/cjs/index.client.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.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"
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@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",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.mjs",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
"build:watch": "run-p build:transpile:watch",
"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.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",
"test": "vitest run",
"test:watch": "vitest --watch",
"yalc:publish": "yalc publish --push --sig"
},
"volta": {
"extends": "../../package.json"
},
"sideEffects": false
}
25 changes: 25 additions & 0 deletions packages/effect/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';

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);
39 changes: 39 additions & 0 deletions packages/effect/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { BrowserOptions } from '@sentry/browser';
import type * as EffectLayer from 'effect/Layer';
import { suspend as suspendLayer } from 'effect/Layer';
import { buildEffectLayer } from '../utils/buildEffectLayer';
import { init } from './sdk';

export { init } from './sdk';

/**
* Options for the Sentry Effect client layer.
*/
export type EffectClientLayerOptions = BrowserOptions;

/**
* Creates an Effect Layer that initializes Sentry for browser clients.
*
* This layer provides Effect applications with full Sentry instrumentation including:
* - Effect spans traced as Sentry spans
* - Effect logs forwarded to Sentry (when `enableLogs` is set)
*
* @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(options: EffectClientLayerOptions): EffectLayer.Layer<never, never, never> {
return suspendLayer(() => buildEffectLayer(options, init(options)));
}
20 changes: 20 additions & 0 deletions packages/effect/src/client/sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { BrowserOptions } from '@sentry/browser';
import { init as initBrowser } from '@sentry/browser';
import type { Client } from '@sentry/core';
import { applySdkMetadata } from '@sentry/core';

/**
* Initializes the Sentry Effect SDK for browser clients.
*
* @param options - Configuration options for the SDK
* @returns The initialized Sentry client, or undefined if initialization failed
*/
export function init(options: BrowserOptions): Client | undefined {
const opts = {
...options,
};

applySdkMetadata(opts, 'effect', ['effect', 'browser']);

return initBrowser(opts);
}
7 changes: 7 additions & 0 deletions packages/effect/src/index.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// import/export got a false positive, and affects most of our index barrel files
// can be removed once following issue is fixed: https://github.com/import-js/eslint-plugin-import/issues/703
/* eslint-disable import/export */
export * from '@sentry/browser';

export { effectLayer, init } from './client/index';
export type { EffectClientLayerOptions } from './client/index';
4 changes: 4 additions & 0 deletions packages/effect/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from '@sentry/node-core/light';

export { effectLayer, init } from './server/index';
export type { EffectServerLayerOptions } from './server/index';
26 changes: 26 additions & 0 deletions packages/effect/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* 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 { Client, Integration, Options, StackParser } from '@sentry/core';
import type * as EffectLayer from 'effect/Layer';
import type * as clientSdk from './index.client';
import type * as serverSdk from './index.server';

export * from './index.client';
export * from './index.server';

export type { EffectClientLayerOptions } from './index.client';
export type { EffectServerLayerOptions } from './index.server';

export declare function effectLayer(
options: clientSdk.EffectClientLayerOptions | serverSdk.EffectServerLayerOptions,
): EffectLayer.Layer<never, never, never>;

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;
43 changes: 43 additions & 0 deletions packages/effect/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { logger as sentryLogger } from '@sentry/core';
import * as Logger from 'effect/Logger';

/**
* Effect Logger that sends logs to Sentry.
*/
export const SentryEffectLogger = Logger.make(({ logLevel, message }) => {
let msg: string;
if (typeof message === 'string') {
msg = message;
} else if (Array.isArray(message) && message.length === 1) {
const firstElement = message[0];
msg = typeof firstElement === 'string' ? firstElement : JSON.stringify(firstElement);
} else {
msg = JSON.stringify(message);
}

switch (logLevel._tag) {
case 'Fatal':
sentryLogger.fatal(msg);
break;
case 'Error':
sentryLogger.error(msg);
break;
case 'Warning':
sentryLogger.warn(msg);
break;
case 'Info':
sentryLogger.info(msg);
break;
case 'Debug':
sentryLogger.debug(msg);
break;
case 'Trace':
sentryLogger.trace(msg);
break;
case 'All':
case 'None':
break;
default:
logLevel satisfies never;
}
});
Loading
Loading