Merged in fix/tracking-issue (pull request #1643)
Fix/tracking issue: add try/catch around promises * Test * Cleaning Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -7,6 +7,7 @@ import { getProfile } from "@/lib/trpc/memoizedRequests"
|
||||
import { auth } from "@/auth"
|
||||
import { getIntl } from "@/i18n"
|
||||
import { getLang } from "@/i18n/serverContext"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
|
||||
export async function ProtectedLayout({ children }: React.PropsWithChildren) {
|
||||
const intl = await getIntl()
|
||||
@@ -22,7 +23,7 @@ export async function ProtectedLayout({ children }: React.PropsWithChildren) {
|
||||
|
||||
const redirectURL = `/${getLang()}/login?redirectTo=${redirectTo}`
|
||||
|
||||
if (!session) {
|
||||
if (!isValidSession(session)) {
|
||||
console.log(`[layout:protected] no session, redirecting to: ${redirectURL}`)
|
||||
redirect(redirectURL)
|
||||
}
|
||||
|
||||
@@ -93,10 +93,20 @@ export default function RouterTransition({
|
||||
}
|
||||
|
||||
const trackPerformance = async () => {
|
||||
const [pageLoadTime, lcpTime] = await Promise.all([
|
||||
promiseWithTimeout(getPageLoadTimeEntry(), 3000),
|
||||
promiseWithTimeout(getLCPTimeEntry(), 3000),
|
||||
])
|
||||
let pageLoadTime: number | undefined = undefined
|
||||
let lcpTime: number | undefined = undefined
|
||||
|
||||
try {
|
||||
pageLoadTime = await promiseWithTimeout(getPageLoadTimeEntry(), 3000)
|
||||
} catch (error) {
|
||||
console.error("Error obtaining pageLoadTime:", error)
|
||||
}
|
||||
|
||||
try {
|
||||
lcpTime = await promiseWithTimeout(getLCPTimeEntry(), 3000)
|
||||
} catch (error) {
|
||||
console.error("Error obtaining lcpTime:", error)
|
||||
}
|
||||
|
||||
const trackingData = {
|
||||
...pageData,
|
||||
|
||||
Reference in New Issue
Block a user