Skip to content

Commit d5efd68

Browse files
authored
feat(effect): Use options in buildEffectLayer without overriding (#19794)
To not mess with `@sentry/core` while adding the new SDK this, the options are directly moved into the Effect SDK. The main reason why this is now moved is that mutating the options could lead to other issues, and this is why I want to keep this in a separate and smaller PR.
1 parent 6d004ec commit d5efd68

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/core/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
256256

257257
// todo(v11): Remove the experimental flag
258258
// eslint-disable-next-line deprecation/deprecation
259-
this._options.enableMetrics = this._options.enableMetrics ?? this._options._experiments?.enableMetrics ?? true;
259+
const enableMetrics = this._options.enableMetrics ?? this._options._experiments?.enableMetrics ?? true;
260260

261261
// Setup metric flushing with weight and timeout tracking
262-
if (this._options.enableMetrics) {
262+
if (enableMetrics) {
263263
setupWeightBasedFlushing(
264264
this,
265265
'afterCaptureMetric',

packages/effect/src/utils/buildEffectLayer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ export function buildEffectLayer<T extends EffectLayerBaseOptions>(
2727
}
2828

2929
const clientOptions = client.getOptions();
30+
const enableMetrics = clientOptions.enableMetrics ?? clientOptions._experiments?.enableMetrics ?? true;
31+
const enableLogs = clientOptions.enableLogs ?? clientOptions._experiments?.enableLogs ?? false;
3032
const { enableEffectLogs = false, enableEffectMetrics = false } = options;
3133
let layer: EffectLayer.Layer<never, never, never> = SentryEffectTracerLayer;
3234

33-
if (enableEffectLogs && clientOptions.enableLogs) {
35+
if (enableEffectLogs && enableLogs) {
3436
const effectLogger = replaceLogger(defaultLogger, SentryEffectLogger);
3537
layer = layer.pipe(provideMerge(effectLogger));
3638
}
3739

38-
if (enableEffectMetrics && clientOptions.enableMetrics) {
40+
if (enableEffectMetrics && enableMetrics) {
3941
layer = layer.pipe(provideMerge(SentryEffectMetricsLayer));
4042
}
4143

0 commit comments

Comments
 (0)