diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ca04cd9..86b5e4c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -364,8 +364,6 @@ importers: specifier: ^5.9.3 version: 5.9.3 - dist: {} - packages: '@ampproject/remapping@2.3.0': diff --git a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx index b9f34e48..ca82d8d4 100644 --- a/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx +++ b/src/app/(main)/websites/[websiteId]/sessions/SessionActivity.tsx @@ -42,6 +42,19 @@ export function SessionActivity({ {data?.map(({ eventId, createdAt, urlPath, eventName, visitId, hasData }) => { + if (!createdAt) { + if (process.env.NODE_ENV !== 'production') { + // eslint-disable-next-line no-console + console.error('[SessionActivity] Event missing createdAt', { + eventId, + visitId, + urlPath, + eventName, + }); + } + return null; + } + const showHeader = !lastDay || !isSameDay(new Date(lastDay), new Date(createdAt)); lastDay = createdAt; diff --git a/src/app/(main)/websites/[websiteId]/sessions/SessionInfo.tsx b/src/app/(main)/websites/[websiteId]/sessions/SessionInfo.tsx index e968daba..1809ae59 100644 --- a/src/app/(main)/websites/[websiteId]/sessions/SessionInfo.tsx +++ b/src/app/(main)/websites/[websiteId]/sessions/SessionInfo.tsx @@ -11,6 +11,18 @@ export function SessionInfo({ data }) { const { formatValue } = useFormat(); const { getRegionName } = useRegionNames(locale); + if (process.env.NODE_ENV !== 'production') { + if (!data.lastAt || !data.firstAt) { + // eslint-disable-next-line no-console + console.error('[SessionInfo] Session missing date fields', { + sessionId: data.id, + hasLastAt: !!data.lastAt, + hasFirstAt: !!data.firstAt, + distinctId: data.distinctId, + }); + } + } + return ( }> @@ -18,11 +30,11 @@ export function SessionInfo({ data }) { }> - + {data.lastAt ? : '—'} }> - + {data.firstAt ? : '—'} - {(row: any) => } + {(row: any) => { + if (!row.createdAt) { + if (process.env.NODE_ENV !== 'production') { + // eslint-disable-next-line no-console + console.error('[SessionsTable] Session missing createdAt', { + sessionId: row.id, + visits: row.visits, + views: row.views, + }); + } + return '—'; + } + return ; + }} ); diff --git a/src/components/common/DateDistance.tsx b/src/components/common/DateDistance.tsx index b305f857..79bc9642 100644 --- a/src/components/common/DateDistance.tsx +++ b/src/components/common/DateDistance.tsx @@ -6,6 +6,14 @@ export function DateDistance({ date }: { date: Date }) { const { formatTimezoneDate } = useTimezone(); const { dateLocale } = useLocale(); + if (!date || isNaN(date.getTime())) { + if (process.env.NODE_ENV !== 'production') { + // eslint-disable-next-line no-console + console.error('[DateDistance] Invalid date received', { date }); + } + return ; + } + return ( {formatDistanceToNow(date, { addSuffix: true, locale: dateLocale })}