In the parts 1.1, 1.2 we reviewed API layer in /websites and /links page and in part 1.3, we reviewed the website overview page. In this article, we review links detail page.
In the Link detail page, you will find the below code:
'use client';import { PageBody } from '@/components/common/PageBody';import { LinkProvider } from '@/app/(main)/links/LinkProvider';import { LinkHeader } from '@/app/(main)/links/[linkId]/LinkHeader';import { Panel } from '@/components/common/Panel';import { WebsiteChart } from '@/app/(main)/websites/[websiteId]/WebsiteChart';import { LinkMetricsBar } from '@/app/(main)/links/[linkId]/LinkMetricsBar';import { LinkControls } from '@/app/(main)/links/[linkId]/LinkControls';import { LinkPanels } from '@/app/(main)/links/[linkId]/LinkPanels';import { Column, Grid } from '@umami/react-zen';import { ExpandedViewModal } from '@/app/(main)/websites/[websiteId]/ExpandedViewModal';const excludedIds = ['path', 'entry', 'exit', 'title', 'language', 'screen', 'event'];export function LinkPage({ linkId }: { linkId: string }) { return ( <LinkProvider linkId={linkId}> <Grid width="100%" height="100%"> <Column margin="2"> <PageBody gap> <LinkHeader /> <LinkControls linkId={linkId} /> <LinkMetricsBar linkId={linkId} showChange={true} /> <Panel> <WebsiteChart websiteId={linkId} /> </Panel> <LinkPanels linkId={linkId} /> </PageBody> <ExpandedViewModal websiteId={linkId} excludedIds={excludedIds} /> </Column> </Grid> </LinkProvider> );}
useWebsiteMetricsQuery is a common query used to fetch information depending on the type and other parameters, using our code snippet, here type could be browser, os, device.
You will find the below code in useWebsiteMetricsQuery.ts
We reviewed the Link detail page and found the same API used in the website detail page to fetch similar information like views and stats. However, the metrics in the other sections is fetched and rendered using a common component named MetricsTable and this data is fetched depending on the type.
I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects atthinkthroo.com