Skip to content
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

add more logging #303

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion src/components/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect, useState } from 'react'
import { useNavigate, Outlet } from 'react-router-dom'
import { getUserProfile } from '../services/userProfile'
import { fetchUserInformationFromAuthToken } from '../utils/services'
import { Effect } from 'effect'
import { customLogger } from '../utils/logger.ts'

const ProtectedRoute = () => {
const [isAuthenticated, setIsAuthenticated] = useState(false)
Expand All @@ -17,7 +19,12 @@ const ProtectedRoute = () => {
}

const userProfileData = await fetchUserInformationFromAuthToken()
localStorage.setItem('userProfile', JSON.stringify(await getUserProfile(userProfileData.email)))
const userProfile = JSON.stringify(await getUserProfile(userProfileData.email))
Effect.logInfo(`UserProfile set in localStorage: ${userProfile}`).pipe(
Effect.provide(customLogger),
Effect.runSync
)
localStorage.setItem('userProfile', userProfile)
setIsAuthenticated(true)
} catch (error) {
console.error('Error occurred when updating userProfile data')
Expand Down
4 changes: 4 additions & 0 deletions src/pages/TeamOverview/TeamOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const TeamOverview = () => {

useEffect(() => {
const userProfileItem = localStorage.getItem('userProfile')
Effect.logInfo(`UserProfile from localStorage: ${userProfileItem}`).pipe(
Effect.provide(customLogger),
Effect.runSync
)
if (!userProfileItem) return

const user = JSON.parse(userProfileItem) as User
Expand Down