Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(analytics): skip aggregated Tinybird fallback with pathname filter

Richie McIlroy0a2969ff706f
diff --git a/apps/web/app/(org)/dashboard/analytics/data.ts b/apps/web/app/(org)/dashboard/analytics/data.ts
index a2d487544..2f3e069bb 100644
--- a/apps/web/app/(org)/dashboard/analytics/data.ts
+++ b/apps/web/app/(org)/dashboard/analytics/data.ts
@@ -799,10 +799,15 @@ const queryBrowsers = (
`;
type Row = { name: string; views: number };
- return fallbackIfEmpty(
- withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
- withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql)),
- ).pipe(
+ const rawEffect = withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql));
+ const effect = pathnameFilter
+ ? rawEffect
+ : fallbackIfEmpty(
+ withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
+ rawEffect,
+ );
+
+ return effect.pipe(
Effect.map((rows: Row[]) =>
rows.map((row: Row) => ({
name: row.name,
@@ -848,10 +853,15 @@ const queryDevices = (
`;
type Row = { name: string; views: number };
- return fallbackIfEmpty(
- withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
- withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql)),
- ).pipe(
+ const rawEffect = withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql));
+ const effect = pathnameFilter
+ ? rawEffect
+ : fallbackIfEmpty(
+ withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
+ rawEffect,
+ );
+
+ return effect.pipe(
Effect.map((rows: Row[]) =>
rows.map((row: Row) => ({
name: row.name,
@@ -897,10 +907,15 @@ const queryOperatingSystems = (
`;
type Row = { name: string; views: number };
- return fallbackIfEmpty(
- withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
- withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql)),
- ).pipe(
+ const rawEffect = withTinybirdFallback<Row>(tinybird.querySql<Row>(rawSql));
+ const effect = pathnameFilter
+ ? rawEffect
+ : fallbackIfEmpty(
+ withTinybirdFallback<Row>(tinybird.querySql<Row>(aggregatedSql)),
+ rawEffect,
+ );
+
+ return effect.pipe(
Effect.map((rows: Row[]) =>
rows.map((row: Row) => ({
name: row.name,