File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -201,15 +201,23 @@ function startSessionTracking(): void {
201
201
202
202
const hub = getCurrentHub ( ) ;
203
203
204
- hub . startSession ( ) ;
205
- hub . captureSession ( ) ;
206
-
207
- // We want to create a session for every navigation as well
208
- addInstrumentationHandler ( {
209
- callback : ( ) => {
210
- hub . startSession ( ) ;
211
- hub . captureSession ( ) ;
212
- } ,
213
- type : 'history' ,
214
- } ) ;
204
+ if ( 'startSession' in hub ) {
205
+ // The only way for this to be false is for there to be a version mismatch between @sentry /browser (>= 6.0.0) and
206
+ // @sentry /hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
207
+ // pinned at the same version in package.json, but there are edge cases where it's possible'. See
208
+ // https://github.com/getsentry/sentry-javascript/issues/3234 and
209
+ // https://github.com/getsentry/sentry-javascript/issues/3207.
210
+
211
+ hub . startSession ( ) ;
212
+ hub . captureSession ( ) ;
213
+
214
+ // We want to create a session for every navigation as well
215
+ addInstrumentationHandler ( {
216
+ callback : ( ) => {
217
+ hub . startSession ( ) ;
218
+ hub . captureSession ( ) ;
219
+ } ,
220
+ type : 'history' ,
221
+ } ) ;
222
+ }
215
223
}
You can’t perform that action at this time.
0 commit comments