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.

Updates for cloud mode.

Mike Caof40e1b44f3c0
diff --git a/next.config.ts b/next.config.ts
index 86aaae953..e229cb44a 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,15 +1,10 @@
import 'dotenv/config';
-import { createRequire } from 'module';
-
-const require = createRequire(import.meta.url);
-
-const pkg = require('./package.json');
+import pkg from './package.json' assert { type: 'json' };
const TRACKER_SCRIPT = '/script.js';
const basePath = process.env.BASE_PATH;
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
-const cloudMode = process.env.CLOUD_MODE;
const cloudUrl = process.env.CLOUD_URL;
const corsMaxAge = process.env.CORS_MAX_AGE;
const defaultLocale = process.env.DEFAULT_LOCALE;
@@ -162,7 +157,7 @@ if (trackerScriptName) {
}
}
-if (cloudMode && cloudUrl) {
+if (cloudUrl) {
redirects.push({
source: '/login',
destination: cloudUrl,
@@ -175,7 +170,6 @@ export default {
reactStrictMode: false,
env: {
basePath,
- cloudMode,
cloudUrl,
currentVersion: pkg.version,
defaultLocale,
diff --git a/package.components.json b/package.components.json
index 048673e89..27887f8f6 100644
--- a/package.components.json
+++ b/package.components.json
@@ -1,6 +1,6 @@
{
"name": "@umami/components",
- "version": "0.115.0",
+ "version": "0.116.0",
"description": "Umami React components.",
"author": "Mike Cao <[email protected]>",
"license": "MIT",
diff --git a/package.json b/package.json
index e6fe20f49..7d3528fa5 100644
--- a/package.json
+++ b/package.json
@@ -82,7 +82,7 @@
"@react-spring/web": "^10.0.1",
"@svgr/cli": "^8.1.0",
"@tanstack/react-query": "^5.85.5",
- "@umami/react-zen": "^0.176.0",
+ "@umami/react-zen": "^0.179.0",
"@umami/redis-client": "^0.29.0",
"bcryptjs": "^3.0.2",
"chalk": "^5.6.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3f5ea9413..a587f004e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -45,8 +45,8 @@ importers:
specifier: ^5.85.5
version: 5.85.5([email protected])
'@umami/react-zen':
- specifier: ^0.176.0
+ specifier: ^0.179.0
'@umami/redis-client':
specifier: ^0.29.0
version: 0.29.0
@@ -2735,8 +2735,8 @@ packages:
'@prisma/client': ^6.1.0
'@prisma/extension-read-replicas': ^0.4.1
- '@umami/[email protected]':
- resolution: {integrity: sha512-GP+Df68w0Kfo09ZC5WgK1YCg/IbqOz7HWPw8PLYG3shYm+feuF8ND8DHjoTle4qXY4oRJFufXCEsDbTb8FITkg==}
+ '@umami/[email protected]':
+ resolution: {integrity: sha512-OS6Xa1tMO2PfXYXEB98XyOBctvnw/gE2eO3gK5mkJF5P3Ati6Z9KpTpj28Fxi7PgJiWYqcQ5enFzQqHXjYy/3A==}
resolution: {integrity: sha512-Jaqh++jskqDB7ny75pfC02OvKp1JTS4asGDsFrRL3qy8sxL3PAl9+/mybCJe4/6vWrXDJKqpgkSfUDJq2bFjyw==}
@@ -10333,7 +10333,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@fontsource/jetbrains-mono': 5.2.6
'@internationalized/date': 3.9.0
diff --git a/scripts/check-env.js b/scripts/check-env.js
index 21de9469b..c73bed546 100644
--- a/scripts/check-env.js
+++ b/scripts/check-env.js
@@ -22,6 +22,13 @@ if (!process.env.SKIP_DB_CHECK && !process.env.DATABASE_TYPE) {
checkMissing(['DATABASE_URL']);
}
-if (process.env.CLOUD_MODE) {
- checkMissing(['CLOUD_URL', 'KAFKA_BROKER', 'KAFKA_URL', 'REDIS_URL', 'KAFKA_SASL_MECHANISM']);
+if (process.env.CLOUD_URL) {
+ checkMissing([
+ 'CLOUD_URL',
+ 'CLICKHOUSE_URL',
+ 'REDIS_URL',
+ 'KAFKA_BROKER',
+ 'KAFKA_URL',
+ 'KAFKA_SASL_MECHANISM',
+ ]);
}
diff --git a/src/app/(main)/App.tsx b/src/app/(main)/App.tsx
index bb33dc87f..6c14a484a 100644
--- a/src/app/(main)/App.tsx
+++ b/src/app/(main)/App.tsx
@@ -11,8 +11,8 @@ export function App({ children }) {
const config = useConfig();
const pathname = usePathname();
- if (isLoading) {
- return <Loading position="page" />;
+ if (isLoading || !config) {
+ return <Loading placement="absolute" />;
}
if (error) {
diff --git a/src/app/(main)/SideNav.tsx b/src/app/(main)/SideNav.tsx
index a65640e13..7ffc98227 100644
--- a/src/app/(main)/SideNav.tsx
+++ b/src/app/(main)/SideNav.tsx
@@ -14,15 +14,13 @@ import {
Link as LinkIcon,
Logo,
Pixel,
- Settings,
PanelLeft,
} from '@/components/icons';
import { useMessages, useNavigation, useGlobalState } from '@/components/hooks';
import { TeamsButton } from '@/components/input/TeamsButton';
import { PanelButton } from '@/components/input/PanelButton';
-import { ProfileButton } from '@/components/input/ProfileButton';
-import { LanguageButton } from '@/components/input/LanguageButton';
import { Key } from 'react';
+import { SettingsButton } from '@/components/input/SettingsButton';
export function SideNav(props: SidebarProps) {
const { formatMessage, labels } = useMessages();
@@ -58,17 +56,7 @@ export function SideNav(props: SidebarProps) {
},
];
- const bottomLinks = [
- {
- id: 'settings',
- label: formatMessage(labels.settings),
- path: renderUrl('/settings'),
- icon: <Settings />,
- },
- ];
-
const handleSelect = (id: Key) => {
- console.log({ id });
router.push(id === 'user' ? '/websites' : `/teams/${id}/websites`);
};
@@ -78,18 +66,15 @@ export function SideNav(props: SidebarProps) {
<SidebarSection onClick={() => setIsCollapsed(false)}>
<SidebarHeader
label="umami"
- icon={
- isCollapsed && !hasNav ? (
- <PanelLeft />
- ) : (
- <Logo onClick={() => (window.location.href = process.env.cloudUrl)} />
- )
- }
+ icon={isCollapsed && !hasNav ? <PanelLeft /> : <Logo />}
style={{ maxHeight: 40 }}
>
{!isCollapsed && !hasNav && <PanelButton />}
</SidebarHeader>
</SidebarSection>
+ <SidebarSection paddingTop="0" paddingBottom="0" justifyContent="center">
+ <TeamsButton showText={!hasNav && !isCollapsed} onAction={handleSelect} />
+ </SidebarSection>
<SidebarSection flexGrow={1}>
{links.map(({ id, path, label, icon }) => {
return (
@@ -104,30 +89,10 @@ export function SideNav(props: SidebarProps) {
);
})}
</SidebarSection>
- <SidebarSection style={{ paddingTop: 0, paddingBottom: 0 }}>
- <TeamsButton showText={!hasNav && !isCollapsed} onAction={handleSelect} />
- </SidebarSection>
- <SidebarSection>
- {bottomLinks.map(({ id, path, label, icon }) => {
- return (
- <Link key={id} href={path} role="button">
- <SidebarItem
- label={label}
- icon={icon}
- isSelected={pathname.includes(path)}
- role="button"
- />
- </Link>
- );
- })}
- <Row alignItems="center" height="40px">
- <ProfileButton />
- {!isCollapsed && !hasNav && (
- <Row>
- <LanguageButton />
- <ThemeButton />
- </Row>
- )}
+ <SidebarSection justifyContent="flex-start">
+ <Row>
+ <SettingsButton />
+ {!isCollapsed && !hasNav && <ThemeButton />}
</Row>
</SidebarSection>
</Sidebar>
diff --git a/src/app/(main)/UpdateNotice.tsx b/src/app/(main)/UpdateNotice.tsx
index 357287912..c971d4038 100644
--- a/src/app/(main)/UpdateNotice.tsx
+++ b/src/app/(main)/UpdateNotice.tsx
@@ -18,7 +18,7 @@ export function UpdateNotice({ user, config }) {
!config?.updatesDisabled &&
!config?.privateMode &&
!pathname.includes('/share/') &&
- !process.env.cloudMode &&
+ !process.env.cloudUrl &&
!dismissed;
const updateCheck = useCallback(() => {
diff --git a/src/app/(main)/admin/AdminLayout.tsx b/src/app/(main)/admin/AdminLayout.tsx
index a33b745af..eb4c2ffa5 100644
--- a/src/app/(main)/admin/AdminLayout.tsx
+++ b/src/app/(main)/admin/AdminLayout.tsx
@@ -11,7 +11,7 @@ export function AdminLayout({ children }: { children: ReactNode }) {
const { formatMessage, labels } = useMessages();
const { pathname } = useNavigation();
- if (!user.isAdmin) {
+ if (!user.isAdmin || process.env.cloudUrl) {
return null;
}
diff --git a/src/app/(main)/admin/layout.tsx b/src/app/(main)/admin/layout.tsx
index 634fc6588..3dea41422 100644
--- a/src/app/(main)/admin/layout.tsx
+++ b/src/app/(main)/admin/layout.tsx
@@ -2,7 +2,7 @@ import { Metadata } from 'next';
import { AdminLayout } from './AdminLayout';
export default function ({ children }) {
- if (process.env.cloudMode) {
+ if (process.env.cloudUrl) {
return null;
}
diff --git a/src/app/(main)/admin/users/[userId]/UserProvider.tsx b/src/app/(main)/admin/users/[userId]/UserProvider.tsx
index 8ac321dab..82dba512f 100644
--- a/src/app/(main)/admin/users/[userId]/UserProvider.tsx
+++ b/src/app/(main)/admin/users/[userId]/UserProvider.tsx
@@ -9,7 +9,7 @@ export function UserProvider({ userId, children }: { userId: string; children: R
const { data: user, isFetching, isLoading } = useUserQuery(userId);
if (isFetching && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
if (!user) {
diff --git a/src/app/(main)/links/LinkEditForm.tsx b/src/app/(main)/links/LinkEditForm.tsx
index b7a458dd6..54237e435 100644
--- a/src/app/(main)/links/LinkEditForm.tsx
+++ b/src/app/(main)/links/LinkEditForm.tsx
@@ -78,7 +78,7 @@ export function LinkEditForm({
}, [data]);
if (linkId && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
return (
diff --git a/src/app/(main)/links/LinkProvider.tsx b/src/app/(main)/links/LinkProvider.tsx
index 0a8900cf1..de97cdcf5 100644
--- a/src/app/(main)/links/LinkProvider.tsx
+++ b/src/app/(main)/links/LinkProvider.tsx
@@ -10,7 +10,7 @@ export function LinkProvider({ linkId, children }: { linkId?: string; children:
const { data: link, isLoading, isFetching } = useLinkQuery(linkId);
if (isFetching && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
if (!link) {
diff --git a/src/app/(main)/pixels/PixelEditForm.tsx b/src/app/(main)/pixels/PixelEditForm.tsx
index bd29e69e0..4d3def87f 100644
--- a/src/app/(main)/pixels/PixelEditForm.tsx
+++ b/src/app/(main)/pixels/PixelEditForm.tsx
@@ -70,7 +70,7 @@ export function PixelEditForm({
}, [data]);
if (pixelId && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
return (
diff --git a/src/app/(main)/pixels/PixelProvider.tsx b/src/app/(main)/pixels/PixelProvider.tsx
index d46b687d1..3ba4c5e5c 100644
--- a/src/app/(main)/pixels/PixelProvider.tsx
+++ b/src/app/(main)/pixels/PixelProvider.tsx
@@ -10,7 +10,7 @@ export function PixelProvider({ pixelId, children }: { pixelId?: string; childre
const { data: pixel, isLoading, isFetching } = usePixelQuery(pixelId);
if (isFetching && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
if (!pixel) {
diff --git a/src/app/(main)/settings/layout.tsx b/src/app/(main)/settings/layout.tsx
index 1d4c418b5..6f409e483 100644
--- a/src/app/(main)/settings/layout.tsx
+++ b/src/app/(main)/settings/layout.tsx
@@ -2,6 +2,10 @@ import { Metadata } from 'next';
import { SettingsLayout } from './SettingsLayout';
export default function ({ children }) {
+ if (process.env.cloudUrl) {
+ return null;
+ }
+
return <SettingsLayout>{children}</SettingsLayout>;
}
diff --git a/src/app/(main)/settings/preferences/DateRangeSetting.tsx b/src/app/(main)/settings/preferences/DateRangeSetting.tsx
index ff92a8b0f..2b81985f5 100644
--- a/src/app/(main)/settings/preferences/DateRangeSetting.tsx
+++ b/src/app/(main)/settings/preferences/DateRangeSetting.tsx
@@ -15,7 +15,7 @@ export function DateRangeSetting() {
return (
<Row gap="3">
- <DateFilter value={value} onChange={handleChange} />
+ <DateFilter value={value} onChange={handleChange} placement="bottom start" />
<Button onPress={handleReset}>{formatMessage(labels.reset)}</Button>
</Row>
);
diff --git a/src/app/(main)/settings/preferences/LanguageSetting.tsx b/src/app/(main)/settings/preferences/LanguageSetting.tsx
index 9e32196a6..0bcaa6ba8 100644
--- a/src/app/(main)/settings/preferences/LanguageSetting.tsx
+++ b/src/app/(main)/settings/preferences/LanguageSetting.tsx
@@ -26,7 +26,7 @@ export function LanguageSetting() {
};
return (
- <Row gap="3">
+ <Row gap>
<Select
value={locale}
onChange={val => saveLocale(val as string)}
diff --git a/src/app/(main)/settings/preferences/TimezoneSetting.tsx b/src/app/(main)/settings/preferences/TimezoneSetting.tsx
index 87db54e5d..68d8fadb0 100644
--- a/src/app/(main)/settings/preferences/TimezoneSetting.tsx
+++ b/src/app/(main)/settings/preferences/TimezoneSetting.tsx
@@ -22,7 +22,7 @@ export function TimezoneSetting() {
};
return (
- <Row gap="3">
+ <Row gap>
<Select
value={timezone}
onChange={(value: any) => saveTimezone(value)}
diff --git a/src/app/(main)/settings/profile/ProfileSettings.tsx b/src/app/(main)/settings/profile/ProfileSettings.tsx
index b580d686a..156bf28e2 100644
--- a/src/app/(main)/settings/profile/ProfileSettings.tsx
+++ b/src/app/(main)/settings/profile/ProfileSettings.tsx
@@ -1,12 +1,12 @@
import { Row, Column, Label } from '@umami/react-zen';
-import { useLoginQuery, useMessages } from '@/components/hooks';
+import { useConfig, useLoginQuery, useMessages } from '@/components/hooks';
import { ROLES } from '@/lib/constants';
import { PasswordChangeButton } from './PasswordChangeButton';
export function ProfileSettings() {
const { user } = useLoginQuery();
const { formatMessage, labels } = useMessages();
- const cloudMode = !!process.env.cloudMode;
+ const { cloudMode } = useConfig();
if (!user) {
return null;
diff --git a/src/app/(main)/teams/TeamProvider.tsx b/src/app/(main)/teams/TeamProvider.tsx
index 1c139b17a..d4d319865 100644
--- a/src/app/(main)/teams/TeamProvider.tsx
+++ b/src/app/(main)/teams/TeamProvider.tsx
@@ -10,7 +10,7 @@ export function TeamProvider({ teamId, children }: { teamId?: string; children:
const { data: team, isLoading, isFetching } = useTeamQuery(teamId);
if (isFetching && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
if (!team) {
diff --git a/src/app/(main)/teams/TeamsDataTable.tsx b/src/app/(main)/teams/TeamsDataTable.tsx
index 7700627c1..b023f77ea 100644
--- a/src/app/(main)/teams/TeamsDataTable.tsx
+++ b/src/app/(main)/teams/TeamsDataTable.tsx
@@ -1,10 +1,10 @@
+import { ReactNode } from 'react';
+import Link from 'next/link';
import { DataGrid } from '@/components/common/DataGrid';
import { TeamsTable } from './TeamsTable';
import { useLoginQuery, useUserTeamsQuery } from '@/components/hooks';
-import { ReactNode } from 'react';
export function TeamsDataTable({
- allowEdit,
showActions,
}: {
allowEdit?: boolean;
@@ -14,10 +14,18 @@ export function TeamsDataTable({
const { user } = useLoginQuery();
const query = useUserTeamsQuery(user.id);
+ const renderLink = (row: any) => {
+ return (
+ <Link key={row.id} href={`/teams/${row.id}`}>
+ {row.name}
+ </Link>
+ );
+ };
+
return (
<DataGrid query={query}>
{({ data }) => {
- return <TeamsTable data={data} allowEdit={allowEdit} showActions={showActions} />;
+ return <TeamsTable data={data} showActions={showActions} renderLink={renderLink} />;
}}
</DataGrid>
);
diff --git a/src/app/(main)/teams/TeamsHeader.tsx b/src/app/(main)/teams/TeamsHeader.tsx
index 61244033e..f7d7e5203 100644
--- a/src/app/(main)/teams/TeamsHeader.tsx
+++ b/src/app/(main)/teams/TeamsHeader.tsx
@@ -1,14 +1,14 @@
import { Row } from '@umami/react-zen';
import { PageHeader } from '@/components/common/PageHeader';
import { ROLES } from '@/lib/constants';
-import { useLoginQuery, useMessages } from '@/components/hooks';
+import { useConfig, useLoginQuery, useMessages } from '@/components/hooks';
import { TeamsJoinButton } from './TeamsJoinButton';
import { TeamsAddButton } from './TeamsAddButton';
export function TeamsHeader({ allowCreate = true }: { allowCreate?: boolean }) {
const { formatMessage, labels } = useMessages();
const { user } = useLoginQuery();
- const cloudMode = !!process.env.cloudMode;
+ const { cloudMode } = useConfig();
return (
<PageHeader title={formatMessage(labels.teams)}>
diff --git a/src/app/(main)/teams/TeamsTable.tsx b/src/app/(main)/teams/TeamsTable.tsx
index d77ede111..aaf27f524 100644
--- a/src/app/(main)/teams/TeamsTable.tsx
+++ b/src/app/(main)/teams/TeamsTable.tsx
@@ -1,25 +1,25 @@
import { DataColumn, DataTable, Icon, MenuItem, Text, Row } from '@umami/react-zen';
-import { useMessages, useNavigation } from '@/components/hooks';
+import { useMessages } from '@/components/hooks';
import { Eye, Edit } from '@/components/icons';
import { ROLES } from '@/lib/constants';
import { MenuButton } from '@/components/input/MenuButton';
-import Link from 'next/link';
+import { ReactNode } from 'react';
export function TeamsTable({
data = [],
showActions = false,
+ renderLink,
}: {
data: any[];
- allowEdit?: boolean;
showActions?: boolean;
+ renderLink?: (row: any) => ReactNode;
}) {
const { formatMessage, labels } = useMessages();
- const { renderUrl } = useNavigation();
return (
<DataTable data={data}>
<DataColumn id="name" label={formatMessage(labels.name)}>
- {(row: any) => <Link href={renderUrl(`/settings/teams/${row.id}`)}>{row.name}</Link>}
+ {renderLink}
</DataColumn>
<DataColumn id="owner" label={formatMessage(labels.owner)}>
{(row: any) => row?.members?.find(({ role }) => role === ROLES.teamOwner)?.user?.username}
diff --git a/src/app/(main)/websites/WebsiteProvider.tsx b/src/app/(main)/websites/WebsiteProvider.tsx
index 3f439550e..4129cdd3c 100644
--- a/src/app/(main)/websites/WebsiteProvider.tsx
+++ b/src/app/(main)/websites/WebsiteProvider.tsx
@@ -16,7 +16,7 @@ export function WebsiteProvider({
const { data: website, isFetching, isLoading } = useWebsiteQuery(websiteId);
if (isFetching && isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
if (!website) {
diff --git a/src/app/(main)/websites/WebsitesDataTable.tsx b/src/app/(main)/websites/WebsitesDataTable.tsx
index 5015264a2..612dc502b 100644
--- a/src/app/(main)/websites/WebsitesDataTable.tsx
+++ b/src/app/(main)/websites/WebsitesDataTable.tsx
@@ -1,6 +1,7 @@
+import Link from 'next/link';
import { WebsitesTable } from './WebsitesTable';
import { DataGrid } from '@/components/common/DataGrid';
-import { useUserWebsitesQuery } from '@/components/hooks';
+import { useNavigation, useUserWebsitesQuery } from '@/components/hooks';
export function WebsitesDataTable({
teamId,
@@ -14,16 +15,21 @@ export function WebsitesDataTable({
showActions?: boolean;
}) {
const queryResult = useUserWebsitesQuery({ teamId });
+ const { renderUrl } = useNavigation();
+
+ const renderLink = (row: any) => (
+ <Link href={renderUrl(`/websites/${row.id}`, false)}>{row.name}</Link>
+ );
return (
<DataGrid query={queryResult} allowSearch allowPaging>
{({ data }) => (
<WebsitesTable
- teamId={teamId}
data={data}
showActions={showActions}
allowEdit={allowEdit}
allowView={allowView}
+ renderLink={renderLink}
/>
)}
</DataGrid>
diff --git a/src/app/(main)/websites/WebsitesTable.tsx b/src/app/(main)/websites/WebsitesTable.tsx
index c2077eb1b..3fc22a988 100644
--- a/src/app/(main)/websites/WebsitesTable.tsx
+++ b/src/app/(main)/websites/WebsitesTable.tsx
@@ -3,27 +3,24 @@ import { Row, Text, Icon, DataTable, DataColumn, MenuItem } from '@umami/react-z
import { useMessages, useNavigation } from '@/components/hooks';
import { MenuButton } from '@/components/input/MenuButton';
import { Eye, SquarePen } from '@/components/icons';
-import Link from 'next/link';
-
-export interface WebsitesTableProps {
- data: Record<string, any>[];
- showActions?: boolean;
- allowEdit?: boolean;
- allowView?: boolean;
- teamId?: string;
- children?: ReactNode;
-}
export function WebsitesTable({
data = [],
showActions,
allowEdit,
allowView,
+ renderLink,
children,
-}: WebsitesTableProps) {
+}: {
+ data: Record<string, any>[];
+ showActions?: boolean;
+ allowEdit?: boolean;
+ allowView?: boolean;
+ renderLink?: (row: any) => ReactNode;
+ children?: ReactNode;
+}) {
const { formatMessage, labels } = useMessages();
- const { renderUrl, pathname } = useNavigation();
- const isSettings = pathname.includes('/settings');
+ const { renderUrl } = useNavigation();
if (!data?.length) {
return children;
@@ -32,11 +29,7 @@ export function WebsitesTable({
return (
<DataTable data={data}>
<DataColumn id="name" label={formatMessage(labels.name)}>
- {(row: any) => (
- <Link href={renderUrl(`${isSettings ? '/settings' : ''}/websites/${row.id}`, false)}>
- {row.name}
- </Link>
- )}
+ {renderLink}
</DataColumn>
<DataColumn id="domain" label={formatMessage(labels.domain)} />
{showActions && (
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/funnels/FunnelEditForm.tsx b/src/app/(main)/websites/[websiteId]/(reports)/funnels/FunnelEditForm.tsx
index 1cf2bca22..57675bdf7 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/funnels/FunnelEditForm.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/funnels/FunnelEditForm.tsx
@@ -50,7 +50,7 @@ export function FunnelEditForm({
};
if (id && !data) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
const defaultValues = {
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/goals/GoalEditForm.tsx b/src/app/(main)/websites/[websiteId]/(reports)/goals/GoalEditForm.tsx
index 5556e4d8c..2264ccf89 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/goals/GoalEditForm.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/goals/GoalEditForm.tsx
@@ -44,7 +44,7 @@ export function GoalEditForm({
};
if (id && !data) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
const defaultValues = {
diff --git a/src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx b/src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx
index 9e491a122..88e3d50de 100644
--- a/src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx
+++ b/src/app/(main)/websites/[websiteId]/cohorts/CohortEditForm.tsx
@@ -52,7 +52,7 @@ export function CohortEditForm({
};
if (cohortId && !data) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
const defaultValues = {
diff --git a/src/app/(main)/websites/[websiteId]/segments/SegmentEditForm.tsx b/src/app/(main)/websites/[websiteId]/segments/SegmentEditForm.tsx
index b9a85c66f..3be668d88 100644
--- a/src/app/(main)/websites/[websiteId]/segments/SegmentEditForm.tsx
+++ b/src/app/(main)/websites/[websiteId]/segments/SegmentEditForm.tsx
@@ -49,7 +49,7 @@ export function SegmentEditForm({
};
if (segmentId && !data) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
return (
diff --git a/src/app/(main)/websites/[websiteId]/settings/WebsiteTransferForm.tsx b/src/app/(main)/websites/[websiteId]/settings/WebsiteTransferForm.tsx
index d0daefa9d..4576b05e6 100644
--- a/src/app/(main)/websites/[websiteId]/settings/WebsiteTransferForm.tsx
+++ b/src/app/(main)/websites/[websiteId]/settings/WebsiteTransferForm.tsx
@@ -64,7 +64,7 @@ export function WebsiteTransferForm({
};
if (isLoading) {
- return <Loading icon="dots" position="center" />;
+ return <Loading icon="dots" placement="center" />;
}
return (
diff --git a/src/app/actions/getConfig.ts b/src/app/actions/getConfig.ts
index 9c26354ab..534c008e5 100644
--- a/src/app/actions/getConfig.ts
+++ b/src/app/actions/getConfig.ts
@@ -1,23 +1,27 @@
'use server';
export type Config = {
+ cloudMode: boolean;
+ cloudUrl?: string;
faviconUrl?: string;
+ linksUrl?: string;
+ pixelsUrl?: string;
privateMode: boolean;
telemetryDisabled: boolean;
trackerScriptName?: string;
updatesDisabled: boolean;
- linksUrl?: string;
- pixelsUrl?: string;
};
export async function getConfig(): Promise<Config> {
return {
+ cloudMode: !!process.env.CLOUD_URL,
+ cloudUrl: process.env.CLOUD_URL,
faviconUrl: process.env.FAVICON_URL,
+ linksUrl: process.env.LINKS_URL,
+ pixelsUrl: process.env.PIXELS_URL,
privateMode: !!process.env.PRIVATE_MODE,
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
updatesDisabled: !!process.env.DISABLE_UPDATES,
- linksUrl: process.env.LINKS_URL,
- pixelsUrl: process.env.PIXELS_URL,
};
}
diff --git a/src/app/logout/LogoutPage.tsx b/src/app/logout/LogoutPage.tsx
index 469886719..26dc48345 100644
--- a/src/app/logout/LogoutPage.tsx
+++ b/src/app/logout/LogoutPage.tsx
@@ -8,7 +8,7 @@ import { removeClientAuthToken } from '@/lib/client';
export function LogoutPage() {
const router = useRouter();
const { post } = useApi();
- const disabled = process.env.cloudMode;
+ const disabled = process.env.cloudUrl;
useEffect(() => {
async function logout() {
diff --git a/src/app/share/[...shareId]/Header.tsx b/src/app/share/[...shareId]/Header.tsx
index eece42bb5..88da5bec6 100644
--- a/src/app/share/[...shareId]/Header.tsx
+++ b/src/app/share/[...shareId]/Header.tsx
@@ -1,7 +1,7 @@
import { Row, Icon, Text, ThemeButton } from '@umami/react-zen';
import Link from 'next/link';
import { LanguageButton } from '@/components/input/LanguageButton';
-import { SettingsButton } from '@/components/input/SettingsButton';
+import { PreferencesButton } from '@/components/input/PreferencesButton';
import { Logo } from '@/components/icons';
export function Header() {
@@ -18,7 +18,7 @@ export function Header() {
<Row alignItems="center" gap>
<ThemeButton />
<LanguageButton />
- <SettingsButton />
+ <PreferencesButton />
</Row>
</Row>
);
diff --git a/src/app/sso/SSOPage.tsx b/src/app/sso/SSOPage.tsx
index b8893a6c9..ec04c0901 100644
--- a/src/app/sso/SSOPage.tsx
+++ b/src/app/sso/SSOPage.tsx
@@ -18,5 +18,5 @@ export function SSOPage() {
}
}, [router, url, token]);
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
diff --git a/src/components/common/LoadingPanel.tsx b/src/components/common/LoadingPanel.tsx
index 9caffee8e..d5abfef02 100644
--- a/src/components/common/LoadingPanel.tsx
+++ b/src/components/common/LoadingPanel.tsx
@@ -10,7 +10,7 @@ export interface LoadingPanelProps extends ColumnProps {
isLoading?: boolean;
isFetching?: boolean;
loadingIcon?: 'dots' | 'spinner';
- loadingPosition?: 'center' | 'page' | 'inline';
+ loadingPlacement?: 'center' | 'absolute' | 'inline';
renderEmpty?: () => ReactNode;
children: ReactNode;
}
@@ -22,7 +22,7 @@ export function LoadingPanel({
isLoading,
isFetching,
loadingIcon = 'dots',
- loadingPosition = 'page',
+ loadingPlacement = 'absolute',
renderEmpty = () => <Empty />,
children,
...props
@@ -34,7 +34,7 @@ export function LoadingPanel({
{/* Show loading spinner only if no data exists */}
{(isLoading || isFetching) && (
<Column position="relative" height="100%" {...props}>
- <Loading icon={loadingIcon} position={loadingPosition} />
+ <Loading icon={loadingIcon} placement={loadingPlacement} />
</Column>
)}
diff --git a/src/components/common/PageBody.tsx b/src/components/common/PageBody.tsx
index 7478280a4..d7f1fc302 100644
--- a/src/components/common/PageBody.tsx
+++ b/src/components/common/PageBody.tsx
@@ -24,7 +24,7 @@ export function PageBody({
}
if (isLoading) {
- return <Loading position="page" />;
+ return <Loading placement="absolute" />;
}
return (
diff --git a/src/components/icons.ts b/src/components/icons.ts
index d25b5b72a..c96a27b67 100644
--- a/src/components/icons.ts
+++ b/src/components/icons.ts
@@ -1,6 +1,7 @@
export {
AlertTriangle as Alert,
ArrowRight as Arrow,
+ Bookmark,
Calendar,
ChartPie,
ChevronRight as Chevron,
@@ -50,4 +51,20 @@ export {
UserPlus,
X as Close,
} from 'lucide-react';
-export * from '@/components/svg';
+export {
+ Logo,
+ Bolt,
+ Change,
+ Compare,
+ Funnel,
+ Lightbulb,
+ Lightning,
+ Magnet,
+ Money,
+ Network,
+ Path,
+ Tag,
+ Target,
+ AddUser,
+ Visitor,
+} from '@/components/svg';
diff --git a/src/components/input/DateFilter.tsx b/src/components/input/DateFilter.tsx
index 2a1f9a2c2..cd0164915 100644
--- a/src/components/input/DateFilter.tsx
+++ b/src/components/input/DateFilter.tsx
@@ -1,12 +1,12 @@
import { useState, Key, Fragment } from 'react';
-import { Modal, Select, ListItem, ListSeparator, Dialog, Row } from '@umami/react-zen';
+import { Modal, Select, ListItem, ListSeparator, Dialog, SelectProps } from '@umami/react-zen';
import { endOfYear } from 'date-fns';
import { DatePickerForm } from '@/components/metrics/DatePickerForm';
import { useMessages } from '@/components/hooks';
import { DateDisplay } from '@/components/common/DateDisplay';
import { parseDateRange } from '@/lib/date';
-export interface DateFilterProps {
+export interface DateFilterProps extends SelectProps {
value?: string;
onChange?: (value: string) => void;
showAllTime?: boolean;
@@ -20,6 +20,7 @@ export function DateFilter({
showAllTime,
renderDate,
placement = 'bottom',
+ ...props
}: DateFilterProps) {
const { formatMessage, labels } = useMessages();
const [showPicker, setShowPicker] = useState(false);
@@ -99,8 +100,9 @@ export function DateFilter({
};
return (
- <Row minWidth="200px">
+ <>
<Select
+ {...props}
value={value}
placeholder={formatMessage(labels.selectDate)}
onChange={handleChange}
@@ -130,6 +132,6 @@ export function DateFilter({
</Dialog>
</Modal>
)}
- </Row>
+ </>
);
}
diff --git a/src/components/input/LookupField.tsx b/src/components/input/LookupField.tsx
index 841ab866f..06b5006a3 100644
--- a/src/components/input/LookupField.tsx
+++ b/src/components/input/LookupField.tsx
@@ -49,7 +49,7 @@ export function LookupField({ websiteId, type, value, onChange, ...props }: Look
allowsCustomValue
renderEmptyState={() =>
isLoading ? (
- <Loading position="center" icon="dots" />
+ <Loading placement="center" icon="dots" />
) : (
<Empty message={formatMessage(messages.noResultsFound)} />
)
diff --git a/src/components/input/PreferencesButton.tsx b/src/components/input/PreferencesButton.tsx
new file mode 100644
index 000000000..a7f074aaa
--- /dev/null
+++ b/src/components/input/PreferencesButton.tsx
@@ -0,0 +1,27 @@
+import { Button, Icon, DialogTrigger, Popover, Column, Label } from '@umami/react-zen';
+import { TimezoneSetting } from '@/app/(main)/settings/preferences/TimezoneSetting';
+import { DateRangeSetting } from '@/app/(main)/settings/preferences/DateRangeSetting';
+import { Settings } from '@/components/icons';
+import { useMessages } from '@/components/hooks';
+
+export function PreferencesButton() {
+ const { formatMessage, labels } = useMessages();
+
+ return (
+ <DialogTrigger>
+ <Button variant="quiet">
+ <Icon>
+ <Settings />
+ </Icon>
+ </Button>
+ <Popover placement="bottom end">
+ <Column gap="3">
+ <Label>{formatMessage(labels.timezone)}</Label>
+ <TimezoneSetting />
+ <Label>{formatMessage(labels.defaultDateRange)}</Label>
+ <DateRangeSetting />
+ </Column>
+ </Popover>
+ </DialogTrigger>
+ );
+}
diff --git a/src/components/input/ProfileButton.tsx b/src/components/input/ProfileButton.tsx
index 9e1cbd3f5..017ea8319 100644
--- a/src/components/input/ProfileButton.tsx
+++ b/src/components/input/ProfileButton.tsx
@@ -11,31 +11,31 @@ import {
Text,
Row,
} from '@umami/react-zen';
-import { useMessages, useLoginQuery, useNavigation } from '@/components/hooks';
+import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
import { LogOut, UserCircle, LockKeyhole } from '@/components/icons';
export function ProfileButton() {
const { formatMessage, labels } = useMessages();
const { user } = useLoginQuery();
const { renderUrl } = useNavigation();
- const cloudMode = !!process.env.cloudMode;
+ const { cloudUrl } = useConfig();
const items = [
{
- id: 'profile',
+ id: 'settings',
label: formatMessage(labels.profile),
path: renderUrl('/settings/profile'),
icon: <UserCircle />,
},
user.isAdmin &&
- !cloudMode && {
+ !cloudUrl && {
id: 'admin',
label: formatMessage(labels.admin),
path: '/admin',
icon: <LockKeyhole />,
},
{
- id: 'LogOut',
+ id: 'logout',
label: formatMessage(labels.logout),
path: '/logout',
icon: <LogOut />,
diff --git a/src/components/input/SettingsButton.tsx b/src/components/input/SettingsButton.tsx
index ae7b1eb04..e717e1357 100644
--- a/src/components/input/SettingsButton.tsx
+++ b/src/components/input/SettingsButton.tsx
@@ -1,27 +1,71 @@
-import { Button, Icon, DialogTrigger, Popover, Column, Label } from '@umami/react-zen';
-import { TimezoneSetting } from '@/app/(main)/settings/preferences/TimezoneSetting';
-import { DateRangeSetting } from '@/app/(main)/settings/preferences/DateRangeSetting';
-import { Gear } from '@/components/icons';
-import { useMessages } from '@/components/hooks';
+import { Key } from 'react';
+import {
+ Icon,
+ Button,
+ MenuTrigger,
+ Popover,
+ Menu,
+ MenuItem,
+ MenuSeparator,
+ MenuSection,
+ Dialog,
+ SubMenuTrigger,
+} from '@umami/react-zen';
+import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
+import { LogOut, LockKeyhole, Settings, Knobs } from '@/components/icons';
+import { PreferenceSettings } from '@/app/(main)/settings/preferences/PreferenceSettings';
export function SettingsButton() {
const { formatMessage, labels } = useMessages();
+ const { user } = useLoginQuery();
+ const { router, renderUrl } = useNavigation();
+ const { cloudMode, cloudUrl } = useConfig();
+
+ const handleAction = (id: Key) => {
+ if (id === 'settings') {
+ if (cloudMode) {
+ window.location.href = `${cloudUrl}/dashboard`;
+ return;
+ }
+ }
+
+ router.push(renderUrl(`/${id}`));
+ };
return (
- <DialogTrigger>
- <Button variant="quiet">
+ <MenuTrigger>
+ <Button data-test="button-profile" variant="quiet" autoFocus={false}>
<Icon>
- <Gear />
+ <Settings />
</Icon>
</Button>
<Popover placement="bottom end">
- <Column gap="3">
- <Label>{formatMessage(labels.timezone)}</Label>
- <TimezoneSetting />
- <Label>{formatMessage(labels.defaultDateRange)}</Label>
- <DateRangeSetting />
- </Column>
+ <Menu autoFocus="last" onAction={handleAction}>
+ <MenuSection title={user.username}>
+ <MenuSeparator />
+ <MenuItem id="settings" icon={<Settings />} label={formatMessage(labels.settings)} />
+ {cloudMode && (
+ <SubMenuTrigger>
+ <MenuItem
+ icon={<Knobs />}
+ label={formatMessage(labels.preferences)}
+ showSubMenuIcon
+ />
+ <Popover placement="right bottom">
+ <Dialog>
+ <PreferenceSettings />
+ </Dialog>
+ </Popover>
+ </SubMenuTrigger>
+ )}
+ {!cloudMode && user.isAdmin && (
+ <MenuItem id="admin" icon={<LockKeyhole />} label={formatMessage(labels.admin)} />
+ )}
+ <MenuSeparator />
+ <MenuItem id="logout" icon={<LogOut />} label={formatMessage(labels.logout)} />
+ </MenuSection>
+ </Menu>
</Popover>
- </DialogTrigger>
+ </MenuTrigger>
);
}
diff --git a/src/components/input/TeamsButton.tsx b/src/components/input/TeamsButton.tsx
index 5d40142ea..afed4c6d4 100644
--- a/src/components/input/TeamsButton.tsx
+++ b/src/components/input/TeamsButton.tsx
@@ -1,5 +1,3 @@
-import { Key } from 'react';
-import { useRouter } from 'next/navigation';
import {
Text,
Icon,
@@ -10,8 +8,8 @@ import {
MenuSeparator,
Popover,
Row,
- Box,
- Button,
+ Column,
+ Pressable,
Loading,
} from '@umami/react-zen';
import { useLoginQuery, useMessages, useUserTeamsQuery, useNavigation } from '@/components/hooks';
@@ -32,7 +30,7 @@ export function TeamsButton({ showText = true, onAction }: TeamsButtonProps) {
const label = teamId ? team?.name : user.username;
if (isLoading) {
- return <Loading icon="dots" position="center" />;
+ return <Loading icon="dots" size="sm" placement="center" />;
}
if (!data?.count) {
@@ -41,8 +39,15 @@ export function TeamsButton({ showText = true, onAction }: TeamsButtonProps) {
return (
<MenuTrigger>
- <Button variant="outline">
- <Row alignItems="center" justifyContent="space-between" flexGrow={1}>
+ <Pressable>
+ <Row
+ alignItems="center"
+ justifyContent="space-between"
+ flexGrow={1}
+ padding
+ backgroundColor="2"
+ style={{ cursor: 'pointer', textWrap: 'nowrap', outline: 'none' }}
+ >
<Row alignItems="center" gap>
<Icon>{teamId ? <Users /> : <User />}</Icon>
{showText && <Text>{label}</Text>}
@@ -53,9 +58,9 @@ export function TeamsButton({ showText = true, onAction }: TeamsButtonProps) {
</Icon>
)}
</Row>
- </Button>
+ </Pressable>
<Popover placement="bottom start">
- <Box minWidth="300px">
+ <Column minWidth="300px">
<Menu
selectionMode="single"
selectedKeys={selectedKeys}
@@ -86,7 +91,7 @@ export function TeamsButton({ showText = true, onAction }: TeamsButtonProps) {
))}
</MenuSection>
</Menu>
- </Box>
+ </Column>
</Popover>
</MenuTrigger>
);
diff --git a/src/components/input/WebsiteDateFilter.tsx b/src/components/input/WebsiteDateFilter.tsx
index ec8c4107c..47cc82bb9 100644
--- a/src/components/input/WebsiteDateFilter.tsx
+++ b/src/components/input/WebsiteDateFilter.tsx
@@ -59,12 +59,14 @@ export function WebsiteDateFilter({
</Button>
</Row>
)}
- <DateFilter
- value={value}
- onChange={handleChange}
- showAllTime={showAllTime}
- renderDate={+offset !== 0}
- />
+ <Row width="200px">
+ <DateFilter
+ value={value}
+ onChange={handleChange}
+ showAllTime={showAllTime}
+ renderDate={+offset !== 0}
+ />
+ </Row>
{allowCompare && !isAllTime && (
<Row alignItems="center" gap>
<Text weight="bold">VS</Text>
diff --git a/src/permissions/team.ts b/src/permissions/team.ts
index 97a02b9fd..3273c8192 100644
--- a/src/permissions/team.ts
+++ b/src/permissions/team.ts
@@ -3,7 +3,7 @@ import { PERMISSIONS } from '@/lib/constants';
import { getTeamUser } from '@/queries';
import { hasPermission } from '@/lib/auth';
-const cloudMode = !!process.env.CLOUD_MODE;
+const cloudMode = !!process.env.CLOUD_URL;
export async function canViewTeam({ user }: Auth, teamId: string) {
if (user.isAdmin) {
diff --git a/src/permissions/website.ts b/src/permissions/website.ts
index 9f871b1c9..63ae5c903 100644
--- a/src/permissions/website.ts
+++ b/src/permissions/website.ts
@@ -3,7 +3,7 @@ import { PERMISSIONS } from '@/lib/constants';
import { hasPermission } from '@/lib/auth';
import { getTeamUser, getWebsite } from '@/queries';
-const cloudMode = !!process.env.CLOUD_MODE;
+const cloudMode = !!process.env.CLOUD_URL;
export async function canViewWebsite({ user, shareToken }: Auth, websiteId: string) {
if (user?.isAdmin) {
diff --git a/src/queries/prisma/team.ts b/src/queries/prisma/team.ts
index 70750783a..2d3b7d856 100644
--- a/src/queries/prisma/team.ts
+++ b/src/queries/prisma/team.ts
@@ -117,7 +117,7 @@ export async function deleteTeam(
teamId: string,
): Promise<Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Team]>> {
const { client, transaction } = prisma;
- const cloudMode = process.env.CLOUD_MODE;
+ const cloudMode = !!process.env.CLOUD_URL;
if (cloudMode) {
return transaction([
diff --git a/src/queries/prisma/user.ts b/src/queries/prisma/user.ts
index 96288dd03..d56c5747d 100644
--- a/src/queries/prisma/user.ts
+++ b/src/queries/prisma/user.ts
@@ -122,7 +122,7 @@ export async function deleteUser(
]
> {
const { client, transaction } = prisma;
- const cloudMode = process.env.CLOUD_MODE;
+ const cloudMode = !!process.env.CLOUD_URL;
const websites = await client.website.findMany({
where: { userId },
diff --git a/src/queries/prisma/website.ts b/src/queries/prisma/website.ts
index 683aab0f2..fc10bcfd8 100644
--- a/src/queries/prisma/website.ts
+++ b/src/queries/prisma/website.ts
@@ -159,7 +159,7 @@ export async function resetWebsite(
websiteId: string,
): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
const { client, transaction } = prisma;
- const cloudMode = !!process.env.cloudMode;
+ const cloudMode = !!process.env.CLOUD_URL;
return transaction([
client.eventData.deleteMany({
@@ -193,7 +193,7 @@ export async function deleteWebsite(
websiteId: string,
): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
const { client, transaction } = prisma;
- const cloudMode = !!process.env.CLOUD_MODE;
+ const cloudMode = !!process.env.CLOUD_URL;
return transaction([
client.eventData.deleteMany({