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 @@ -189,15 +189,23 @@ function startSessionTracking(): void {
189
189
190
190
const hub = getCurrentHub ( ) ;
191
191
192
- hub . startSession ( ) ;
193
- hub . captureSession ( ) ;
194
-
195
- // We want to create a session for every navigation as well
196
- addInstrumentationHandler ( {
197
- callback : ( ) => {
198
- hub . startSession ( ) ;
199
- hub . captureSession ( ) ;
200
- } ,
201
- type : 'history' ,
202
- } ) ;
192
+ if ( 'startSession' in hub ) {
193
+ // The only way for this to be false is for there to be a version mismatch between @sentry /browser (>= 6.0.0) and
194
+ // @sentry /hub (< 5.27.0). In the simple case, there won't ever be such a mismatch, because the two packages are
195
+ // pinned at the same version in package.json, but there are edge cases where it's possible'. See
196
+ // https://github.com/getsentry/sentry-javascript/issues/3234 and
197
+ // https://github.com/getsentry/sentry-javascript/issues/3207.
198
+
199
+ hub . startSession ( ) ;
200
+ hub . captureSession ( ) ;
201
+
202
+ // We want to create a session for every navigation as well
203
+ addInstrumentationHandler ( {
204
+ callback : ( ) => {
205
+ hub . startSession ( ) ;
206
+ hub . captureSession ( ) ;
207
+ } ,
208
+ type : 'history' ,
209
+ } ) ;
210
+ }
203
211
}
You can’t perform that action at this time.
0 commit comments