Gate heatmaps report on UMAMI_SELF_RECORD.

This commit is contained in:
Mike Cao committed 2026-05-04 13:29:53 -07:00
1 parent a6b13b71db
commit 12c10c48cd
5 files changed
+24 -7

No files matched your search

@@ -1,7 +1,12 @@
import type { Metadata } from 'next'; import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { HeatmapsPage } from './HeatmapsPage'; import { HeatmapsPage } from './HeatmapsPage';
export default async function ({ params }: { params: Promise<{ websiteId: string }> }) { export default async function ({ params }: { params: Promise<{ websiteId: string }> }) {
if (!process.env.UMAMI_SELF_RECORD) {
notFound();
}
const { websiteId } = await params; const { websiteId } = await params;
return <HeatmapsPage websiteId={websiteId} />; return <HeatmapsPage websiteId={websiteId} />;
+1
View File
@@ -14,6 +14,7 @@ export async function GET(request: Request) {
linksUrl: process.env.LINKS_URL, linksUrl: process.env.LINKS_URL,
pixelsUrl: process.env.PIXELS_URL, pixelsUrl: process.env.PIXELS_URL,
privateMode: !!process.env.PRIVATE_MODE, privateMode: !!process.env.PRIVATE_MODE,
selfRecordEnabled: !!process.env.UMAMI_SELF_RECORD,
telemetryDisabled: !!process.env.DISABLE_TELEMETRY, telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
trackerScriptName: process.env.TRACKER_SCRIPT_NAME, trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
updatesDisabled: !!process.env.DISABLE_UPDATES, updatesDisabled: !!process.env.DISABLE_UPDATES,
+5 -1
View File
@@ -1,10 +1,14 @@
import { parseRequest, setWebsiteDate } from '@/lib/request'; import { parseRequest, setWebsiteDate } from '@/lib/request';
import { json, unauthorized } from '@/lib/response'; import { forbidden, json, unauthorized } from '@/lib/response';
import { reportResultSchema } from '@/lib/schema'; import { reportResultSchema } from '@/lib/schema';
import { canViewWebsite } from '@/permissions'; import { canViewWebsite } from '@/permissions';
import { getHeatmap, type HeatmapParameters } from '@/queries/sql'; import { getHeatmap, type HeatmapParameters } from '@/queries/sql';
export async function POST(request: Request) { export async function POST(request: Request) {
if (!process.env.UMAMI_SELF_RECORD) {
return forbidden({ message: 'Heatmap recording is disabled.' });
}
const { auth, body, error } = await parseRequest(request, reportResultSchema); const { auth, body, error } = await parseRequest(request, reportResultSchema);
if (error) { if (error) {
+1
View File
@@ -8,6 +8,7 @@ export type Config = {
linksUrl?: string; linksUrl?: string;
pixelsUrl?: string; pixelsUrl?: string;
privateMode: boolean; privateMode: boolean;
selfRecordEnabled: boolean;
telemetryDisabled: boolean; telemetryDisabled: boolean;
trackerScriptName?: string; trackerScriptName?: string;
updatesDisabled: boolean; updatesDisabled: boolean;
+12 -6
View File
@@ -11,12 +11,14 @@ import {
Video, Video,
} from '@/components/icons'; } from '@/components/icons';
import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg'; import { Funnel, Gauge, Lightning, Magnet, Money, Network, Path, Target } from '@/components/svg';
import { useConfig } from './useConfig';
import { useMessages } from './useMessages'; import { useMessages } from './useMessages';
import { useNavigation } from './useNavigation'; import { useNavigation } from './useNavigation';
export function useWebsiteNavItems(websiteId: string) { export function useWebsiteNavItems(websiteId: string) {
const { t, labels } = useMessages(); const { t, labels } = useMessages();
const { pathname, renderUrl } = useNavigation(); const { pathname, renderUrl } = useNavigation();
const config = useConfig();
const renderPath = (path: string) => const renderPath = (path: string) =>
renderUrl(`/websites/${websiteId}${path}`, { renderUrl(`/websites/${websiteId}${path}`, {
@@ -108,12 +110,16 @@ export function useWebsiteNavItems(websiteId: string) {
icon: <Video />, icon: <Video />,
path: renderPath('/replays'), path: renderPath('/replays'),
}, },
{ ...(config?.selfRecordEnabled
id: 'heatmaps', ? [
label: t(labels.heatmaps), {
icon: <Flame />, id: 'heatmaps',
path: renderPath('/heatmaps'), label: t(labels.heatmaps),
}, icon: <Flame />,
path: renderPath('/heatmaps'),
},
]
: []),
], ],
}, },
{ {