@sentry/effect 11.11.0 → 11.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/client/index.js +38 -16
- package/build/cjs/client/index.js.map +1 -1
- package/build/cjs/client/sdk.js +14 -12
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/tracer.js +13 -8
- package/build/cjs/client/tracer.js.map +1 -1
- package/build/cjs/errorReporter.js +52 -56
- package/build/cjs/errorReporter.js.map +1 -1
- package/build/cjs/index.client.js +20 -28
- package/build/cjs/index.server.js +20 -28
- package/build/cjs/logger.js +41 -51
- package/build/cjs/logger.js.map +1 -1
- package/build/cjs/metrics.js +100 -114
- package/build/cjs/metrics.js.map +1 -1
- package/build/cjs/server/index.js +39 -16
- package/build/cjs/server/index.js.map +1 -1
- package/build/cjs/server/sdk.js +22 -14
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/tracer.js +19 -8
- package/build/cjs/server/tracer.js.map +1 -1
- package/build/cjs/tracer.js +251 -226
- package/build/cjs/tracer.js.map +1 -1
- package/build/esm/client/index.js +37 -13
- package/build/esm/client/index.js.map +1 -1
- package/build/esm/client/sdk.js +14 -10
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/tracer.js +12 -5
- package/build/esm/client/tracer.js.map +1 -1
- package/build/esm/errorReporter.js +50 -54
- package/build/esm/errorReporter.js.map +1 -1
- package/build/esm/index.client.js +8 -8
- package/build/esm/index.server.js +8 -8
- package/build/esm/logger.js +38 -48
- package/build/esm/logger.js.map +1 -1
- package/build/esm/metrics.js +93 -111
- package/build/esm/metrics.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/index.js +38 -13
- package/build/esm/server/index.js.map +1 -1
- package/build/esm/server/sdk.js +22 -12
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/tracer.js +18 -5
- package/build/esm/server/tracer.js.map +1 -1
- package/build/esm/tracer.js +244 -222
- package/build/esm/tracer.js.map +1 -1
- package/package.json +18 -19
- package/build/cjs/index.client.js.map +0 -1
- package/build/cjs/index.server.js.map +0 -1
- package/build/esm/index.client.js.map +0 -1
- package/build/esm/index.server.js.map +0 -1
|
@@ -1,16 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { makeSentryErrorReporterLayer } from "../errorReporter.js";
|
|
2
|
+
import { init } from "./sdk.js";
|
|
3
|
+
import { empty, merge, suspend } from "effect/Layer";
|
|
4
|
+
// src/client/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates an Effect Layer that initializes Sentry for browser clients.
|
|
7
|
+
*
|
|
8
|
+
* On Effect v4 the layer also registers a Sentry `ErrorReporter`, so failures passing through
|
|
9
|
+
* `Effect.withErrorReporting`, `ErrorReporter.report` or the built-in HTTP and RPC boundaries are captured.
|
|
10
|
+
*
|
|
11
|
+
* To enable Effect tracing, logs, or metrics, compose with the respective layers:
|
|
12
|
+
* - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing
|
|
13
|
+
* - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs
|
|
14
|
+
* - `Sentry.SentryEffectMetricsLayer` for metrics
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import * as Sentry from '@sentry/effect/client';
|
|
19
|
+
* import { Layer, Logger, LogLevel } from 'effect';
|
|
20
|
+
*
|
|
21
|
+
* const SentryLive = Layer.mergeAll(
|
|
22
|
+
* Sentry.effectLayer({
|
|
23
|
+
* dsn: '__DSN__',
|
|
24
|
+
* integrations: [Sentry.browserTracingIntegration()],
|
|
25
|
+
* tracesSampleRate: 1.0,
|
|
26
|
+
* }),
|
|
27
|
+
* Layer.setTracer(Sentry.SentryEffectTracer),
|
|
28
|
+
* Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
5
32
|
function effectLayer(options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}),
|
|
11
|
-
makeSentryErrorReporterLayer()
|
|
12
|
-
);
|
|
33
|
+
return merge(suspend(() => {
|
|
34
|
+
init(options);
|
|
35
|
+
return empty;
|
|
36
|
+
}), makeSentryErrorReporterLayer());
|
|
13
37
|
}
|
|
14
|
-
|
|
15
38
|
export { effectLayer, init };
|
|
16
|
-
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/client/index.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer, merge as mergeLayer, suspend as suspendLayer } from 'effect/Layer';\nimport { makeSentryErrorReporterLayer } from '../errorReporter';\nimport { init } from './sdk';\n\nexport { init } from './sdk';\n\n/**\n * Options for the Sentry Effect client layer.\n */\nexport type EffectClientLayerOptions = BrowserOptions;\n\n/**\n * Creates an Effect Layer that initializes Sentry for browser clients.\n *\n * On Effect v4 the layer also registers a Sentry `ErrorReporter`, so failures passing through\n * `Effect.withErrorReporting`, `ErrorReporter.report` or the built-in HTTP and RPC boundaries are captured.\n *\n * To enable Effect tracing, logs, or metrics, compose with the respective layers:\n * - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing\n * - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs\n * - `Sentry.SentryEffectMetricsLayer` for metrics\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/effect/client';\n * import { Layer, Logger, LogLevel } from 'effect';\n *\n * const SentryLive = Layer.mergeAll(\n * Sentry.effectLayer({\n * dsn: '__DSN__',\n * integrations: [Sentry.browserTracingIntegration()],\n * tracesSampleRate: 1.0,\n * }),\n * Layer.setTracer(Sentry.SentryEffectTracer),\n * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),\n * );\n * ```\n */\nexport function effectLayer(options: EffectClientLayerOptions): EffectLayer.Layer<never, never, never> {\n return mergeLayer(\n suspendLayer(() => {\n init(options);\n\n return emptyLayer;\n }),\n makeSentryErrorReporterLayer(),\n );\n}\n"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":["mergeLayer","suspendLayer","emptyLayer"],"sources":["../../../src/client/index.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer, merge as mergeLayer, suspend as suspendLayer } from 'effect/Layer';\nimport { makeSentryErrorReporterLayer } from '../errorReporter';\nimport { init } from './sdk';\n\nexport { init } from './sdk';\n\n/**\n * Options for the Sentry Effect client layer.\n */\nexport type EffectClientLayerOptions = BrowserOptions;\n\n/**\n * Creates an Effect Layer that initializes Sentry for browser clients.\n *\n * On Effect v4 the layer also registers a Sentry `ErrorReporter`, so failures passing through\n * `Effect.withErrorReporting`, `ErrorReporter.report` or the built-in HTTP and RPC boundaries are captured.\n *\n * To enable Effect tracing, logs, or metrics, compose with the respective layers:\n * - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing\n * - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs\n * - `Sentry.SentryEffectMetricsLayer` for metrics\n *\n * @example\n * ```typescript\n * import * as Sentry from '@sentry/effect/client';\n * import { Layer, Logger, LogLevel } from 'effect';\n *\n * const SentryLive = Layer.mergeAll(\n * Sentry.effectLayer({\n * dsn: '__DSN__',\n * integrations: [Sentry.browserTracingIntegration()],\n * tracesSampleRate: 1.0,\n * }),\n * Layer.setTracer(Sentry.SentryEffectTracer),\n * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),\n * );\n * ```\n */\nexport function effectLayer(options: EffectClientLayerOptions): EffectLayer.Layer<never, never, never> {\n return mergeLayer(\n suspendLayer(() => {\n init(options);\n\n return emptyLayer;\n }),\n makeSentryErrorReporterLayer(),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,YAAY,SAA2E;CACrG,OAAOA,MACLC,cAAmB;EACjB,KAAK,OAAO;EAEZ,OAAOC;CACT,CAAC,GACD,6BAA6B,CAC/B;AACF"}
|
package/build/esm/client/sdk.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { applySdkMetadata } from "@sentry/core";
|
|
2
|
+
import { init as init$1 } from "@sentry/browser";
|
|
3
|
+
// src/client/sdk.ts
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the Sentry Effect SDK for browser clients.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options for the SDK
|
|
8
|
+
* @returns The initialized Sentry client, or undefined if initialization failed
|
|
9
|
+
*/
|
|
4
10
|
function init(options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
applySdkMetadata(opts, "effect", ["effect", "browser"]);
|
|
9
|
-
return init$1(opts);
|
|
11
|
+
const opts = { ...options };
|
|
12
|
+
applySdkMetadata(opts, "effect", ["effect", "browser"]);
|
|
13
|
+
return init$1(opts);
|
|
10
14
|
}
|
|
11
|
-
|
|
12
15
|
export { init };
|
|
13
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as initBrowser } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n\n/**\n * Initializes the Sentry Effect SDK for browser clients.\n *\n * @param options - Configuration options for the SDK\n * @returns The initialized Sentry client, or undefined if initialization failed\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'effect', ['effect', 'browser']);\n\n return initBrowser(opts);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["initBrowser"],"sources":["../../../src/client/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { init as initBrowser } from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n\n/**\n * Initializes the Sentry Effect SDK for browser clients.\n *\n * @param options - Configuration options for the SDK\n * @returns The initialized Sentry client, or undefined if initialization failed\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'effect', ['effect', 'browser']);\n\n return initBrowser(opts);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,KAAK,SAA6C;CAChE,MAAM,OAAO,EACX,GAAG,QACL;CAEA,iBAAiB,MAAM,UAAU,CAAC,UAAU,SAAS,CAAC;CAEtD,OAAOA,OAAY,IAAI;AACzB"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { makeSentryTracer } from "../tracer.js";
|
|
2
|
+
import { startInactiveSpan } from "@sentry/core/browser";
|
|
3
|
+
// src/client/tracer.ts
|
|
4
|
+
/**
|
|
5
|
+
* Effect `Tracer` that records Effect spans as Sentry spans in browser clients.
|
|
6
|
+
*
|
|
7
|
+
* Wrapped in an arrow rather than passed by reference so the import binding is read per span. That
|
|
8
|
+
* keeps the browser variant substitutable (mocks, bundler interop) exactly as it was when the tracer
|
|
9
|
+
* called it directly.
|
|
10
|
+
*/
|
|
4
11
|
const SentryEffectTracer = makeSentryTracer((options) => startInactiveSpan(options), false);
|
|
5
|
-
|
|
6
12
|
export { SentryEffectTracer };
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=tracer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.js","sources":["../../../src/client/tracer.ts"],"sourcesContent":["import { startInactiveSpan } from '@sentry/core/browser';\nimport { makeSentryTracer } from '../tracer';\n\n/**\n * Effect `Tracer` that records Effect spans as Sentry spans in browser clients.\n *\n * Wrapped in an arrow rather than passed by reference so the import binding is read per span. That\n * keeps the browser variant substitutable (mocks, bundler interop) exactly as it was when the tracer\n * called it directly.\n */\nexport const SentryEffectTracer = makeSentryTracer(options => startInactiveSpan(options), false);\n"],"
|
|
1
|
+
{"version":3,"file":"tracer.js","names":[],"sources":["../../../src/client/tracer.ts"],"sourcesContent":["import { startInactiveSpan } from '@sentry/core/browser';\nimport { makeSentryTracer } from '../tracer';\n\n/**\n * Effect `Tracer` that records Effect spans as Sentry spans in browser clients.\n *\n * Wrapped in an arrow rather than passed by reference so the import binding is read per span. That\n * keeps the browser variant substitutable (mocks, bundler interop) exactly as it was when the tracer\n * called it directly.\n */\nexport const SentryEffectTracer = makeSentryTracer(options => startInactiveSpan(options), false);\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qBAAqB,kBAAiB,YAAW,kBAAkB,OAAO,GAAG,KAAK"}
|
|
@@ -1,63 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const ErrorReporter = effectExports.ErrorReporter;
|
|
1
|
+
import { empty } from "effect/Layer";
|
|
2
|
+
import { captureException, isObjectLike } from "@sentry/core";
|
|
3
|
+
import * as Effect from "effect";
|
|
4
|
+
// src/errorReporter.ts
|
|
5
|
+
const ErrorReporter = Reflect.get(Effect, "ErrorReporter");
|
|
7
6
|
const SEVERITY_TO_LEVEL = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
Fatal: "fatal",
|
|
8
|
+
Error: "error",
|
|
9
|
+
Warn: "warning",
|
|
10
|
+
Info: "info",
|
|
11
|
+
Debug: "debug",
|
|
12
|
+
Trace: "debug"
|
|
14
13
|
};
|
|
15
14
|
function getLevel(errorReporter, error) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return "error";
|
|
15
|
+
if (isObjectLike(error) && errorReporter.severity in error) return SEVERITY_TO_LEVEL[errorReporter.getSeverity(error)];
|
|
16
|
+
return "error";
|
|
20
17
|
}
|
|
21
18
|
function makeSentryErrorReporter(errorReporter) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
19
|
+
const reported = /* @__PURE__ */ new WeakSet();
|
|
20
|
+
return {
|
|
21
|
+
[errorReporter.TypeId]: errorReporter.TypeId,
|
|
22
|
+
report({ cause }) {
|
|
23
|
+
if (reported.has(cause)) return;
|
|
24
|
+
reported.add(cause);
|
|
25
|
+
for (const reason of cause.reasons) {
|
|
26
|
+
if (reason._tag === "Interrupt") continue;
|
|
27
|
+
const error = reason._tag === "Fail" ? reason.error : reason.defect;
|
|
28
|
+
if (isObjectLike(error)) {
|
|
29
|
+
if (reported.has(error)) continue;
|
|
30
|
+
reported.add(error);
|
|
31
|
+
}
|
|
32
|
+
if (errorReporter.isIgnored(error)) continue;
|
|
33
|
+
captureException(error, {
|
|
34
|
+
mechanism: {
|
|
35
|
+
type: "auto.function.effect.error_reporter",
|
|
36
|
+
handled: false
|
|
37
|
+
},
|
|
38
|
+
captureContext: {
|
|
39
|
+
level: getLevel(errorReporter, error),
|
|
40
|
+
extra: isObjectLike(error) ? { ...errorReporter.getAttributes(error) } : void 0
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
54
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Registers a Sentry `ErrorReporter` for `Effect.withErrorReporting`, `ErrorReporter.report` and the
|
|
49
|
+
* built-in HTTP and RPC reporting boundaries. Existing reporters are kept.
|
|
50
|
+
*
|
|
51
|
+
* Effect v3 has no `ErrorReporter` API, so the returned layer is empty there.
|
|
52
|
+
*/
|
|
55
53
|
function makeSentryErrorReporterLayer() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
return ErrorReporter.layer([makeSentryErrorReporter(ErrorReporter)], { mergeWithExisting: true });
|
|
54
|
+
if (!ErrorReporter) return empty;
|
|
55
|
+
return ErrorReporter.layer([makeSentryErrorReporter(ErrorReporter)], { mergeWithExisting: true });
|
|
60
56
|
}
|
|
61
|
-
|
|
62
57
|
export { makeSentryErrorReporterLayer };
|
|
63
|
-
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=errorReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorReporter.js","sources":["../../src/errorReporter.ts"],"sourcesContent":["import type { SeverityLevel } from '@sentry/core';\nimport { captureException, isObjectLike } from '@sentry/core';\nimport * as Effect from 'effect';\nimport type * as Cause from 'effect/Cause';\nimport type * as EffectErrorReporter from 'effect/ErrorReporter';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer } from 'effect/Layer';\nimport type * as LogLevel from 'effect/LogLevel';\n\n// `effect/ErrorReporter` only exists in Effect v4, so it is read off the main entry instead of being imported\n// as a subpath. On Effect v3 the lookup yields `undefined` and no reporter is registered. The property is read\n//
|
|
1
|
+
{"version":3,"file":"errorReporter.js","names":["emptyLayer"],"sources":["../../src/errorReporter.ts"],"sourcesContent":["import type { SeverityLevel } from '@sentry/core';\nimport { captureException, isObjectLike } from '@sentry/core';\nimport * as Effect from 'effect';\nimport type * as Cause from 'effect/Cause';\nimport type * as EffectErrorReporter from 'effect/ErrorReporter';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer } from 'effect/Layer';\nimport type * as LogLevel from 'effect/LogLevel';\n\n// `effect/ErrorReporter` only exists in Effect v4, so it is read off the main entry instead of being imported\n// as a subpath. On Effect v3 the lookup yields `undefined` and no reporter is registered. The property is read\n// with `Reflect.get` because bundlers fail the build on `Effect.ErrorReporter` when the export is absent, and\n// an aliased property read gets folded back into exactly that member access by our own build.\nconst ErrorReporter = Reflect.get(Effect, 'ErrorReporter') as typeof EffectErrorReporter | undefined;\n\nconst SEVERITY_TO_LEVEL: Record<LogLevel.Severity, SeverityLevel> = {\n Fatal: 'fatal',\n Error: 'error',\n Warn: 'warning',\n Info: 'info',\n Debug: 'debug',\n Trace: 'debug',\n};\n\nfunction getLevel(errorReporter: typeof EffectErrorReporter, error: unknown): SeverityLevel {\n // Effect's `getSeverity` falls back to `Info` for unannotated errors, which would file plain failures as\n // informational in Sentry. Only an explicit annotation changes the level.\n if (isObjectLike(error) && errorReporter.severity in error) {\n return SEVERITY_TO_LEVEL[errorReporter.getSeverity(error)];\n }\n return 'error';\n}\n\nfunction makeSentryErrorReporter(errorReporter: typeof EffectErrorReporter): EffectErrorReporter.ErrorReporter {\n const reported = new WeakSet<object>();\n\n return {\n [errorReporter.TypeId]: errorReporter.TypeId,\n report({ cause }: { readonly cause: Cause.Cause<unknown> }): void {\n if (reported.has(cause)) {\n return;\n }\n reported.add(cause);\n\n for (const reason of cause.reasons) {\n if (reason._tag === 'Interrupt') {\n continue;\n }\n\n // The raw error is captured rather than Effect's pretty-printed copy so Sentry sees the original stack,\n // `cause` chain and error class.\n const error = reason._tag === 'Fail' ? reason.error : reason.defect;\n\n if (isObjectLike(error)) {\n if (reported.has(error)) {\n continue;\n }\n reported.add(error);\n }\n\n if (errorReporter.isIgnored(error)) {\n continue;\n }\n\n captureException(error, {\n mechanism: { type: 'auto.function.effect.error_reporter', handled: false },\n captureContext: {\n level: getLevel(errorReporter, error),\n extra: isObjectLike(error) ? { ...errorReporter.getAttributes(error) } : undefined,\n },\n });\n }\n },\n };\n}\n\n/**\n * Registers a Sentry `ErrorReporter` for `Effect.withErrorReporting`, `ErrorReporter.report` and the\n * built-in HTTP and RPC reporting boundaries. Existing reporters are kept.\n *\n * Effect v3 has no `ErrorReporter` API, so the returned layer is empty there.\n */\nexport function makeSentryErrorReporterLayer(): EffectLayer.Layer<never, never, never> {\n if (!ErrorReporter) {\n return emptyLayer;\n }\n\n return ErrorReporter.layer([makeSentryErrorReporter(ErrorReporter)], { mergeWithExisting: true });\n}\n"],"mappings":";;;;AAaA,MAAM,gBAAgB,QAAQ,IAAI,QAAQ,eAAe;AAEzD,MAAM,oBAA8D;CAClE,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;AACT;AAEA,SAAS,SAAS,eAA2C,OAA+B;CAG1F,IAAI,aAAa,KAAK,KAAK,cAAc,YAAY,OACnD,OAAO,kBAAkB,cAAc,YAAY,KAAK;CAE1D,OAAO;AACT;AAEA,SAAS,wBAAwB,eAA8E;CAC7G,MAAM,2BAAW,IAAI,QAAgB;CAErC,OAAO;GACJ,cAAc,SAAS,cAAc;EACtC,OAAO,EAAE,SAAyD;GAChE,IAAI,SAAS,IAAI,KAAK,GACpB;GAEF,SAAS,IAAI,KAAK;GAElB,KAAK,MAAM,UAAU,MAAM,SAAS;IAClC,IAAI,OAAO,SAAS,aAClB;IAKF,MAAM,QAAQ,OAAO,SAAS,SAAS,OAAO,QAAQ,OAAO;IAE7D,IAAI,aAAa,KAAK,GAAG;KACvB,IAAI,SAAS,IAAI,KAAK,GACpB;KAEF,SAAS,IAAI,KAAK;IACpB;IAEA,IAAI,cAAc,UAAU,KAAK,GAC/B;IAGF,iBAAiB,OAAO;KACtB,WAAW;MAAE,MAAM;MAAuC,SAAS;KAAM;KACzE,gBAAgB;MACd,OAAO,SAAS,eAAe,KAAK;MACpC,OAAO,aAAa,KAAK,IAAI,EAAE,GAAG,cAAc,cAAc,KAAK,EAAE,IAAI,KAAA;KAC3E;IACF,CAAC;GACH;EACF;CACF;AACF;;;;;;;AAQA,SAAgB,+BAAuE;CACrF,IAAI,CAAC,eACH,OAAOA;CAGT,OAAO,cAAc,MAAM,CAAC,wBAAwB,aAAa,CAAC,GAAG,EAAE,mBAAmB,KAAK,CAAC;AAClG"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
1
|
+
import { effectLayer } from "./client/index.js";
|
|
2
|
+
import { SentryEffectTracer } from "./client/tracer.js";
|
|
3
|
+
import { SentryEffectExternalSpanLayer } from "./tracer.js";
|
|
4
|
+
import { init } from "./client/sdk.js";
|
|
5
|
+
import { SentryEffectLogger } from "./logger.js";
|
|
6
|
+
import { SentryEffectMetricsLayer } from "./metrics.js";
|
|
7
|
+
export * from "@sentry/browser";
|
|
8
|
+
export { SentryEffectExternalSpanLayer, SentryEffectLogger, SentryEffectMetricsLayer, SentryEffectTracer, effectLayer, init };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
1
|
+
import { init } from "./server/sdk.js";
|
|
2
|
+
import { effectLayer } from "./server/index.js";
|
|
3
|
+
import { SentryEffectTracer } from "./server/tracer.js";
|
|
4
|
+
import { SentryEffectExternalSpanLayer } from "./tracer.js";
|
|
5
|
+
import { SentryEffectLogger } from "./logger.js";
|
|
6
|
+
import { SentryEffectMetricsLayer } from "./metrics.js";
|
|
7
|
+
export * from "@sentry/node";
|
|
8
|
+
export { SentryEffectExternalSpanLayer, SentryEffectLogger, SentryEffectMetricsLayer, SentryEffectTracer, effectLayer, init };
|
package/build/esm/logger.js
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import * as Logger from
|
|
4
|
-
|
|
5
|
-
const LOG_ATTRIBUTES = {
|
|
6
|
-
[SENTRY_ORIGIN]: "auto.log.effect"
|
|
7
|
-
};
|
|
1
|
+
import { isObjectLike, logger } from "@sentry/core";
|
|
2
|
+
import { SENTRY_ORIGIN } from "@sentry/conventions/attributes";
|
|
3
|
+
import * as Logger from "effect/Logger";
|
|
4
|
+
// src/logger.ts
|
|
5
|
+
const LOG_ATTRIBUTES = { [SENTRY_ORIGIN]: "auto.log.effect" };
|
|
8
6
|
function getLogLevelTag(logLevel) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (isObjectLike(logLevel) && "_tag" in logLevel) {
|
|
13
|
-
return logLevel._tag;
|
|
14
|
-
}
|
|
15
|
-
return "Info";
|
|
7
|
+
if (typeof logLevel === "string") return logLevel;
|
|
8
|
+
if (isObjectLike(logLevel) && "_tag" in logLevel) return logLevel._tag;
|
|
9
|
+
return "Info";
|
|
16
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Effect Logger that sends logs to Sentry.
|
|
13
|
+
*/
|
|
17
14
|
const SentryEffectLogger = Logger.make(({ logLevel, message }) => {
|
|
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
|
-
case "Debug":
|
|
44
|
-
logger.debug(msg, LOG_ATTRIBUTES);
|
|
45
|
-
break;
|
|
46
|
-
case "Trace":
|
|
47
|
-
logger.trace(msg, LOG_ATTRIBUTES);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
15
|
+
let msg;
|
|
16
|
+
if (typeof message === "string") msg = message;
|
|
17
|
+
else if (Array.isArray(message) && message.length === 1) {
|
|
18
|
+
const firstElement = message[0];
|
|
19
|
+
msg = typeof firstElement === "string" ? firstElement : JSON.stringify(firstElement);
|
|
20
|
+
} else msg = JSON.stringify(message);
|
|
21
|
+
switch (getLogLevelTag(logLevel)) {
|
|
22
|
+
case "Fatal":
|
|
23
|
+
logger.fatal(msg, LOG_ATTRIBUTES);
|
|
24
|
+
break;
|
|
25
|
+
case "Error":
|
|
26
|
+
logger.error(msg, LOG_ATTRIBUTES);
|
|
27
|
+
break;
|
|
28
|
+
case "Warning":
|
|
29
|
+
case "Warn":
|
|
30
|
+
logger.warn(msg, LOG_ATTRIBUTES);
|
|
31
|
+
break;
|
|
32
|
+
case "Info":
|
|
33
|
+
logger.info(msg, LOG_ATTRIBUTES);
|
|
34
|
+
break;
|
|
35
|
+
case "Debug":
|
|
36
|
+
logger.debug(msg, LOG_ATTRIBUTES);
|
|
37
|
+
break;
|
|
38
|
+
case "Trace": logger.trace(msg, LOG_ATTRIBUTES);
|
|
39
|
+
}
|
|
50
40
|
});
|
|
51
|
-
|
|
52
41
|
export { SentryEffectLogger };
|
|
53
|
-
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=logger.js.map
|
package/build/esm/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../../src/logger.ts"],"sourcesContent":["import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { isObjectLike, logger as sentryLogger } from '@sentry/core';\nimport * as Logger from 'effect/Logger';\nimport type * as LogLevel from 'effect/LogLevel';\n\nconst LOG_ATTRIBUTES = {\n [SENTRY_ORIGIN]: 'auto.log.effect',\n};\n\nfunction getLogLevelTag(logLevel: LogLevel.LogLevel): LogLevel.LogLevel | 'Warning' {\n // Effect v4: logLevel is a string literal directly\n if (typeof logLevel === 'string') {\n return logLevel;\n }\n\n // Effect v3: logLevel has _tag property\n if (isObjectLike(logLevel) && '_tag' in logLevel) {\n return (logLevel as { _tag: LogLevel.LogLevel })._tag;\n }\n\n return 'Info';\n}\n\n/**\n * Effect Logger that sends logs to Sentry.\n */\nexport const SentryEffectLogger = Logger.make(({ logLevel, message }) => {\n let msg: string;\n if (typeof message === 'string') {\n msg = message;\n } else if (Array.isArray(message) && message.length === 1) {\n const firstElement = message[0];\n msg = typeof firstElement === 'string' ? firstElement : JSON.stringify(firstElement);\n } else {\n msg = JSON.stringify(message);\n }\n\n const tag = getLogLevelTag(logLevel);\n\n switch (tag) {\n case 'Fatal':\n sentryLogger.fatal(msg, LOG_ATTRIBUTES);\n break;\n case 'Error':\n sentryLogger.error(msg, LOG_ATTRIBUTES);\n break;\n case 'Warning': // Effect v3\n case 'Warn': // Effect v4\n sentryLogger.warn(msg, LOG_ATTRIBUTES);\n break;\n case 'Info':\n sentryLogger.info(msg, LOG_ATTRIBUTES);\n break;\n case 'Debug':\n sentryLogger.debug(msg, LOG_ATTRIBUTES);\n break;\n case 'Trace':\n sentryLogger.trace(msg, LOG_ATTRIBUTES);\n break;\n case 'All':\n case 'None':\n break;\n default:\n tag satisfies never;\n }\n});\n"],"
|
|
1
|
+
{"version":3,"file":"logger.js","names":["sentryLogger"],"sources":["../../src/logger.ts"],"sourcesContent":["import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { isObjectLike, logger as sentryLogger } from '@sentry/core';\nimport * as Logger from 'effect/Logger';\nimport type * as LogLevel from 'effect/LogLevel';\n\nconst LOG_ATTRIBUTES = {\n [SENTRY_ORIGIN]: 'auto.log.effect',\n};\n\nfunction getLogLevelTag(logLevel: LogLevel.LogLevel): LogLevel.LogLevel | 'Warning' {\n // Effect v4: logLevel is a string literal directly\n if (typeof logLevel === 'string') {\n return logLevel;\n }\n\n // Effect v3: logLevel has _tag property\n if (isObjectLike(logLevel) && '_tag' in logLevel) {\n return (logLevel as { _tag: LogLevel.LogLevel })._tag;\n }\n\n return 'Info';\n}\n\n/**\n * Effect Logger that sends logs to Sentry.\n */\nexport const SentryEffectLogger = Logger.make(({ logLevel, message }) => {\n let msg: string;\n if (typeof message === 'string') {\n msg = message;\n } else if (Array.isArray(message) && message.length === 1) {\n const firstElement = message[0];\n msg = typeof firstElement === 'string' ? firstElement : JSON.stringify(firstElement);\n } else {\n msg = JSON.stringify(message);\n }\n\n const tag = getLogLevelTag(logLevel);\n\n switch (tag) {\n case 'Fatal':\n sentryLogger.fatal(msg, LOG_ATTRIBUTES);\n break;\n case 'Error':\n sentryLogger.error(msg, LOG_ATTRIBUTES);\n break;\n case 'Warning': // Effect v3\n case 'Warn': // Effect v4\n sentryLogger.warn(msg, LOG_ATTRIBUTES);\n break;\n case 'Info':\n sentryLogger.info(msg, LOG_ATTRIBUTES);\n break;\n case 'Debug':\n sentryLogger.debug(msg, LOG_ATTRIBUTES);\n break;\n case 'Trace':\n sentryLogger.trace(msg, LOG_ATTRIBUTES);\n break;\n case 'All':\n case 'None':\n break;\n default:\n tag satisfies never;\n }\n});\n"],"mappings":";;;;AAKA,MAAM,iBAAiB,GACpB,gBAAgB,kBACnB;AAEA,SAAS,eAAe,UAA4D;CAElF,IAAI,OAAO,aAAa,UACtB,OAAO;CAIT,IAAI,aAAa,QAAQ,KAAK,UAAU,UACtC,OAAQ,SAAyC;CAGnD,OAAO;AACT;;;;AAKA,MAAa,qBAAqB,OAAO,MAAM,EAAE,UAAU,cAAc;CACvE,IAAI;CACJ,IAAI,OAAO,YAAY,UACrB,MAAM;MACD,IAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAAG;EACzD,MAAM,eAAe,QAAQ;EAC7B,MAAM,OAAO,iBAAiB,WAAW,eAAe,KAAK,UAAU,YAAY;CACrF,OACE,MAAM,KAAK,UAAU,OAAO;CAK9B,QAFY,eAAe,QAEjB,GAAV;EACE,KAAK;GACHA,OAAa,MAAM,KAAK,cAAc;GACtC;EACF,KAAK;GACHA,OAAa,MAAM,KAAK,cAAc;GACtC;EACF,KAAK;EACL,KAAK;GACHA,OAAa,KAAK,KAAK,cAAc;GACrC;EACF,KAAK;GACHA,OAAa,KAAK,KAAK,cAAc;GACrC;EACF,KAAK;GACHA,OAAa,MAAM,KAAK,cAAc;GACtC;EACF,KAAK,SACHA,OAAa,MAAM,KAAK,cAAc;CAO1C;AACF,CAAC"}
|