Skip to content

Commit ef26423

Browse files
authored
revert: "feat(browser): Add interactionsSampleRate to browserTracingIntegration options (#12023)" (#12048)
The reason for the revert is that we're concerned about 1. the usefulness and 2. the name of this option and would like to revisit this without blocking the 8.1.0 release. This is not semver-breaking because in 8.0.0, this API did not exist.
1 parent 32bf90c commit ef26423

File tree

3 files changed

+4
-56
lines changed

3 files changed

+4
-56
lines changed

packages/browser-utils/src/metrics/inp.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import { getBrowserPerformanceAPI, msToSec } from './utils';
1717
/**
1818
* Start tracking INP webvital events.
1919
*/
20-
export function startTrackingINP(interactionsSampleRate: number): () => void {
20+
export function startTrackingINP(): () => void {
2121
const performance = getBrowserPerformanceAPI();
2222
if (performance && browserPerformanceTimeOrigin) {
23-
const inpCallback = _trackINP(interactionsSampleRate);
23+
const inpCallback = _trackINP();
2424

2525
return (): void => {
2626
inpCallback();
@@ -60,16 +60,8 @@ const INP_ENTRY_MAP: Record<string, 'click' | 'hover' | 'drag' | 'press'> = {
6060
};
6161

6262
/** Starts tracking the Interaction to Next Paint on the current page. */
63-
function _trackINP(interactionsSampleRate: number): () => void {
63+
function _trackINP(): () => void {
6464
return addInpInstrumentationHandler(({ metric }) => {
65-
// As specified in the `interactionsSampleRate` option, the sampling decision shall be based on
66-
// `tracesSampleRate` x `interactionsSampleRate`
67-
// This is the same as sampling here first on `interactionsSampleRate` and later again on `tracesSampleRate`
68-
// (which is done in `startInactiveSpan`). Doing it this way is easier and more bundle-size efficient.
69-
if (Math.random() > interactionsSampleRate) {
70-
return;
71-
}
72-
7365
const client = getClient();
7466
if (!client || metric.value == undefined) {
7567
return;

packages/browser/src/tracing/browserTracingIntegration.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,6 @@ export interface BrowserTracingOptions {
103103
*/
104104
enableInp: boolean;
105105

106-
/**
107-
* Sample rate to determine interaction (INP) span sampling.
108-
*
109-
* The `interactionsSampleRate` is applied on top of the global `tracesSampleRate`.
110-
* For example, a tracesSampleRate of 0.1 and interactionsSampleRate of 0.5 will result in a 0.05 sample rate
111-
* for interactions.
112-
*
113-
* Default: 1
114-
*/
115-
interactionsSampleRate: number;
116-
117106
/**
118107
* Flag to disable patching all together for fetch requests.
119108
*
@@ -166,7 +155,6 @@ const DEFAULT_BROWSER_TRACING_OPTIONS: BrowserTracingOptions = {
166155
markBackgroundSpan: true,
167156
enableLongTask: true,
168157
enableInp: true,
169-
interactionsSampleRate: 1,
170158
_experiments: {},
171159
...defaultRequestInstrumentationOptions,
172160
};
@@ -185,7 +173,6 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
185173

186174
const {
187175
enableInp,
188-
interactionsSampleRate,
189176
enableLongTask,
190177
_experiments: { enableInteractions },
191178
beforeStartSpan,
@@ -207,14 +194,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
207194
const _collectWebVitals = startTrackingWebVitals();
208195

209196
if (enableInp) {
210-
const isValidInteractionsSampleRate = interactionsSampleRate >= 0 && interactionsSampleRate <= 1;
211-
if (isValidInteractionsSampleRate) {
212-
DEBUG_BUILD &&
213-
logger.warn(
214-
`[Tracing] \`interactionsSampleRate\` must be between 0 and 1. Got: ${interactionsSampleRate}. Setting to 100%`,
215-
);
216-
}
217-
startTrackingINP(isValidInteractionsSampleRate ? interactionsSampleRate : 1);
197+
startTrackingINP();
218198
}
219199

220200
if (enableLongTask) {

packages/browser/test/unit/tracing/browserTracingIntegration.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import {
3636
} from '../../../src/tracing/browserTracingIntegration';
3737
import { getDefaultBrowserClientOptions } from '../helper/browser-client-options';
3838

39-
import * as browserUtils from '@sentry-internal/browser-utils';
40-
4139
// We're setting up JSDom here because the Next.js routing instrumentations requires a few things to be present on pageload:
4240
// 1. Access to window.document API for `window.document.getElementById`
4341
// 2. Access to window.location API for `window.location.pathname`
@@ -1000,28 +998,6 @@ describe('browserTracingIntegration', () => {
1000998
});
1001999
});
10021000

1003-
describe('INP - interactionsSampleRate', () => {
1004-
const startTrackingInpSpy = jest.spyOn(browserUtils, 'startTrackingINP');
1005-
1006-
it('sets interactionsSampleRate to 1 by default', () => {
1007-
browserTracingIntegration();
1008-
expect(startTrackingInpSpy).toHaveBeenCalledWith(1);
1009-
});
1010-
1011-
it.each([0, 0.5, 1])('passes on user-defined interactionsSampleRate', interactionsSampleRate => {
1012-
browserTracingIntegration({ interactionsSampleRate });
1013-
expect(startTrackingInpSpy).toHaveBeenCalledWith(interactionsSampleRate);
1014-
});
1015-
1016-
it.each([-1, 1.1, NaN, Infinity])(
1017-
'falls back to 100% when receiving an invalid interactionsSampleRate',
1018-
interactionsSampleRate => {
1019-
browserTracingIntegration({ interactionsSampleRate });
1020-
expect(startTrackingInpSpy).toHaveBeenCalledWith(1);
1021-
},
1022-
);
1023-
});
1024-
10251001
// TODO(lforst): I cannot manage to get this test to pass.
10261002
/*
10271003
it('heartbeatInterval can be a custom value', () => {

0 commit comments

Comments
 (0)