Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix getActiveVisitors return type

Francis Cao5468ca5dd32d
diff --git a/src/components/metrics/ActiveUsers.tsx b/src/components/metrics/ActiveUsers.tsx
index 9a5ff327a..05d0fc1d6 100644
--- a/src/components/metrics/ActiveUsers.tsx
+++ b/src/components/metrics/ActiveUsers.tsx
@@ -24,7 +24,7 @@ export function ActiveUsers({
const count = useMemo(() => {
if (websiteId) {
- return data?.[0]?.x || 0;
+ return data?.x || 0;
}
return value !== undefined ? value : 0;
diff --git a/src/queries/analytics/getActiveVisitors.ts b/src/queries/analytics/getActiveVisitors.ts
index 962bea350..9913977f5 100644
--- a/src/queries/analytics/getActiveVisitors.ts
+++ b/src/queries/analytics/getActiveVisitors.ts
@@ -13,7 +13,7 @@ export async function getActiveVisitors(...args: [websiteId: string]) {
async function relationalQuery(websiteId: string) {
const { rawQuery } = prisma;
- return rawQuery(
+ const result = await rawQuery(
`
select count(distinct session_id) x
from website_event
@@ -22,6 +22,8 @@ async function relationalQuery(websiteId: string) {
`,
{ websiteId, startAt: subMinutes(new Date(), 5) },
);
+
+ return result[0] ?? null;
}
async function clickhouseQuery(websiteId: string): Promise<{ x: number }> {