Skip to content
Open
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
8 changes: 8 additions & 0 deletions docs/platforms/javascript/guides/effect/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Effect
description: Learn how to set up Sentry in your Effect application with first-class integration for tracing, logging, and metrics.
sdk: sentry.javascript.effect
categories:
- javascript
- server
- server-node
- browser
183 changes: 183 additions & 0 deletions docs/platforms/javascript/guides/effect/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
title: Effect
sdk: sentry.javascript.effect
description: Learn how to set up Sentry in your Effect application with first-class integration for tracing, logging, and metrics.
---

<Alert>

This SDK is currently in **ALPHA**. Alpha features are still in progress, may have bugs, and might include breaking changes.
Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns.

</Alert>

The `@sentry/effect` SDK provides first-class integration with [Effect](https://effect.website/), enabling automatic tracing, logging, and metrics capture for Effect-based applications.

<PlatformContent includePath="getting-started-prerequisites" />

## Step 1: Install

Choose the features you want to configure, and this guide will show you how:

<OnboardingOptionButtons
options={[
"error-monitoring",
"performance",
"logs",
"metrics",
]}
/>

<PlatformContent includePath="getting-started-features-expandable" />

### Install the Sentry SDK

```bash {tabTitle:npm}
npm install @sentry/effect --save
```

```bash {tabTitle:yarn}
yarn add @sentry/effect
```

```bash {tabTitle:pnpm}
pnpm add @sentry/effect
```

## Step 2: Configure

The SDK provides an `effectLayer` that initializes Sentry. You can compose it with additional Effect layers to enable tracing, logging, and metrics.

### Server Usage

```typescript {filename:main.ts}
import * as Sentry from "@sentry/effect/server";
import { NodeRuntime } from "@effect/platform-node";
// ___PRODUCT_OPTION_START___ logs
import * as Logger from "effect/Logger";
// ___PRODUCT_OPTION_END___ logs
import * as Layer from "effect/Layer";
import { HttpLive } from "./Http.js";

const SentryLive = Layer.mergeAll(
Sentry.effectLayer({
dsn: "___PUBLIC_DSN___",
// ___PRODUCT_OPTION_START___ performance

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production.
tracesSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
}),
// ___PRODUCT_OPTION_START___ performance

// Enable Effect tracing
Layer.setTracer(Sentry.SentryEffectTracer),
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Forward Effect logs to Sentry
Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
// ___PRODUCT_OPTION_END___ logs
// ___PRODUCT_OPTION_START___ metrics

// Forward Effect metrics to Sentry
Sentry.SentryEffectMetricsLayer,
// ___PRODUCT_OPTION_END___ metrics
);

const MainLive = HttpLive.pipe(Layer.provide(SentryLive));

MainLive.pipe(Layer.launch, NodeRuntime.runMain);
```

### Client Usage

```typescript {filename:main.ts}
import * as Sentry from "@sentry/effect/client";
// ___PRODUCT_OPTION_START___ logs
import { Logger } from "effect";
// ___PRODUCT_OPTION_END___ logs
import { Layer } from "effect";

const SentryLive = Layer.mergeAll(
Sentry.effectLayer({
dsn: "___PUBLIC_DSN___",
// ___PRODUCT_OPTION_START___ performance

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production.
tracesSampleRate: 1.0,
integrations: [Sentry.browserTracingIntegration()],
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
}),
// ___PRODUCT_OPTION_START___ performance

// Enable Effect tracing
Layer.setTracer(Sentry.SentryEffectTracer),
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Forward Effect logs to Sentry
Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
// ___PRODUCT_OPTION_END___ logs
);

const MainLive = YourAppLayer.pipe(Layer.provide(SentryLive));
```

## Features

The SDK provides composable layers for Effect integration:

<OnboardingOption optionId="performance">
- **Tracing** via `Sentry.SentryEffectTracer`: Effect spans are automatically traced as Sentry spans with distributed tracing support
</OnboardingOption>
<OnboardingOption optionId="logs">
- **Logging** via `Sentry.SentryEffectLogger`: Effect logs are forwarded to Sentry (requires `enableLogs: true`)
</OnboardingOption>
<OnboardingOption optionId="metrics">
- **Metrics** via `Sentry.SentryEffectMetricsLayer`: Effect metrics (counters, gauges, histograms) are sent to Sentry
</OnboardingOption>

## Step 3: Verify

Add a test error to verify your setup:

```typescript
import { Effect } from "effect";
import * as Sentry from "@sentry/effect/server";

const program = Effect.gen(function* () {
yield* Effect.fail(new Error("Sentry Test Error"));
});

// Run with your layer that includes Sentry.effectLayer
```

Head over to your project on [Sentry.io](https://sentry.io) to view the collected data.

## Next Steps

- Learn how to [manually capture errors](/platforms/javascript/guides/effect/usage/)
- Continue to [customize your configuration](/platforms/javascript/guides/effect/configuration/)
- Get familiar with [Sentry's product features](/product/) like tracing, insights, and alerts

<Expandable permalink={false} title="Are you having problems setting up the SDK?">

- Find various topics in <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink>
- [Get support](https://sentry.zendesk.com/hc/en-us/)

</Expandable>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"next-themes": "^0.3.0",
"nextjs-toploader": "^1.6.6",
"p-limit": "^6.2.0",
"platformicons": "^9.0.7",
"platformicons": "^9.2.1",
"prism-sentry": "^1.0.2",
"react": "^19.2.4",
"react-dom": "^19.2.4",
Expand Down
Loading
Loading