@sentry/effect 10.53.1 → 10.55.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.
@@ -3,38 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const Layer = require('effect/Layer');
4
4
  const sdk = require('./sdk.js');
5
5
 
6
- /**
7
- * Options for the Sentry Effect client layer.
8
- */
9
-
10
- /**
11
- * Creates an Effect Layer that initializes Sentry for browser clients.
12
- *
13
- * To enable Effect tracing, logs, or metrics, compose with the respective layers:
14
- * - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing
15
- * - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs
16
- * - `Sentry.SentryEffectMetricsLayer` for metrics
17
- *
18
- * @example
19
- * ```typescript
20
- * import * as Sentry from '@sentry/effect/client';
21
- * import { Layer, Logger, LogLevel } from 'effect';
22
- *
23
- * const SentryLive = Layer.mergeAll(
24
- * Sentry.effectLayer({
25
- * dsn: '__DSN__',
26
- * integrations: [Sentry.browserTracingIntegration()],
27
- * tracesSampleRate: 1.0,
28
- * }),
29
- * Layer.setTracer(Sentry.SentryEffectTracer),
30
- * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
31
- * );
32
- * ```
33
- */
34
6
  function effectLayer(options) {
35
7
  return Layer.suspend(() => {
36
8
  sdk.init(options);
37
-
38
9
  return Layer.empty;
39
10
  });
40
11
  }
@@ -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, suspend as suspendLayer } from 'effect/Layer';\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 * 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 suspendLayer(() => {\n init(options);\n\n return emptyLayer;\n });\n}\n"],"names":["suspendLayer","init","emptyLayer"],"mappings":";;;;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,OAAO,EAAoE;AACvG,EAAE,OAAOA,aAAY,CAAC,MAAM;AAC5B,IAAIC,QAAI,CAAC,OAAO,CAAC;;AAEjB,IAAI,OAAOC,WAAU;AACrB,EAAE,CAAC,CAAC;AACJ;;;;;"}
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, suspend as suspendLayer } from 'effect/Layer';\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 * 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 suspendLayer(() => {\n init(options);\n\n return emptyLayer;\n });\n}\n"],"names":["suspendLayer","init","emptyLayer"],"mappings":";;;;;AAoCO,SAAS,YAAY,OAAA,EAA2E;AACrG,EAAA,OAAOA,cAAa,MAAM;AACxB,IAAAC,QAAA,CAAK,OAAO,CAAA;AAEZ,IAAA,OAAOC,WAAA;AAAA,EACT,CAAC,CAAA;AACH;;;;;"}
@@ -3,19 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const browser = require('@sentry/browser');
4
4
  const core = require('@sentry/core');
5
5
 
6
- /**
7
- * Initializes the Sentry Effect SDK for browser clients.
8
- *
9
- * @param options - Configuration options for the SDK
10
- * @returns The initialized Sentry client, or undefined if initialization failed
11
- */
12
6
  function init(options) {
13
7
  const opts = {
14
- ...options,
8
+ ...options
15
9
  };
16
-
17
- core.applySdkMetadata(opts, 'effect', ['effect', 'browser']);
18
-
10
+ core.applySdkMetadata(opts, "effect", ["effect", "browser"]);
19
11
  return browser.init(opts);
20
12
  }
21
13
 
@@ -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"],"names":["applySdkMetadata","initBrowser"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;;AAEzD,EAAE,OAAOC,YAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
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"],"names":["applySdkMetadata","initBrowser"],"mappings":";;;;;AAWO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,IAAA,EAAM,QAAA,EAAU,CAAC,QAAA,EAAU,SAAS,CAAC,CAAA;AAEtD,EAAA,OAAOC,aAAY,IAAI,CAAA;AACzB;;;;"}
@@ -4,53 +4,44 @@ const core = require('@sentry/core');
4
4
  const Logger = require('effect/Logger');
5
5
 
6
6
  function getLogLevelTag(logLevel) {
7
- // Effect v4: logLevel is a string literal directly
8
- if (typeof logLevel === 'string') {
7
+ if (typeof logLevel === "string") {
9
8
  return logLevel;
10
9
  }
11
-
12
- // Effect v3: logLevel has _tag property
13
- if (logLevel && typeof logLevel === 'object' && '_tag' in logLevel) {
14
- return (logLevel )._tag;
10
+ if (logLevel && typeof logLevel === "object" && "_tag" in logLevel) {
11
+ return logLevel._tag;
15
12
  }
16
-
17
- return 'Info';
13
+ return "Info";
18
14
  }
19
-
20
- /**
21
- * Effect Logger that sends logs to Sentry.
22
- */
23
15
  const SentryEffectLogger = Logger.make(({ logLevel, message }) => {
24
16
  let msg;
25
- if (typeof message === 'string') {
17
+ if (typeof message === "string") {
26
18
  msg = message;
27
19
  } else if (Array.isArray(message) && message.length === 1) {
28
20
  const firstElement = message[0];
29
- msg = typeof firstElement === 'string' ? firstElement : JSON.stringify(firstElement);
21
+ msg = typeof firstElement === "string" ? firstElement : JSON.stringify(firstElement);
30
22
  } else {
31
23
  msg = JSON.stringify(message);
32
24
  }
33
-
34
25
  const tag = getLogLevelTag(logLevel);
35
-
36
26
  switch (tag) {
37
- case 'Fatal':
27
+ case "Fatal":
38
28
  core.logger.fatal(msg);
39
29
  break;
40
- case 'Error':
30
+ case "Error":
41
31
  core.logger.error(msg);
42
32
  break;
43
- case 'Warning': // Effect v3
44
- case 'Warn': // Effect v4
33
+ case "Warning":
34
+ // Effect v3
35
+ case "Warn":
45
36
  core.logger.warn(msg);
46
37
  break;
47
- case 'Info':
38
+ case "Info":
48
39
  core.logger.info(msg);
49
40
  break;
50
- case 'Debug':
41
+ case "Debug":
51
42
  core.logger.debug(msg);
52
43
  break;
53
- case 'Trace':
44
+ case "Trace":
54
45
  core.logger.trace(msg);
55
46
  break;
56
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sources":["../../src/logger.ts"],"sourcesContent":["import { logger as sentryLogger } from '@sentry/core';\nimport * as Logger from 'effect/Logger';\nimport type * as LogLevel from 'effect/LogLevel';\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 (logLevel && typeof logLevel === 'object' && '_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);\n break;\n case 'Error':\n sentryLogger.error(msg);\n break;\n case 'Warning': // Effect v3\n case 'Warn': // Effect v4\n sentryLogger.warn(msg);\n break;\n case 'Info':\n sentryLogger.info(msg);\n break;\n case 'Debug':\n sentryLogger.debug(msg);\n break;\n case 'Trace':\n sentryLogger.trace(msg);\n break;\n case 'All':\n case 'None':\n break;\n default:\n tag satisfies never;\n }\n});\n"],"names":["sentryLogger"],"mappings":";;;;;AAIA,SAAS,cAAc,CAAC,QAAQ,EAAoD;AACpF;AACA,EAAE,IAAI,OAAO,QAAA,KAAa,QAAQ,EAAE;AACpC,IAAI,OAAO,QAAQ;AACnB,EAAE;;AAEF;AACA,EAAE,IAAI,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA,IAAY,MAAA,IAAU,QAAQ,EAAE;AACtE,IAAI,OAAO,CAAC,QAAA,GAAyC,IAAI;AACzD,EAAE;;AAEF,EAAE,OAAO,MAAM;AACf;;AAEA;AACA;AACA;AACO,MAAM,kBAAA,GAAqB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAA,EAAS,KAAK;AACzE,EAAE,IAAI,GAAG;AACT,EAAE,IAAI,OAAO,OAAA,KAAY,QAAQ,EAAE;AACnC,IAAI,GAAA,GAAM,OAAO;AACjB,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA,IAAK,OAAO,CAAC,MAAA,KAAW,CAAC,EAAE;AAC7D,IAAI,MAAM,YAAA,GAAe,OAAO,CAAC,CAAC,CAAC;AACnC,IAAI,GAAA,GAAM,OAAO,YAAA,KAAiB,QAAA,GAAW,YAAA,GAAe,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;AACxF,EAAE,OAAO;AACT,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AACjC,EAAE;;AAEF,EAAE,MAAM,GAAA,GAAM,cAAc,CAAC,QAAQ,CAAC;;AAEtC,EAAE,QAAQ,GAAG;AACb,IAAI,KAAK,OAAO;AAChB,MAAMA,WAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AAC7B,MAAM;AACN,IAAI,KAAK,OAAO;AAChB,MAAMA,WAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AAC7B,MAAM;AACN,IAAI,KAAK,SAAS,CAAA;AAClB,IAAI,KAAK,MAAM;AACf,MAAMA,WAAY,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5B,MAAM;AACN,IAAI,KAAK,MAAM;AACf,MAAMA,WAAY,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5B,MAAM;AACN,IAAI,KAAK,OAAO;AAChB,MAAMA,WAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AAC7B,MAAM;AACN,IAAI,KAAK,OAAO;AAChB,MAAMA,WAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AAC7B,MAAM;AAMN;AACA,CAAC;;;;"}
1
+ {"version":3,"file":"logger.js","sources":["../../src/logger.ts"],"sourcesContent":["import { logger as sentryLogger } from '@sentry/core';\nimport * as Logger from 'effect/Logger';\nimport type * as LogLevel from 'effect/LogLevel';\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 (logLevel && typeof logLevel === 'object' && '_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);\n break;\n case 'Error':\n sentryLogger.error(msg);\n break;\n case 'Warning': // Effect v3\n case 'Warn': // Effect v4\n sentryLogger.warn(msg);\n break;\n case 'Info':\n sentryLogger.info(msg);\n break;\n case 'Debug':\n sentryLogger.debug(msg);\n break;\n case 'Trace':\n sentryLogger.trace(msg);\n break;\n case 'All':\n case 'None':\n break;\n default:\n tag satisfies never;\n }\n});\n"],"names":["sentryLogger"],"mappings":";;;;;AAIA,SAAS,eAAe,QAAA,EAA4D;AAElF,EAAA,IAAI,OAAO,aAAa,QAAA,EAAU;AAChC,IAAA,OAAO,QAAA;AAAA,EACT;AAGA,EAAA,IAAI,QAAA,IAAY,OAAO,QAAA,KAAa,QAAA,IAAY,UAAU,QAAA,EAAU;AAClE,IAAA,OAAQ,QAAA,CAAyC,IAAA;AAAA,EACnD;AAEA,EAAA,OAAO,MAAA;AACT;AAKO,MAAM,qBAAqB,MAAA,CAAO,IAAA,CAAK,CAAC,EAAE,QAAA,EAAU,SAAQ,KAAM;AACvE,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAC/B,IAAA,GAAA,GAAM,OAAA;AAAA,EACR,WAAW,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,IAAK,OAAA,CAAQ,WAAW,CAAA,EAAG;AACzD,IAAA,MAAM,YAAA,GAAe,QAAQ,CAAC,CAAA;AAC9B,IAAA,GAAA,GAAM,OAAO,YAAA,KAAiB,QAAA,GAAW,YAAA,GAAe,IAAA,CAAK,UAAU,YAAY,CAAA;AAAA,EACrF,CAAA,MAAO;AACL,IAAA,GAAA,GAAM,IAAA,CAAK,UAAU,OAAO,CAAA;AAAA,EAC9B;AAEA,EAAA,MAAM,GAAA,GAAM,eAAe,QAAQ,CAAA;AAEnC,EAAA,QAAQ,GAAA;AAAK,IACX,KAAK,OAAA;AACH,MAAAA,WAAA,CAAa,MAAM,GAAG,CAAA;AACtB,MAAA;AAAA,IACF,KAAK,OAAA;AACH,MAAAA,WAAA,CAAa,MAAM,GAAG,CAAA;AACtB,MAAA;AAAA,IACF,KAAK,SAAA;AAAA;AAAA,IACL,KAAK,MAAA;AACH,MAAAA,WAAA,CAAa,KAAK,GAAG,CAAA;AACrB,MAAA;AAAA,IACF,KAAK,MAAA;AACH,MAAAA,WAAA,CAAa,KAAK,GAAG,CAAA;AACrB,MAAA;AAAA,IACF,KAAK,OAAA;AACH,MAAAA,WAAA,CAAa,MAAM,GAAG,CAAA;AACtB,MAAA;AAAA,IACF,KAAK,OAAA;AACH,MAAAA,WAAA,CAAa,MAAM,GAAG,CAAA;AACtB,MAAA;AAKA;AAEN,CAAC;;;;"}
@@ -7,164 +7,124 @@ const Layer = require('effect/Layer');
7
7
  const Metric = require('effect/Metric');
8
8
  const Schedule = require('effect/Schedule');
9
9
 
10
- // Effect v3 `MetricState` implementations brand themselves with a `Symbol.for(...)` TypeId
11
- // rather than a string `_tag`. We use these globally-registered symbols to classify state
12
- // instances returned by `Metric.unsafeSnapshot()` without importing `effect/MetricState`
13
- // (the module does not exist in Effect v4).
14
- const V3_COUNTER_STATE_TYPE_ID = Symbol.for('effect/MetricState/Counter');
15
- const V3_GAUGE_STATE_TYPE_ID = Symbol.for('effect/MetricState/Gauge');
16
- const V3_HISTOGRAM_STATE_TYPE_ID = Symbol.for('effect/MetricState/Histogram');
17
- const V3_SUMMARY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Summary');
18
- const V3_FREQUENCY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Frequency');
19
-
10
+ const V3_COUNTER_STATE_TYPE_ID = /* @__PURE__ */ Symbol.for("effect/MetricState/Counter");
11
+ const V3_GAUGE_STATE_TYPE_ID = /* @__PURE__ */ Symbol.for("effect/MetricState/Gauge");
12
+ const V3_HISTOGRAM_STATE_TYPE_ID = /* @__PURE__ */ Symbol.for("effect/MetricState/Histogram");
13
+ const V3_SUMMARY_STATE_TYPE_ID = /* @__PURE__ */ Symbol.for("effect/MetricState/Summary");
14
+ const V3_FREQUENCY_STATE_TYPE_ID = /* @__PURE__ */ Symbol.for("effect/MetricState/Frequency");
20
15
  function labelsToAttributes(labels) {
21
16
  return labels.reduce((acc, label) => ({ ...acc, [label.key]: label.value }), {});
22
17
  }
23
-
24
18
  function getMetricIdV3(pair) {
25
- const tags = pair.metricKey.tags.map(t => `${t.key}=${t.value}`).join(',');
19
+ const tags = pair.metricKey.tags.map((t) => `${t.key}=${t.value}`).join(",");
26
20
  return `${pair.metricKey.name}:${tags}`;
27
21
  }
28
-
29
22
  function getMetricIdV4(snapshot) {
30
- const attrs = snapshot.attributes
31
- ? Object.entries(snapshot.attributes)
32
- .map(([k, v]) => `${k}=${v}`)
33
- .join(',')
34
- : '';
23
+ const attrs = snapshot.attributes ? Object.entries(snapshot.attributes).map(([k, v]) => `${k}=${v}`).join(",") : "";
35
24
  return `${snapshot.id}:${attrs}`;
36
25
  }
37
-
38
26
  function sendV3MetricToSentry(pair, previousCounterValues) {
39
27
  const { metricKey, metricState } = pair;
40
28
  const name = metricKey.name;
41
29
  const attributes = labelsToAttributes(metricKey.tags);
42
30
  const metricId = getMetricIdV3(pair);
43
-
44
- const state = metricState ;
45
-
46
- if (state[V3_COUNTER_STATE_TYPE_ID] !== undefined) {
31
+ const state = metricState;
32
+ if (state[V3_COUNTER_STATE_TYPE_ID] !== void 0) {
47
33
  const currentValue = Number(metricState.count);
48
34
  const previousValue = previousCounterValues.get(metricId) ?? 0;
49
35
  const delta = currentValue - previousValue;
50
-
51
36
  if (delta > 0) {
52
37
  core.metrics.count(name, delta, { attributes });
53
38
  }
54
-
55
39
  previousCounterValues.set(metricId, currentValue);
56
- } else if (state[V3_GAUGE_STATE_TYPE_ID] !== undefined) {
40
+ } else if (state[V3_GAUGE_STATE_TYPE_ID] !== void 0) {
57
41
  const value = Number(metricState.value);
58
42
  core.metrics.gauge(name, value, { attributes });
59
- } else if (state[V3_HISTOGRAM_STATE_TYPE_ID] !== undefined || state[V3_SUMMARY_STATE_TYPE_ID] !== undefined) {
43
+ } else if (state[V3_HISTOGRAM_STATE_TYPE_ID] !== void 0 || state[V3_SUMMARY_STATE_TYPE_ID] !== void 0) {
60
44
  core.metrics.gauge(`${name}.sum`, metricState.sum ?? 0, { attributes });
61
45
  core.metrics.gauge(`${name}.count`, Number(metricState.count ?? 0), { attributes });
62
46
  core.metrics.gauge(`${name}.min`, metricState.min ?? 0, { attributes });
63
47
  core.metrics.gauge(`${name}.max`, metricState.max ?? 0, { attributes });
64
- } else if (state[V3_FREQUENCY_STATE_TYPE_ID] !== undefined && metricState.occurrences) {
48
+ } else if (state[V3_FREQUENCY_STATE_TYPE_ID] !== void 0 && metricState.occurrences) {
65
49
  for (const [word, count] of metricState.occurrences) {
66
50
  core.metrics.count(name, count, {
67
- attributes: { ...attributes, word },
51
+ attributes: { ...attributes, word }
68
52
  });
69
53
  }
70
54
  }
71
55
  }
72
-
73
56
  function sendV4MetricToSentry(snapshot, previousCounterValues) {
74
57
  const name = snapshot.id;
75
58
  const attributes = snapshot.attributes ? { ...snapshot.attributes } : {};
76
59
  const metricId = getMetricIdV4(snapshot);
77
-
78
60
  switch (snapshot.type) {
79
- case 'Counter': {
61
+ case "Counter": {
80
62
  const currentValue = Number(snapshot.state.count);
81
63
  const previousValue = previousCounterValues.get(metricId) ?? 0;
82
64
  const delta = currentValue - previousValue;
83
-
84
65
  if (delta > 0) {
85
66
  core.metrics.count(name, delta, { attributes });
86
67
  }
87
-
88
68
  previousCounterValues.set(metricId, currentValue);
89
69
  break;
90
70
  }
91
- case 'Gauge': {
71
+ case "Gauge": {
92
72
  const value = Number(snapshot.state.value);
93
73
  core.metrics.gauge(name, value, { attributes });
94
74
  break;
95
75
  }
96
- case 'Histogram':
97
- case 'Summary': {
76
+ case "Histogram":
77
+ case "Summary": {
98
78
  core.metrics.gauge(`${name}.sum`, snapshot.state.sum ?? 0, { attributes });
99
79
  core.metrics.gauge(`${name}.count`, snapshot.state.count ?? 0, { attributes });
100
80
  core.metrics.gauge(`${name}.min`, snapshot.state.min ?? 0, { attributes });
101
81
  core.metrics.gauge(`${name}.max`, snapshot.state.max ?? 0, { attributes });
102
82
  break;
103
83
  }
104
- case 'Frequency': {
84
+ case "Frequency": {
105
85
  for (const [word, count] of snapshot.state.occurrences) {
106
86
  core.metrics.count(name, count, {
107
- attributes: { ...attributes, word },
87
+ attributes: { ...attributes, word }
108
88
  });
109
89
  }
110
90
  break;
111
91
  }
112
92
  }
113
93
  }
114
-
115
- // =============================================================================
116
- // Effect v3 snapshot function type (vendored - not exported from effect@3.x)
117
- // =============================================================================
118
-
119
- // Use bracket notation to avoid Webpack static analysis flagging missing exports
120
- // This is important for Effect v3 compatibility.
121
94
  const MetricModule = Metric;
122
- const snapshotUnsafe = MetricModule['snapshotUnsafe'] ;
123
- // @ts-expect-error - unsafeSnapshot is not exported from effect@3.x
124
- const unsafeSnapshot = MetricModule['unsafeSnapshot'] ;
125
-
95
+ const snapshotUnsafe = MetricModule["snapshotUnsafe"];
96
+ const unsafeSnapshot = MetricModule["unsafeSnapshot"];
126
97
  function flushMetricsToSentry(previousCounterValues) {
127
98
  if (snapshotUnsafe) {
128
- // Effect v4
129
99
  const snapshots = snapshotUnsafe(Context.empty());
130
100
  for (const snapshot of snapshots) {
131
101
  sendV4MetricToSentry(snapshot, previousCounterValues);
132
102
  }
133
103
  } else if (unsafeSnapshot) {
134
- // Effect v3
135
104
  const snapshots = unsafeSnapshot();
136
105
  for (const pair of snapshots) {
137
106
  sendV3MetricToSentry(pair, previousCounterValues);
138
107
  }
139
108
  }
140
109
  }
141
-
142
110
  function createMetricsReporterEffect(previousCounterValues) {
143
- const schedule = Schedule.spaced('10 seconds');
144
-
111
+ const schedule = Schedule.spaced("10 seconds");
145
112
  return Effect.repeat(
146
113
  Effect.sync(() => flushMetricsToSentry(previousCounterValues)),
147
- schedule,
114
+ schedule
148
115
  ).pipe(Effect.asVoid, Effect.interruptible);
149
116
  }
150
-
151
- /**
152
- * Effect Layer that periodically flushes metrics to Sentry.
153
- * The layer manages its own state for delta counter calculations,
154
- * which is automatically cleaned up when the layer is finalized.
155
- */
156
117
  const SentryEffectMetricsLayer = Layer.effectDiscard(
157
118
  Effect.gen(function* () {
158
- const previousCounterValues = new Map();
159
-
160
- yield* Effect.acquireRelease(Effect.void, () =>
161
- Effect.sync(() => {
119
+ const previousCounterValues = /* @__PURE__ */ new Map();
120
+ yield* Effect.acquireRelease(
121
+ Effect.void,
122
+ () => Effect.sync(() => {
162
123
  previousCounterValues.clear();
163
- }),
124
+ })
164
125
  );
165
-
166
126
  yield* Effect.forkScoped(createMetricsReporterEffect(previousCounterValues));
167
- }),
127
+ })
168
128
  );
169
129
 
170
130
  exports.SentryEffectMetricsLayer = SentryEffectMetricsLayer;
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.js","sources":["../../src/metrics.ts"],"sourcesContent":["import { metrics as sentryMetrics } from '@sentry/core';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Metric from 'effect/Metric';\nimport * as Schedule from 'effect/Schedule';\n\ntype MetricAttributes = Record<string, string>;\n\n// =============================================================================\n// Effect v3 Types (vendored - not exported from effect@3.x)\n// =============================================================================\n\ninterface V3MetricLabel {\n key: string;\n value: string;\n}\n\ninterface V3MetricPair {\n metricKey: {\n name: string;\n tags: ReadonlyArray<V3MetricLabel>;\n keyType: { _tag: string };\n };\n metricState: {\n count?: number | bigint;\n value?: number;\n sum?: number;\n min?: number;\n max?: number;\n occurrences?: Map<string, number>;\n };\n}\n\n// Effect v3 `MetricState` implementations brand themselves with a `Symbol.for(...)` TypeId\n// rather than a string `_tag`. We use these globally-registered symbols to classify state\n// instances returned by `Metric.unsafeSnapshot()` without importing `effect/MetricState`\n// (the module does not exist in Effect v4).\nconst V3_COUNTER_STATE_TYPE_ID = Symbol.for('effect/MetricState/Counter');\nconst V3_GAUGE_STATE_TYPE_ID = Symbol.for('effect/MetricState/Gauge');\nconst V3_HISTOGRAM_STATE_TYPE_ID = Symbol.for('effect/MetricState/Histogram');\nconst V3_SUMMARY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Summary');\nconst V3_FREQUENCY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Frequency');\n\nfunction labelsToAttributes(labels: ReadonlyArray<V3MetricLabel>): MetricAttributes {\n return labels.reduce((acc, label) => ({ ...acc, [label.key]: label.value }), {});\n}\n\nfunction getMetricIdV3(pair: V3MetricPair): string {\n const tags = pair.metricKey.tags.map(t => `${t.key}=${t.value}`).join(',');\n return `${pair.metricKey.name}:${tags}`;\n}\n\nfunction getMetricIdV4(snapshot: Metric.Metric.Snapshot): string {\n const attrs = snapshot.attributes\n ? Object.entries(snapshot.attributes)\n .map(([k, v]) => `${k}=${v}`)\n .join(',')\n : '';\n return `${snapshot.id}:${attrs}`;\n}\n\nfunction sendV3MetricToSentry(pair: V3MetricPair, previousCounterValues: Map<string, number>): void {\n const { metricKey, metricState } = pair;\n const name = metricKey.name;\n const attributes = labelsToAttributes(metricKey.tags);\n const metricId = getMetricIdV3(pair);\n\n const state = metricState as unknown as Record<symbol, unknown>;\n\n if (state[V3_COUNTER_STATE_TYPE_ID] !== undefined) {\n const currentValue = Number(metricState.count);\n const previousValue = previousCounterValues.get(metricId) ?? 0;\n const delta = currentValue - previousValue;\n\n if (delta > 0) {\n sentryMetrics.count(name, delta, { attributes });\n }\n\n previousCounterValues.set(metricId, currentValue);\n } else if (state[V3_GAUGE_STATE_TYPE_ID] !== undefined) {\n const value = Number(metricState.value);\n sentryMetrics.gauge(name, value, { attributes });\n } else if (state[V3_HISTOGRAM_STATE_TYPE_ID] !== undefined || state[V3_SUMMARY_STATE_TYPE_ID] !== undefined) {\n sentryMetrics.gauge(`${name}.sum`, metricState.sum ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.count`, Number(metricState.count ?? 0), { attributes });\n sentryMetrics.gauge(`${name}.min`, metricState.min ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.max`, metricState.max ?? 0, { attributes });\n } else if (state[V3_FREQUENCY_STATE_TYPE_ID] !== undefined && metricState.occurrences) {\n for (const [word, count] of metricState.occurrences) {\n sentryMetrics.count(name, count, {\n attributes: { ...attributes, word },\n });\n }\n }\n}\n\nfunction sendV4MetricToSentry(snapshot: Metric.Metric.Snapshot, previousCounterValues: Map<string, number>): void {\n const name = snapshot.id;\n const attributes: MetricAttributes = snapshot.attributes ? { ...snapshot.attributes } : {};\n const metricId = getMetricIdV4(snapshot);\n\n switch (snapshot.type) {\n case 'Counter': {\n const currentValue = Number(snapshot.state.count);\n const previousValue = previousCounterValues.get(metricId) ?? 0;\n const delta = currentValue - previousValue;\n\n if (delta > 0) {\n sentryMetrics.count(name, delta, { attributes });\n }\n\n previousCounterValues.set(metricId, currentValue);\n break;\n }\n case 'Gauge': {\n const value = Number(snapshot.state.value);\n sentryMetrics.gauge(name, value, { attributes });\n break;\n }\n case 'Histogram':\n case 'Summary': {\n sentryMetrics.gauge(`${name}.sum`, snapshot.state.sum ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.count`, snapshot.state.count ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.min`, snapshot.state.min ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.max`, snapshot.state.max ?? 0, { attributes });\n break;\n }\n case 'Frequency': {\n for (const [word, count] of snapshot.state.occurrences) {\n sentryMetrics.count(name, count, {\n attributes: { ...attributes, word },\n });\n }\n break;\n }\n }\n}\n\n// =============================================================================\n// Effect v3 snapshot function type (vendored - not exported from effect@3.x)\n// =============================================================================\n\ntype V3UnsafeSnapshotFn = () => ReadonlyArray<V3MetricPair>;\n\n// Use bracket notation to avoid Webpack static analysis flagging missing exports\n// This is important for Effect v3 compatibility.\nconst MetricModule = Metric;\nconst snapshotUnsafe = MetricModule['snapshotUnsafe'] as typeof Metric.snapshotUnsafe | undefined;\n// @ts-expect-error - unsafeSnapshot is not exported from effect@3.x\nconst unsafeSnapshot = MetricModule['unsafeSnapshot'] as V3UnsafeSnapshotFn | undefined;\n\nfunction flushMetricsToSentry(previousCounterValues: Map<string, number>): void {\n if (snapshotUnsafe) {\n // Effect v4\n const snapshots = snapshotUnsafe(Context.empty());\n for (const snapshot of snapshots) {\n sendV4MetricToSentry(snapshot, previousCounterValues);\n }\n } else if (unsafeSnapshot) {\n // Effect v3\n const snapshots = unsafeSnapshot();\n for (const pair of snapshots) {\n sendV3MetricToSentry(pair, previousCounterValues);\n }\n }\n}\n\nfunction createMetricsReporterEffect(previousCounterValues: Map<string, number>): Effect.Effect<void, never, never> {\n const schedule = Schedule.spaced('10 seconds');\n\n return Effect.repeat(\n Effect.sync(() => flushMetricsToSentry(previousCounterValues)),\n schedule,\n ).pipe(Effect.asVoid, Effect.interruptible);\n}\n\n/**\n * Effect Layer that periodically flushes metrics to Sentry.\n * The layer manages its own state for delta counter calculations,\n * which is automatically cleaned up when the layer is finalized.\n */\nexport const SentryEffectMetricsLayer: Layer.Layer<never, never, never> = Layer.effectDiscard(\n Effect.gen(function* () {\n const previousCounterValues = new Map<string, number>();\n\n yield* Effect.acquireRelease(Effect.void, () =>\n Effect.sync(() => {\n previousCounterVal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IAAA,QAAA;AACA,GAAA,CAAA,IAAA,CAAA,MAAA,CAAA,MAAA,EAAA,MAAA,CAAA,aAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAA,wBAAA,GAAA,KAAA,CAAA,aAAA;AACA,EAAA,MAAA,CAAA,GAAA,CAAA,aAAA;AACA,IAAA,MAAA,qBAAA,GAAA,IAAA,GAAA,EAAA;;AAEA,IAAA,OAAA,MAAA,CAAA,cAAA,CAAA,MAAA,CAAA,IAAA,EAAA;AACA,MAAA,MAAA,CAAA,IAAA,CAAA,MAAA;AACA,QAAA,qBAAA,CAAA,KAAA,EAAA;AACA,MAAA,CAAA,CAAA;AACA,KAAA;;AAEA,IAAA,OAAA,MAAA,CAAA,UAAA,CAAA,2BAAA,CAAA,qBAAA,CAAA,CAAA;AACA,EAAA,CAAA,CAAA;AACA;;;;"}
1
+ {"version":3,"file":"metrics.js","sources":["../../src/metrics.ts"],"sourcesContent":["import { metrics as sentryMetrics } from '@sentry/core';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Metric from 'effect/Metric';\nimport * as Schedule from 'effect/Schedule';\n\ntype MetricAttributes = Record<string, string>;\n\n// =============================================================================\n// Effect v3 Types (vendored - not exported from effect@3.x)\n// =============================================================================\n\ninterface V3MetricLabel {\n key: string;\n value: string;\n}\n\ninterface V3MetricPair {\n metricKey: {\n name: string;\n tags: ReadonlyArray<V3MetricLabel>;\n keyType: { _tag: string };\n };\n metricState: {\n count?: number | bigint;\n value?: number;\n sum?: number;\n min?: number;\n max?: number;\n occurrences?: Map<string, number>;\n };\n}\n\n// Effect v3 `MetricState` implementations brand themselves with a `Symbol.for(...)` TypeId\n// rather than a string `_tag`. We use these globally-registered symbols to classify state\n// instances returned by `Metric.unsafeSnapshot()` without importing `effect/MetricState`\n// (the module does not exist in Effect v4).\nconst V3_COUNTER_STATE_TYPE_ID = Symbol.for('effect/MetricState/Counter');\nconst V3_GAUGE_STATE_TYPE_ID = Symbol.for('effect/MetricState/Gauge');\nconst V3_HISTOGRAM_STATE_TYPE_ID = Symbol.for('effect/MetricState/Histogram');\nconst V3_SUMMARY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Summary');\nconst V3_FREQUENCY_STATE_TYPE_ID = Symbol.for('effect/MetricState/Frequency');\n\nfunction labelsToAttributes(labels: ReadonlyArray<V3MetricLabel>): MetricAttributes {\n return labels.reduce((acc, label) => ({ ...acc, [label.key]: label.value }), {});\n}\n\nfunction getMetricIdV3(pair: V3MetricPair): string {\n const tags = pair.metricKey.tags.map(t => `${t.key}=${t.value}`).join(',');\n return `${pair.metricKey.name}:${tags}`;\n}\n\nfunction getMetricIdV4(snapshot: Metric.Metric.Snapshot): string {\n const attrs = snapshot.attributes\n ? Object.entries(snapshot.attributes)\n .map(([k, v]) => `${k}=${v}`)\n .join(',')\n : '';\n return `${snapshot.id}:${attrs}`;\n}\n\nfunction sendV3MetricToSentry(pair: V3MetricPair, previousCounterValues: Map<string, number>): void {\n const { metricKey, metricState } = pair;\n const name = metricKey.name;\n const attributes = labelsToAttributes(metricKey.tags);\n const metricId = getMetricIdV3(pair);\n\n const state = metricState as unknown as Record<symbol, unknown>;\n\n if (state[V3_COUNTER_STATE_TYPE_ID] !== undefined) {\n const currentValue = Number(metricState.count);\n const previousValue = previousCounterValues.get(metricId) ?? 0;\n const delta = currentValue - previousValue;\n\n if (delta > 0) {\n sentryMetrics.count(name, delta, { attributes });\n }\n\n previousCounterValues.set(metricId, currentValue);\n } else if (state[V3_GAUGE_STATE_TYPE_ID] !== undefined) {\n const value = Number(metricState.value);\n sentryMetrics.gauge(name, value, { attributes });\n } else if (state[V3_HISTOGRAM_STATE_TYPE_ID] !== undefined || state[V3_SUMMARY_STATE_TYPE_ID] !== undefined) {\n sentryMetrics.gauge(`${name}.sum`, metricState.sum ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.count`, Number(metricState.count ?? 0), { attributes });\n sentryMetrics.gauge(`${name}.min`, metricState.min ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.max`, metricState.max ?? 0, { attributes });\n } else if (state[V3_FREQUENCY_STATE_TYPE_ID] !== undefined && metricState.occurrences) {\n for (const [word, count] of metricState.occurrences) {\n sentryMetrics.count(name, count, {\n attributes: { ...attributes, word },\n });\n }\n }\n}\n\nfunction sendV4MetricToSentry(snapshot: Metric.Metric.Snapshot, previousCounterValues: Map<string, number>): void {\n const name = snapshot.id;\n const attributes: MetricAttributes = snapshot.attributes ? { ...snapshot.attributes } : {};\n const metricId = getMetricIdV4(snapshot);\n\n switch (snapshot.type) {\n case 'Counter': {\n const currentValue = Number(snapshot.state.count);\n const previousValue = previousCounterValues.get(metricId) ?? 0;\n const delta = currentValue - previousValue;\n\n if (delta > 0) {\n sentryMetrics.count(name, delta, { attributes });\n }\n\n previousCounterValues.set(metricId, currentValue);\n break;\n }\n case 'Gauge': {\n const value = Number(snapshot.state.value);\n sentryMetrics.gauge(name, value, { attributes });\n break;\n }\n case 'Histogram':\n case 'Summary': {\n sentryMetrics.gauge(`${name}.sum`, snapshot.state.sum ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.count`, snapshot.state.count ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.min`, snapshot.state.min ?? 0, { attributes });\n sentryMetrics.gauge(`${name}.max`, snapshot.state.max ?? 0, { attributes });\n break;\n }\n case 'Frequency': {\n for (const [word, count] of snapshot.state.occurrences) {\n sentryMetrics.count(name, count, {\n attributes: { ...attributes, word },\n });\n }\n break;\n }\n }\n}\n\n// =============================================================================\n// Effect v3 snapshot function type (vendored - not exported from effect@3.x)\n// =============================================================================\n\ntype V3UnsafeSnapshotFn = () => ReadonlyArray<V3MetricPair>;\n\n// Use bracket notation to avoid Webpack static analysis flagging missing exports\n// This is important for Effect v3 compatibility.\nconst MetricModule = Metric;\nconst snapshotUnsafe = MetricModule['snapshotUnsafe'] as typeof Metric.snapshotUnsafe | undefined;\n// @ts-expect-error - unsafeSnapshot is not exported from effect@3.x\nconst unsafeSnapshot = MetricModule['unsafeSnapshot'] as V3UnsafeSnapshotFn | undefined;\n\nfunction flushMetricsToSentry(previousCounterValues: Map<string, number>): void {\n if (snapshotUnsafe) {\n // Effect v4\n const snapshots = snapshotUnsafe(Context.empty());\n for (const snapshot of snapshots) {\n sendV4MetricToSentry(snapshot, previousCounterValues);\n }\n } else if (unsafeSnapshot) {\n // Effect v3\n const snapshots = unsafeSnapshot();\n for (const pair of snapshots) {\n sendV3MetricToSentry(pair, previousCounterValues);\n }\n }\n}\n\nfunction createMetricsReporterEffect(previousCounterValues: Map<string, number>): Effect.Effect<void, never, never> {\n const schedule = Schedule.spaced('10 seconds');\n\n return Effect.repeat(\n Effect.sync(() => flushMetricsToSentry(previousCounterValues)),\n schedule,\n ).pipe(Effect.asVoid, Effect.interruptible);\n}\n\n/**\n * Effect Layer that periodically flushes metrics to Sentry.\n * The layer manages its own state for delta counter calculations,\n * which is automatically cleaned up when the layer is finalized.\n */\nexport const SentryEffectMetricsLayer: Layer.Layer<never, never, never> = Layer.effectDiscard(\n Effect.gen(function* () {\n const previousCounterValues = new Map<string, number>();\n\n yield* Effect.acquireRelease(Effect.void, () =>\n Effect.sync(() => {\n previousCounterValues.clear();\n }),\n );\n\n yield* Effect.forkScoped(createMetricsReporterEffect(previousCounterValues));\n }),\n);\n"],"names":["sentryMetrics"],"mappings":";;;;;;;;;AAsCA,MAAM,wBAAA,mBAA2B,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AACxE,MAAM,sBAAA,mBAAyB,MAAA,CAAO,GAAA,CAAI,0BAA0B,CAAA;AACpE,MAAM,0BAAA,mBAA6B,MAAA,CAAO,GAAA,CAAI,8BAA8B,CAAA;AAC5E,MAAM,wBAAA,mBAA2B,MAAA,CAAO,GAAA,CAAI,4BAA4B,CAAA;AACxE,MAAM,0BAAA,mBAA6B,MAAA,CAAO,GAAA,CAAI,8BAA8B,CAAA;AAE5E,SAAS,mBAAmB,MA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A;AAChD,IAAA,KAAA,MAAW,YAAY,SAAA,EAAW;AAChC,MAAA,oBAAA,CAAqB,UAAU,qBAAqB,CAAA;AAAA,IACtD;AAAA,EACF,WAAW,cAAA,EAAgB;AAEzB,IAAA,MAAM,YAAY,cAAA,EAAe;AACjC,IAAA,KAAA,MAAW,QAAQ,SAAA,EAAW;AAC5B,MAAA,oBAAA,CAAqB,MAAM,qBAAqB,CAAA;AAAA,IAClD;AAAA,EACF;AACF;AAEA,SAAS,4BAA4B,qBAAA,EAA+E;AAClH,EAAA,MAAM,QAAA,GAAW,QAAA,CAAS,MAAA,CAAO,YAAY,CAAA;AAE7C,EAAA,OAAO,MAAA,CAAO,MAAA;AAAA,IACZ,MAAA,CAAO,IAAA,CAAK,MAAM,oBAAA,CAAqB,qBAAqB,CAAC,CAAA;AAAA,IAC7D;AAAA,GACF,CAAE,IAAA,CAAK,MAAA,CAAO,MAAA,EAAQ,OAAO,aAAa,CAAA;AAC5C;AAOO,MAAM,2BAA6D,KAAA,CAAM,aAAA;AAAA,EAC9E,MAAA,CAAO,IAAI,aAAa;AACtB,IAAA,MAAM,qBAAA,uBAA4B,GAAA,EAAoB;AAEtD,IAAA,OAAO,MAAA,CAAO,cAAA;AAAA,MAAe,MAAA,CAAO,IAAA;AAAA,MAAM,MACxC,MAAA,CAAO,IAAA,CAAK,MAAM;AAChB,QAAA,qBAAA,CAAsB,KAAA,EAAM;AAAA,MAC9B,CAAC;AAAA,KACH;AAEA,IAAA,OAAO,MAAA,CAAO,UAAA,CAAW,2BAAA,CAA4B,qBAAqB,CAAC,CAAA;AAAA,EAC7E,CAAC;AACH;;;;"}
@@ -3,35 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const Layer = require('effect/Layer');
4
4
  const sdk = require('./sdk.js');
5
5
 
6
- /**
7
- * Options for the Sentry Effect server layer.
8
- */
9
-
10
- /**
11
- * Creates an Effect Layer that initializes Sentry for Node.js servers.
12
- *
13
- * To enable Effect tracing, logs, or metrics, compose with the respective layers:
14
- * - `Layer.setTracer(Sentry.SentryEffectTracer)` for tracing
15
- * - `Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger)` for logs
16
- * - `Sentry.SentryEffectMetricsLayer` for metrics
17
- *
18
- * @example
19
- * ```typescript
20
- * import * as Sentry from '@sentry/effect/server';
21
- * import { NodeRuntime } from '@effect/platform-node';
22
- * import { Layer, Logger } from 'effect';
23
- * import { HttpLive } from './Http.js';
24
- *
25
- * const SentryLive = Layer.mergeAll(
26
- * Sentry.effectLayer({ dsn: '__DSN__' }),
27
- * Layer.setTracer(Sentry.SentryEffectTracer),
28
- * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
29
- * );
30
- *
31
- * const MainLive = HttpLive.pipe(Layer.provide(SentryLive));
32
- * MainLive.pipe(Layer.launch, NodeRuntime.runMain);
33
- * ```
34
- */
35
6
  function effectLayer(options) {
36
7
  return Layer.suspend(() => {
37
8
  sdk.init(options);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/server/index.ts"],"sourcesContent":["import type { NodeOptions } from '@sentry/node-core/light';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer, suspend as suspendLayer } from 'effect/Layer';\nimport { init } from './sdk';\n\nexport { init } from './sdk';\n\n/**\n * Options for the Sentry Effect server layer.\n */\nexport type EffectServerLayerOptions = NodeOptions;\n\n/**\n * Creates an Effect Layer that initializes Sentry for Node.js servers.\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/server';\n * import { NodeRuntime } from '@effect/platform-node';\n * import { Layer, Logger } from 'effect';\n * import { HttpLive } from './Http.js';\n *\n * const SentryLive = Layer.mergeAll(\n * Sentry.effectLayer({ dsn: '__DSN__' }),\n * Layer.setTracer(Sentry.SentryEffectTracer),\n * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),\n * );\n *\n * const MainLive = HttpLive.pipe(Layer.provide(SentryLive));\n * MainLive.pipe(Layer.launch, NodeRuntime.runMain);\n * ```\n */\nexport function effectLayer(options: EffectServerLayerOptions): EffectLayer.Layer<never, never, never> {\n return suspendLayer(() => {\n init(options);\n return emptyLayer;\n });\n}\n"],"names":["suspendLayer","init","emptyLayer"],"mappings":";;;;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,OAAO,EAAoE;AACvG,EAAE,OAAOA,aAAY,CAAC,MAAM;AAC5B,IAAIC,QAAI,CAAC,OAAO,CAAC;AACjB,IAAI,OAAOC,WAAU;AACrB,EAAE,CAAC,CAAC;AACJ;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/server/index.ts"],"sourcesContent":["import type { NodeOptions } from '@sentry/node-core/light';\nimport type * as EffectLayer from 'effect/Layer';\nimport { empty as emptyLayer, suspend as suspendLayer } from 'effect/Layer';\nimport { init } from './sdk';\n\nexport { init } from './sdk';\n\n/**\n * Options for the Sentry Effect server layer.\n */\nexport type EffectServerLayerOptions = NodeOptions;\n\n/**\n * Creates an Effect Layer that initializes Sentry for Node.js servers.\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/server';\n * import { NodeRuntime } from '@effect/platform-node';\n * import { Layer, Logger } from 'effect';\n * import { HttpLive } from './Http.js';\n *\n * const SentryLive = Layer.mergeAll(\n * Sentry.effectLayer({ dsn: '__DSN__' }),\n * Layer.setTracer(Sentry.SentryEffectTracer),\n * Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),\n * );\n *\n * const MainLive = HttpLive.pipe(Layer.provide(SentryLive));\n * MainLive.pipe(Layer.launch, NodeRuntime.runMain);\n * ```\n */\nexport function effectLayer(options: EffectServerLayerOptions): EffectLayer.Layer<never, never, never> {\n return suspendLayer(() => {\n init(options);\n return emptyLayer;\n });\n}\n"],"names":["suspendLayer","init","emptyLayer"],"mappings":";;;;;AAqCO,SAAS,YAAY,OAAA,EAA2E;AACrG,EAAA,OAAOA,cAAa,MAAM;AACxB,IAAAC,QAAA,CAAK,OAAO,CAAA;AACZ,IAAA,OAAOC,WAAA;AAAA,EACT,CAAC,CAAA;AACH;;;;;"}
@@ -3,19 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const core = require('@sentry/core');
4
4
  const light = require('@sentry/node-core/light');
5
5
 
6
- /**
7
- * Initializes the Sentry Effect SDK for Node.js servers.
8
- *
9
- * @param options - Configuration options for the SDK
10
- * @returns The initialized Sentry client, or undefined if initialization failed
11
- */
12
6
  function init(options) {
13
7
  const opts = {
14
- ...options,
8
+ ...options
15
9
  };
16
-
17
- core.applySdkMetadata(opts, 'effect', ['effect', 'node-light']);
18
-
10
+ core.applySdkMetadata(opts, "effect", ["effect", "node-light"]);
19
11
  return light.init(opts);
20
12
  }
21
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { NodeOptions } from '@sentry/node-core/light';\nimport { init as initNode } from '@sentry/node-core/light';\n\n/**\n * Initializes the Sentry Effect SDK for Node.js servers.\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: NodeOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'effect', ['effect', 'node-light']);\n\n return initNode(opts);\n}\n"],"names":["applySdkMetadata","initNode"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAmC;AAC/D,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;;AAE5D,EAAE,OAAOC,UAAQ,CAAC,IAAI,CAAC;AACvB;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\nimport type { NodeOptions } from '@sentry/node-core/light';\nimport { init as initNode } from '@sentry/node-core/light';\n\n/**\n * Initializes the Sentry Effect SDK for Node.js servers.\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: NodeOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'effect', ['effect', 'node-light']);\n\n return initNode(opts);\n}\n"],"names":["applySdkMetadata","initNode"],"mappings":";;;;;AAWO,SAAS,KAAK,OAAA,EAA0C;AAC7D,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,IAAA,EAAM,QAAA,EAAU,CAAC,QAAA,EAAU,YAAY,CAAC,CAAA;AAEzD,EAAA,OAAOC,WAAS,IAAI,CAAA;AACtB;;;;"}