OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix(dashboard): crashes when trial expired for some intervals
Carl-Gerhard Lindesvärdec5207947b62
diff --git a/apps/dashboard/src/components/overview/overview-metrics.tsx b/apps/dashboard/src/components/overview/overview-metrics.tsxindex 9c77efd4b..10a8010f8 100644--- a/apps/dashboard/src/components/overview/overview-metrics.tsx+++ b/apps/dashboard/src/components/overview/overview-metrics.tsx@@ -219,10 +219,14 @@ const { Tooltip, TooltipProvider } = createChartTooltip<interval: IInterval;}>(({ context: { metric, interval }, data: dataArray }) => {- const data = dataArray[0]!;+ const data = dataArray[0];const formatDate = useFormatDateInterval(interval);const number = useNumber();+ if (!data) {+ return null;+ }+return (<><div className="flex justify-between gap-8 text-muted-foreground">diff --git a/packages/trpc/src/routers/overview.ts b/packages/trpc/src/routers/overview.tsindex 813106236..6b7bcf956 100644--- a/packages/trpc/src/routers/overview.ts+++ b/packages/trpc/src/routers/overview.ts@@ -50,6 +50,10 @@ function getCurrentAndPrevious<);if (endDate) {current.endDate = endDate;+ // Only expired trial scenarios+ if (new Date(current.startDate) > new Date(current.endDate)) {+ current.startDate = current.endDate;+ }}const res = await Promise.all([fn({