Skip to content

Commit ab95d3f

Browse files
committed
use _experiments
1 parent b36ed06 commit ab95d3f

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

packages/browser/src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ export class BrowserClient extends Client<BrowserClientOptions> {
108108

109109
super(opts);
110110

111-
const { sendDefaultPii, sendClientReports, enableLogs, _enableTraceMetrics } = this._options;
111+
const { sendDefaultPii, sendClientReports, enableLogs, _experiments } = this._options;
112112

113-
if (WINDOW.document && (sendClientReports || enableLogs || _enableTraceMetrics)) {
113+
if (WINDOW.document && (sendClientReports || enableLogs || _experiments?.enableTraceMetrics)) {
114114
WINDOW.document.addEventListener('visibilitychange', () => {
115115
if (WINDOW.document.visibilityState === 'hidden') {
116116
if (sendClientReports) {
@@ -119,7 +119,7 @@ export class BrowserClient extends Client<BrowserClientOptions> {
119119
if (enableLogs) {
120120
_INTERNAL_flushLogsBuffer(this);
121121
}
122-
if (_enableTraceMetrics) {
122+
if (_experiments?.enableTraceMetrics) {
123123
_INTERNAL_flushMetricsBuffer(this);
124124
}
125125
}
@@ -142,7 +142,7 @@ export class BrowserClient extends Client<BrowserClientOptions> {
142142
});
143143
}
144144

145-
if (_enableTraceMetrics) {
145+
if (_experiments?.enableTraceMetrics) {
146146
this.on('flush', () => {
147147
_INTERNAL_flushMetricsBuffer(this);
148148
});

packages/core/src/metrics/internal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal
133133
return;
134134
}
135135

136-
const { release, environment, _enableTraceMetrics = false, beforeSendMetric } = client.getOptions();
137-
if (!_enableTraceMetrics) {
136+
const { release, environment, _experiments } = client.getOptions();
137+
if (!_experiments?.enableTraceMetrics) {
138138
DEBUG_BUILD && debug.warn('trace metrics option not enabled, metric will not be captured.');
139139
return;
140140
}
@@ -168,7 +168,7 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal
168168
};
169169

170170
// Run beforeSendMetric callback
171-
const processedMetric = beforeSendMetric ? beforeSendMetric(metric) : metric;
171+
const processedMetric = _experiments?.beforeSendMetric ? _experiments.beforeSendMetric(metric) : metric;
172172

173173
if (!processedMetric) {
174174
DEBUG_BUILD && debug.log('An event processor returned `null`, will not send metric.');

packages/core/src/metrics/public-api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function captureMetric(type: MetricType, name: string, value: number | string, o
3838
}
3939

4040
/**
41-
* @summary Increment a counter metric. Requires the `_enableTraceMetrics` option to be enabled.
41+
* @summary Increment a counter metric. Requires the `_experiments.enableTraceMetrics` option to be enabled.
4242
*
4343
* @param name - The name of the counter metric.
4444
* @param value - The value to increment by (defaults to 1).
@@ -72,7 +72,7 @@ export function count(name: string, value: number = 1, options?: MetricOptions):
7272
}
7373

7474
/**
75-
* @summary Set a gauge metric to a specific value. Requires the `_enableTraceMetrics` option to be enabled.
75+
* @summary Set a gauge metric to a specific value. Requires the `_experiments.enableTraceMetrics` option to be enabled.
7676
*
7777
* @param name - The name of the gauge metric.
7878
* @param value - The current value of the gauge.
@@ -106,7 +106,7 @@ export function gauge(name: string, value: number, options?: MetricOptions): voi
106106
}
107107

108108
/**
109-
* @summary Record a value in a distribution metric. Requires the `_enableTraceMetrics` option to be enabled.
109+
* @summary Record a value in a distribution metric. Requires the `_experiments.enableTraceMetrics` option to be enabled.
110110
*
111111
* @param name - The name of the distribution metric.
112112
* @param value - The value to record in the distribution.

packages/core/src/server-runtime-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class ServerRuntimeClient<
8484
});
8585
}
8686

87-
if (this._options._enableTraceMetrics) {
87+
if (this._options._experiments?.enableTraceMetrics) {
8888
// eslint-disable-next-line @typescript-eslint/no-this-alias
8989
const client = this;
9090

packages/core/src/types-hoist/options.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,29 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
283283
_experiments?: {
284284
// eslint-disable-next-line @typescript-eslint/no-explicit-any
285285
[key: string]: any;
286+
287+
/**
288+
* If trace metrics support should be enabled.
289+
*
290+
* @default false
291+
* @experimental
292+
*/
293+
enableTraceMetrics?: boolean;
294+
295+
/**
296+
* An event-processing callback for metrics, guaranteed to be invoked after all other metric
297+
* processors. This allows a metric to be modified or dropped before it's sent.
298+
*
299+
* Note that you must return a valid metric from this callback. If you do not wish to modify the metric, simply return
300+
* it at the end. Returning `null` will cause the metric to be dropped.
301+
*
302+
* @default undefined
303+
* @experimental
304+
*
305+
* @param metric The metric generated by the SDK.
306+
* @returns A new metric that will be sent | null.
307+
*/
308+
beforeSendMetric?: (metric: Metric) => Metric | null;
286309
};
287310

288311
/**
@@ -380,29 +403,6 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
380403
*/
381404
beforeSendLog?: (log: Log) => Log | null;
382405

383-
/**
384-
* If trace metrics support should be enabled.
385-
*
386-
* @default false
387-
* @experimental
388-
*/
389-
_enableTraceMetrics?: boolean;
390-
391-
/**
392-
* An event-processing callback for metrics, guaranteed to be invoked after all other metric
393-
* processors. This allows a metric to be modified or dropped before it's sent.
394-
*
395-
* Note that you must return a valid metric from this callback. If you do not wish to modify the metric, simply return
396-
* it at the end. Returning `null` will cause the metric to be dropped.
397-
*
398-
* @default undefined
399-
* @experimental
400-
*
401-
* @param metric The metric generated by the SDK.
402-
* @returns A new metric that will be sent | null.
403-
*/
404-
beforeSendMetric?: (metric: Metric) => Metric | null;
405-
406406
/**
407407
* Function to compute tracing sample rate dynamically and filter unwanted traces.
408408
*

0 commit comments

Comments
 (0)