File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as Sentry from '@sentry/react'
12import {
23 GithubAuthProvider ,
34 GoogleAuthProvider ,
@@ -17,6 +18,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
1718 closeAuthModal,
1819 initState,
1920 setAuthError,
21+ user,
2022 openAuthModal,
2123 setConnecting,
2224 logout,
@@ -42,6 +44,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
4244 initState ( {
4345 user : {
4446 id : user . uid ,
47+ connectedAt : new Date ( ) ,
4548 name : user . displayName || 'Anonymous' ,
4649 imageURL : user . photoURL || '' ,
4750 } ,
@@ -148,10 +151,18 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
148151 * and logout the user if the session has expired
149152 */
150153 useEffect ( ( ) => {
151- const unsubscribe = firebaseAuth . onAuthStateChanged ( async ( user ) => {
152- if ( ! user ) {
154+ const unsubscribe = firebaseAuth . onAuthStateChanged ( async ( fbUser ) => {
155+ if ( ! fbUser ) {
153156 if ( isConnected ) {
154157 toast ( 'Session expired, please reconnect' , { theme : 'dangerToast' } )
158+
159+ Sentry . captureMessage ( `Session expired` , {
160+ level : 'info' ,
161+ extra : {
162+ fbID : user ?. id || 'anonymous' ,
163+ connectedAt : user ?. connectedAt ?. toISOString ( ) ,
164+ } ,
165+ } )
155166 }
156167
157168 await logout ( )
You can’t perform that action at this time.
0 commit comments