Skip to content

Commit be3044b

Browse files
committed
ref: mode -> lifecycle
1 parent f300ff8 commit be3044b

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

dev-packages/browser-integration-tests/suites/sessions/single-mode/init.js renamed to dev-packages/browser-integration-tests/suites/sessions/page-lifecycle/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ window.Sentry = Sentry;
55
Sentry.init({
66
dsn: 'https://public@dsn.ingest.sentry.io/1337',
77
release: '0.1',
8-
integrations: [Sentry.browserSessionIntegration({ mode: 'single' })],
8+
integrations: [Sentry.browserSessionIntegration({ lifecycle: 'page' })],
99
});

dev-packages/browser-integration-tests/suites/sessions/single-mode/subject.js renamed to dev-packages/browser-integration-tests/suites/sessions/page-lifecycle/subject.js

File renamed without changes.

dev-packages/browser-integration-tests/suites/sessions/single-mode/template.html renamed to dev-packages/browser-integration-tests/suites/sessions/page-lifecycle/template.html

File renamed without changes.

dev-packages/browser-integration-tests/suites/sessions/single-mode/test.ts renamed to dev-packages/browser-integration-tests/suites/sessions/page-lifecycle/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SessionContext } from '@sentry/core';
33
import { sentryTest } from '../../../utils/fixtures';
44
import { getMultipleSentryEnvelopeRequests } from '../../../utils/helpers';
55

6-
sentryTest('should start a session on pageload in single mode.', async ({ getLocalTestUrl, page }) => {
6+
sentryTest('should start a session on pageload with page lifecycle.', async ({ getLocalTestUrl, page }) => {
77
const url = await getLocalTestUrl({ testDir: __dirname });
88

99
const sessions = await getMultipleSentryEnvelopeRequests<SessionContext>(page, 1, {
@@ -21,7 +21,7 @@ sentryTest('should start a session on pageload in single mode.', async ({ getLoc
2121
});
2222

2323
sentryTest(
24-
'should NOT start a new session on pushState navigation in single mode.',
24+
'should NOT start a new session on pushState navigation with page lifecycle.',
2525
async ({ getLocalTestUrl, page }) => {
2626
const url = await getLocalTestUrl({ testDir: __dirname });
2727

dev-packages/browser-integration-tests/suites/sessions/navigation-mode/init.js renamed to dev-packages/browser-integration-tests/suites/sessions/route-lifecycle/init.js

File renamed without changes.

dev-packages/browser-integration-tests/suites/sessions/navigation-mode/subject.js renamed to dev-packages/browser-integration-tests/suites/sessions/route-lifecycle/subject.js

File renamed without changes.

dev-packages/browser-integration-tests/suites/sessions/navigation-mode/template.html renamed to dev-packages/browser-integration-tests/suites/sessions/route-lifecycle/template.html

File renamed without changes.

dev-packages/browser-integration-tests/suites/sessions/navigation-mode/test.ts renamed to dev-packages/browser-integration-tests/suites/sessions/route-lifecycle/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { SessionContext } from '@sentry/core';
33
import { sentryTest } from '../../../utils/fixtures';
44
import { getMultipleSentryEnvelopeRequests } from '../../../utils/helpers';
55

6-
sentryTest('should start new sessions on pushState navigation in default mode.', async ({ getLocalTestUrl, page }) => {
6+
sentryTest('should start new sessions on pushState navigation with route lifecycle (default).', async ({ getLocalTestUrl, page }) => {
77
const url = await getLocalTestUrl({ testDir: __dirname });
88

99
const sessionsPromise = getMultipleSentryEnvelopeRequests<SessionContext>(page, 10, {

packages/browser/src/integrations/browsersession.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { WINDOW } from '../helpers';
55

66
interface BrowserSessionOptions {
77
/**
8-
* Controls when sessions are created.
8+
* Controls the session lifecycle - when new sessions are created.
99
*
10-
* - `'single'`: A session is created once when the page is loaded. Session is not
10+
* - `'route'`: A session is created on page load and on every navigation.
11+
* This is the default behavior.
12+
* - `'page'`: A session is created once when the page is loaded. Session is not
1113
* updated on navigation. This is useful for webviews or single-page apps where
1214
* URL changes should not trigger new sessions.
13-
* - `'navigation'`: A session is created on page load and on every navigation.
14-
* This is the default behavior.
1515
*
16-
* @default 'navigation'
16+
* @default 'route'
1717
*/
18-
mode?: 'single' | 'navigation';
18+
lifecycle?: 'route' | 'page';
1919
}
2020

2121
/**
@@ -25,7 +25,7 @@ interface BrowserSessionOptions {
2525
* Note: In order for session tracking to work, you need to set up Releases: https://docs.sentry.io/product/releases/
2626
*/
2727
export const browserSessionIntegration = defineIntegration((options: BrowserSessionOptions = {}) => {
28-
const mode = options.mode ?? 'navigation';
28+
const lifecycle = options.lifecycle ?? 'route';
2929

3030
return {
3131
name: 'BrowserSession',
@@ -43,7 +43,7 @@ export const browserSessionIntegration = defineIntegration((options: BrowserSess
4343
startSession({ ignoreDuration: true });
4444
captureSession();
4545

46-
if (mode === 'navigation') {
46+
if (lifecycle === 'route') {
4747
// We want to create a session for every navigation as well
4848
addHistoryInstrumentationHandler(({ from, to }) => {
4949
// Don't create an additional session for the initial route or if the location did not change

0 commit comments

Comments
 (0)