1
1
import { Dispatch , Middleware , MiddlewareAPI } from "redux" ;
2
2
import { RegisteredUserDTO } from "../../../IsaacApiTypes" ;
3
- import { ACTION_TYPE , isDefined } from "../../services" ;
3
+ import { ACTION_TYPE , isDefined , trackEvent } from "../../services" ;
4
4
import { redirectTo , getUserId , logAction , setUserId , AppDispatch , changePage } from "../index" ;
5
5
6
6
let timeoutHandle : number | undefined ;
@@ -10,7 +10,6 @@ let timeoutHandle: number | undefined;
10
10
// use it asynchronously, so that is what we do.
11
11
12
12
const scheduleNextCheck = ( middleware : MiddlewareAPI ) => {
13
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
14
13
timeoutHandle = window . setTimeout ( ( ) => checkUserConsistency ( middleware ) , 1000 ) ;
15
14
} ;
16
15
@@ -32,19 +31,13 @@ const checkUserConsistency = (middleware: MiddlewareAPI) => {
32
31
33
32
34
33
const setCurrentUser = ( user : RegisteredUserDTO , api : MiddlewareAPI ) => {
35
- const dispatch = api . dispatch as AppDispatch ;
36
34
clearTimeout ( timeoutHandle ) ;
37
35
// Only start checking if we can successfully store the user id
38
36
if ( setUserId ( user . _id ) ) {
39
37
scheduleNextCheck ( api ) ;
40
38
} else {
41
- // eslint-disable-next-line no-console
42
39
console . error ( "Cannot perform user consistency checking!" ) ;
43
- const eventDetails = {
44
- type : "USER_CONSISTENCY_CHECKING_FAILED" ,
45
- userAgent : navigator . userAgent ,
46
- } ;
47
- dispatch ( logAction ( eventDetails ) ) ;
40
+ trackEvent ( "exception" , { props : { description : "user_consistency_checking_failed" , fatal : false } } ) ;
48
41
}
49
42
} ;
50
43
0 commit comments