OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix(dashboard): actually lazy load reports
Carl-Gerhard Lindesvärd2329982cd14d
diff --git a/apps/dashboard/src/components/report-chart/area/index.tsx b/apps/dashboard/src/components/report-chart/area/index.tsxindex 5f3f7e256..0b9269f06 100644--- a/apps/dashboard/src/components/report-chart/area/index.tsx+++ b/apps/dashboard/src/components/report-chart/area/index.tsx@@ -13,6 +13,7 @@ export function ReportAreaChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/bar/index.tsx b/apps/dashboard/src/components/report-chart/bar/index.tsxindex 330f67471..006903929 100644--- a/apps/dashboard/src/components/report-chart/bar/index.tsx+++ b/apps/dashboard/src/components/report-chart/bar/index.tsx@@ -12,6 +12,7 @@ export function ReportBarChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/funnel/index.tsx b/apps/dashboard/src/components/report-chart/funnel/index.tsxindex b9728ebf0..d8889b779 100644--- a/apps/dashboard/src/components/report-chart/funnel/index.tsx+++ b/apps/dashboard/src/components/report-chart/funnel/index.tsx@@ -31,6 +31,7 @@ export function ReportFunnelChart() {};const res = api.chart.funnel.useQuery(input, {keepPreviousData: true,+ enabled: !isLazyLoading,});if (isLazyLoading || res.isLoading) {diff --git a/apps/dashboard/src/components/report-chart/histogram/index.tsx b/apps/dashboard/src/components/report-chart/histogram/index.tsxindex 197c45e1a..c578ed1a3 100644--- a/apps/dashboard/src/components/report-chart/histogram/index.tsx+++ b/apps/dashboard/src/components/report-chart/histogram/index.tsx@@ -13,6 +13,7 @@ export function ReportHistogramChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/line/index.tsx b/apps/dashboard/src/components/report-chart/line/index.tsxindex 09c672392..10bfa00c7 100644--- a/apps/dashboard/src/components/report-chart/line/index.tsx+++ b/apps/dashboard/src/components/report-chart/line/index.tsx@@ -14,6 +14,7 @@ export function ReportLineChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/map/index.tsx b/apps/dashboard/src/components/report-chart/map/index.tsxindex 4ee5376c2..0c3cc172c 100644--- a/apps/dashboard/src/components/report-chart/map/index.tsx+++ b/apps/dashboard/src/components/report-chart/map/index.tsx@@ -13,6 +13,7 @@ export function ReportMapChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/metric/index.tsx b/apps/dashboard/src/components/report-chart/metric/index.tsxindex 5df27988a..bea88f05a 100644--- a/apps/dashboard/src/components/report-chart/metric/index.tsx+++ b/apps/dashboard/src/components/report-chart/metric/index.tsx@@ -9,6 +9,7 @@ export function ReportMetricChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/pie/index.tsx b/apps/dashboard/src/components/report-chart/pie/index.tsxindex 60514ca02..621f91af3 100644--- a/apps/dashboard/src/components/report-chart/pie/index.tsx+++ b/apps/dashboard/src/components/report-chart/pie/index.tsx@@ -13,6 +13,7 @@ export function ReportPieChart() {const res = api.chart.chart.useQuery(report, {keepPreviousData: true,staleTime: 1000 * 60 * 1,+ enabled: !isLazyLoading,});if (diff --git a/apps/dashboard/src/components/report-chart/retention/index.tsx b/apps/dashboard/src/components/report-chart/retention/index.tsxindex 9fc0e11d4..27b835c99 100644--- a/apps/dashboard/src/components/report-chart/retention/index.tsx+++ b/apps/dashboard/src/components/report-chart/retention/index.tsx@@ -25,7 +25,8 @@ export function ReportRetentionChart() {} = useReportChartContext();const firstEvent = (events[0]?.filters[0]?.value ?? []).map(String);const secondEvent = (events[1]?.filters[0]?.value ?? []).map(String);- const isEnabled = firstEvent.length > 0 && secondEvent.length > 0;+ const isEnabled =+ firstEvent.length > 0 && secondEvent.length > 0 && !isLazyLoading;const res = api.chart.cohort.useQuery({firstEvent,@@ -38,6 +39,8 @@ export function ReportRetentionChart() {interval,},{+ keepPreviousData: true,+ staleTime: 1000 * 60 * 1,enabled: isEnabled,},);