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 build errors, remove active users link on share page.

Francis Cao0bd5e70df773
diff --git a/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx b/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx
index 1739cb4c1..642e9fe22 100644
--- a/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx
+++ b/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx
@@ -31,7 +31,7 @@ export function WebsiteHeader({
titleHref={allowLink ? renderUrl(`/websites/${website.id}`, false) : undefined}
>
<Row alignItems="center" gap="6" wrap="wrap">
- <ActiveUsers websiteId={website.id} />
+ <ActiveUsers websiteId={website.id} allowLink={allowLink} />
{showActions && (
<LinkButton href={renderUrl(`/websites/${website.id}/settings`, false)}>
diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx
index 1bfa79ccd..17daaeed9 100644
--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx
@@ -1,7 +1,7 @@
import { Column, Heading, Row, SearchField, Text } from '@umami/react-zen';
import Link from '@/components/common/Link';
import { useMemo, useState } from 'react';
-import { FixedSizeList } from 'react-window';
+import { List, type RowComponentProps } from 'react-window';
import { SessionModal } from '@/app/(main)/websites/[websiteId]/sessions/SessionModal';
import { useFormat } from '@/components//hooks/useFormat';
import { Avatar } from '@/components/common/Avatar';
@@ -121,7 +121,7 @@ export function RealtimeLog({ data }: { data: any }) {
}
};
- const TableRow = ({ index, style }) => {
+ const TableRow = ({ index, style, logs }: RowComponentProps<{ logs: any[] }>) => {
const row = logs[index];
return (
<Row alignItems="center" style={style} gap>
@@ -195,9 +195,14 @@ export function RealtimeLog({ data }: { data: any }) {
<Column>
{logs?.length === 0 && <Empty />}
{logs?.length > 0 && (
- <FixedSizeList width="100%" height={500} itemCount={logs.length} itemSize={50}>
- {TableRow}
- </FixedSizeList>
+ <List
+ rowComponent={TableRow}
+ rowCount={logs.length}
+ rowHeight={50}
+ rowProps={{ logs }}
+ defaultHeight={500}
+ style={{ width: '100%' }}
+ />
)}
</Column>
<SessionModal websiteId={website.id} />
diff --git a/src/components/hooks/queries/useActiveUsersQuery.ts b/src/components/hooks/queries/useActiveUsersQuery.ts
index 42867c19d..7190a2f9c 100644
--- a/src/components/hooks/queries/useActiveUsersQuery.ts
+++ b/src/components/hooks/queries/useActiveUsersQuery.ts
@@ -1,7 +1,7 @@
import type { ReactQueryOptions } from '@/lib/types';
import { useApi } from '../useApi';
-export function useActyiveUsersQuery(websiteId: string, options?: ReactQueryOptions) {
+export function useActiveUsersQuery(websiteId: string, options?: ReactQueryOptions) {
const { get, useQuery } = useApi();
return useQuery<any>({
queryKey: ['websites:active', websiteId],
diff --git a/src/components/metrics/ActiveUsers.tsx b/src/components/metrics/ActiveUsers.tsx
index f1aa989c6..9d58e82cc 100644
--- a/src/components/metrics/ActiveUsers.tsx
+++ b/src/components/metrics/ActiveUsers.tsx
@@ -7,17 +7,19 @@ export function ActiveUsers({
websiteId,
value,
refetchInterval = 60000,
+ allowLink = true,
}: {
websiteId: string;
value?: number;
refetchInterval?: number;
+ allowLink?: boolean;
}) {
const { t, labels } = useMessages();
const { data } = useActiveUsersQuery(websiteId, { refetchInterval });
const count = useMemo(() => {
if (websiteId) {
- return data?.visitors || 0;
+ return data?.visitors || 10;
}
return value !== undefined ? value : 0;
@@ -27,13 +29,17 @@ export function ActiveUsers({
return null;
}
- return (
- <Link href={`/websites/${websiteId}/realtime`}>
- <StatusLight variant="success">
- <Text size="sm" weight="medium">
- {count} {t(labels.online)}
- </Text>
- </StatusLight>
- </Link>
+ const content = (
+ <StatusLight variant="success">
+ <Text size="sm" weight="medium">
+ {count} {t(labels.online)}
+ </Text>
+ </StatusLight>
);
+
+ if (!allowLink) {
+ return content;
+ }
+
+ return <Link href={`/websites/${websiteId}/realtime`}>{content}</Link>;
}
\ No newline at end of file