Skip to content

feat!: Remove autoSessionTracking option #14802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [captureConsoleIntegration()],
autoSessionTracking: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, we opted out of session tracking for some tests due to session envelopes colliding with the envelope we're waiting for. Do we need to filter on browserSessionIntegration instead here? Might as well be old code and this is no longer a concern. I guess we'd find out with the flaky test detector 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point actually. I didn't consider that. I agree though that we would probably catch anything weird in the flakey test detector. Maybe the autoSessionTrackings here are also from copy and pasting tests.

I will merge this as is cause I'd err on removing unneeded logic. If there are any CI failures coming up we may attribute it to this.

attachStacktrace: true,
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
integrations: [captureConsoleIntegration()],
autoSessionTracking: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ window.Sentry = Sentry;
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '0.1',
// intentionally disabling this, we want to leverage the deprecated hub API
autoSessionTracking: false,
});

// simulate old startSessionTracking behavior
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100, appRootPath: __dirname })],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100, maxAnrEvents: 2 })],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
autoSessionTracking: true,
});

Sentry.setUser({ email: '[email protected]' });
Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/suites/anr/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/suites/anr/basic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

Expand Down
1 change: 0 additions & 1 deletion dev-packages/node-integration-tests/suites/anr/forked.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ setTimeout(() => {
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
debug: true,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ setTimeout(() => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.anrIntegration({ captureStackTrace: true, anrThreshold: 100 })],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ function configureSentry() {
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
debug: true,
integrations: [Sentry.anrIntegration({ captureStackTrace: true })],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ function configureSentry() {
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
debug: true,
integrations: [Sentry.anrIntegration({ captureStackTrace: true })],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
debug: true,
autoSessionTracking: false,
integrations: [anr],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ import * as Sentry from '@sentry/node';
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { loggingTransport } = require('@sentry-internal/node-integration-tests');
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ describe('ContextLines integration in CJS', () => {
filename: expect.stringMatching(/\/scenario with space.cjs$/),
context_line: "Sentry.captureException(new Error('Test Error'));",
pre_context: [
'',
'Sentry.init({',
" dsn: 'https://[email protected]/1337',",
" release: '1.0',",
' autoSessionTracking: false,',
' transport: loggingTransport,',
'});',
'',
],
post_context: ['', '// some more post context'],
colno: 25,
lineno: 11,
lineno: 10,
function: 'Object.?',
in_app: true,
module: 'scenario with space',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CronJob } from 'cron';
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as cron from 'node-cron';
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as schedule from 'node-schedule';
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ new iitm.Hook((_, name) => {
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
transport: loggingTransport,
registerEsmLoaderHooks: { onlyIncludeInstrumentedModules: true },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as Sentry from '@sentry/node';
Sentry.init({
dsn: 'https://[email protected]/1337',
release: '1.0',
autoSessionTracking: false,
integrations: [Sentry.modulesIntegration()],
transport: loggingTransport,
});
12 changes: 3 additions & 9 deletions packages/angular/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IS_DEBUG_BUILD } from './flags';
/**
* Get the default integrations for the Angular SDK.
*/
export function getDefaultIntegrations(options: BrowserOptions = {}): Integration[] {
export function getDefaultIntegrations(_options: BrowserOptions = {}): Integration[] {
// Don't include the BrowserApiErrors integration as it interferes with the Angular SDK's `ErrorHandler`:
// BrowserApiErrors would catch certain errors before they reach the `ErrorHandler` and
// thus provide a lower fidelity error than what `SentryErrorHandler`
Expand All @@ -32,22 +32,16 @@ export function getDefaultIntegrations(options: BrowserOptions = {}): Integratio
// see:
// - https://github.com/getsentry/sentry-javascript/issues/5417#issuecomment-1453407097
// - https://github.com/getsentry/sentry-javascript/issues/2744
const integrations = [
return [
inboundFiltersIntegration(),
functionToStringIntegration(),
breadcrumbsIntegration(),
globalHandlersIntegration(),
linkedErrorsIntegration(),
dedupeIntegration(),
httpContextIntegration(),
browserSessionIntegration(),
];

// eslint-disable-next-line deprecation/deprecation
if (options.autoSessionTracking !== false) {
integrations.push(browserSessionIntegration());
}

return integrations;
}

/**
Expand Down
13 changes: 3 additions & 10 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import { defaultStackParser } from './stack-parsers';
import { makeFetchTransport } from './transports/fetch';

/** Get the default integrations for the browser SDK. */
export function getDefaultIntegrations(options: Options): Integration[] {
export function getDefaultIntegrations(_options: Options): Integration[] {
/**
* Note: Please make sure this stays in sync with Angular SDK, which re-exports
* `getDefaultIntegrations` but with an adjusted set of integrations.
*/
const integrations = [
return [
inboundFiltersIntegration(),
functionToStringIntegration(),
browserApiErrorsIntegration(),
Expand All @@ -41,14 +41,8 @@ export function getDefaultIntegrations(options: Options): Integration[] {
linkedErrorsIntegration(),
dedupeIntegration(),
httpContextIntegration(),
browserSessionIntegration(),
];

// eslint-disable-next-line deprecation/deprecation
if (options.autoSessionTracking !== false) {
integrations.push(browserSessionIntegration());
}

return integrations;
}

/** Exported only for tests. */
Expand All @@ -61,7 +55,6 @@ export function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOpt
: WINDOW.SENTRY_RELEASE && WINDOW.SENTRY_RELEASE.id // This supports the variable that sentry-webpack-plugin injects
? WINDOW.SENTRY_RELEASE.id
: undefined,
autoSessionTracking: true,
sendClientReports: true,
};

Expand Down
3 changes: 0 additions & 3 deletions packages/browser/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ describe('applyDefaultOptions', () => {
expect(actual).toEqual({
defaultIntegrations: expect.any(Array),
release: undefined,
autoSessionTracking: true,
sendClientReports: true,
});

Expand All @@ -299,14 +298,12 @@ describe('applyDefaultOptions', () => {
const options = {
tracesSampleRate: 0.5,
release: '1.0.0',
autoSessionTracking: false,
};
const actual = applyDefaultOptions(options);

expect(actual).toEqual({
defaultIntegrations: expect.any(Array),
release: '1.0.0',
autoSessionTracking: false,
sendClientReports: true,
tracesSampleRate: 0.5,
});
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/types-hoist/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
/** Attaches stacktraces to pure capture message / log integrations */
attachStacktrace?: boolean;

/**
* A flag enabling Sessions Tracking feature.
* By default, Session Tracking is enabled.
*
* @deprecated Setting the `autoSessionTracking` option is deprecated.
* To enable session tracking, it is recommended to unset `autoSessionTracking` and ensure that either, in browser environments the `browserSessionIntegration` is added, or in server environments the `httpIntegration` is added.
* To disable session tracking, it is recommended unset `autoSessionTracking` and to remove the `browserSessionIntegration` in browser environments, or in server environments configure the `httpIntegration` with the `trackIncomingRequestsAsSessions` option set to `false`.
*/
autoSessionTracking?: boolean;

/**
* Send SDK Client Reports. When calling `Sentry.init()`, this option defaults to `true`.
*/
Expand Down
1 change: 0 additions & 1 deletion packages/feedback/src/core/mockSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export async function mockSdk({ sentryOptions }: MockSdkParams = {}): Promise<vo
init({
...getDefaultClientOptions(),
dsn: 'https://[email protected]/1',
autoSessionTracking: false,
sendClientReports: false,
transport: () => new MockTransport(),
replaysSessionSampleRate: 0.0,
Expand Down
2 changes: 0 additions & 2 deletions packages/nextjs/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ export function init(options: NodeOptions): NodeClient | undefined {
environment: process.env.SENTRY_ENVIRONMENT || getVercelEnv(false) || process.env.NODE_ENV,
defaultIntegrations: customDefaultIntegrations,
...options,
// Right now we only capture frontend sessions for Next.js
autoSessionTracking: false,
};

if (DEBUG_BUILD && opts.debug) {
Expand Down
1 change: 0 additions & 1 deletion packages/nextjs/test/serverSdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('Server init()', () => {
],
},
},
autoSessionTracking: false,
environment: 'test',

// Integrations are tested separately, and we can't be more specific here without depending on the order in
Expand Down
10 changes: 0 additions & 10 deletions packages/node/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ function getClientOptions(
): NodeClientOptions {
const release = getRelease(options.release);

const autoSessionTracking =
typeof release !== 'string'
? false
: // eslint-disable-next-line deprecation/deprecation
options.autoSessionTracking === undefined
? true
: // eslint-disable-next-line deprecation/deprecation
options.autoSessionTracking;

if (options.spotlight == null) {
const spotlightEnv = envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true });
if (spotlightEnv == null) {
Expand All @@ -242,7 +233,6 @@ function getClientOptions(

const overwriteOptions = dropUndefinedKeys({
release,
autoSessionTracking,
tracesSampleRate,
});

Expand Down
2 changes: 0 additions & 2 deletions packages/remix/test/integration/instrument.server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ Sentry.init({
dsn: 'https://[email protected]/1337',
tracesSampleRate: 1,
tracePropagationTargets: ['example.org'],
// Disabling to test series of envelopes deterministically.
autoSessionTracking: false,
autoInstrumentRemix: process.env.USE_OTEL === '1',
});
1 change: 0 additions & 1 deletion packages/replay-internal/test/mocks/mockSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export async function mockSdk({ replayOptions, sentryOptions, autoStart = true }
const client = init({
...getDefaultClientOptions(),
dsn: 'https://[email protected]/1',
autoSessionTracking: false,
sendClientReports: false,
transport: () => new MockTransport(),
replaysSessionSampleRate: 1.0,
Expand Down
10 changes: 0 additions & 10 deletions packages/vercel-edge/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,12 @@ export function init(options: VercelEdgeOptions = {}): Client | undefined {
const detectedRelease = getSentryRelease();
if (detectedRelease !== undefined) {
options.release = detectedRelease;
} else {
// If release is not provided, then we should disable autoSessionTracking
// eslint-disable-next-line deprecation/deprecation
options.autoSessionTracking = false;
}
}

options.environment =
options.environment || process.env.SENTRY_ENVIRONMENT || getVercelEnv(false) || process.env.NODE_ENV;

// eslint-disable-next-line deprecation/deprecation
if (options.autoSessionTracking === undefined && options.dsn !== undefined) {
// eslint-disable-next-line deprecation/deprecation
options.autoSessionTracking = true;
}

const client = new VercelEdgeClient({
...options,
stackParser: stackParserFromStackParserOptions(options.stackParser || nodeStackParser),
Expand Down
Loading
Loading