-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (39 loc) · 1.33 KB
/
index.ts
File metadata and controls
43 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import type { BrowserOptions } from '@sentry/browser';
import type * as EffectLayer from 'effect/Layer';
import { empty as emptyLayer, suspend as suspendLayer } from 'effect/Layer';
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.
*
* To enable Effect tracing, logs, or metrics, compose with the respective layers:
* - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing
* - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs
* - `Sentry.SentryEffectMetricsLayer` for metrics
*
* @example
* ```typescript
* import * as Sentry from '@sentry/effect/client';
* import { Layer, Logger, LogLevel } from 'effect';
*
* const SentryLive = Layer.mergeAll(
* Sentry.effectLayer({
* dsn: '__DSN__',
* integrations: [Sentry.browserTracingIntegration()],
* tracesSampleRate: 1.0,
* }),
* Layer.setTracer(Sentry.SentryEffectTracer),
* Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
* );
* ```
*/
export function effectLayer(options: EffectClientLayerOptions): EffectLayer.Layer<never, never, never> {
return suspendLayer(() => {
init(options);
return emptyLayer;
});
}