Skip to content

fix(release health): Only create sessions if the correct methods are defined #3281

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 1 commit into from
Mar 5, 2021
Merged
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
30 changes: 19 additions & 11 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,23 @@ function startSessionTracking(): void {

const hub = getCurrentHub();

hub.startSession();
hub.captureSession();

// We want to create a session for every navigation as well
addInstrumentationHandler({
callback: () => {
hub.startSession();
hub.captureSession();
},
type: 'history',
});
if ('startSession' in hub) {
// The only way for this to be false is for there to be a version mismatch between @sentry/browser (>= 6.0.0) and
// @sentry/hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
// pinned at the same version in package.json, but there are edge cases where it's possible'. See
// https://github.com/getsentry/sentry-javascript/issues/3234 and
// https://github.com/getsentry/sentry-javascript/issues/3207.

hub.startSession();
hub.captureSession();

// We want to create a session for every navigation as well
addInstrumentationHandler({
callback: () => {
hub.startSession();
hub.captureSession();
},
type: 'history',
});
}
}