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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Merge branch 'analytics' into dev
Mike Caoadea3e9b1ccd
diff --cc .gitignoreindex de893d0f1,64cdb30d1..0649999d8--- a/.gitignore+++ b/.gitignore@@@ -1,46 -1,46 +1,47 @@@- # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.-- # dependencies- node_modules- .pnp- .pnp.js- .pnpm-store- package-lock.json-- # testing- /coverage-- # next.js- /.next- /out-- # production- /build- /public/script.js- /geo- /dist- /generated- /src/generated- pm2.yml-- # misc- .DS_Store- .idea- .yarn- *.iml- *.log- .vscode- .tool-versions-- # debug- npm-debug.log*- yarn-debug.log*- yarn-error.log*-- # local env files- .env- .env.*- *.env.*-- *.dev.yml-+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.++ # dependencies+ node_modules+ .pnp+ .pnp.js+ .pnpm-store+ package-lock.json++ # testing+ /coverage++ # next.js+ /.next+ /out++ # production+ /build+ /public/script.js+ /geo+ /dist+ /generated+ /src/generated++pm2.yml++ # misc+ .DS_Store+ .idea+ .yarn+ *.iml+ *.log+ .vscode+ .tool-versions+ .claude++ # debug+ npm-debug.log*+ yarn-debug.log*+ yarn-error.log*++ # local env files+ .env+ .env.*+ *.env.*++ *.dev.yml+diff --cc src/app/(main)/websites/[websiteId]/WebsiteHeader.tsxindex e79576dd3,0d8b5d28e..1dee80220--- a/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx+++ b/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx@@@ -3,10 -4,17 +3,16 @@@ import { Favicon } from '@/components/cimport { LinkButton } from '@/components/common/LinkButton';import { PageHeader } from '@/components/common/PageHeader';import { useMessages, useNavigation, useWebsite } from '@/components/hooks';-import { Edit, Share } from '@/components/icons';-import { DialogButton } from '@/components/input/DialogButton';+import { Edit } from '@/components/icons';import { ActiveUsers } from '@/components/metrics/ActiveUsers';- export function WebsiteHeader({ showActions }: { showActions?: boolean }) {+ export function WebsiteHeader({+ showActions,+ allowLink = true,+ }: {+ showActions?: boolean;+ allowLink?: boolean;+ }) {const website = useWebsite();const { renderUrl, pathname } = useNavigation();const isSettings = pathname.endsWith('/settings');diff --cc src/app/api/share/[slug]/route.tsindex ed3271eab,8b0c9bb9f..62e2fc42c--- a/src/app/api/share/[slug]/route.ts+++ b/src/app/api/share/[slug]/route.ts@@@ -1,23 -1,76 +1,81 @@@+ import { ROLES } from '@/lib/constants';import { secret } from '@/lib/crypto';import { createToken } from '@/lib/jwt';+ import prisma from '@/lib/prisma';+ import redis from '@/lib/redis';import { json, notFound } from '@/lib/response';- import { getShareByCode } from '@/queries/prisma';-import { getSharedWebsite } from '@/queries/prisma';++import { getShareByCode, getWebsite } from '@/queries/prisma';++ export interface WhiteLabel {+ name: string;+ url: string;+ image: string;+ }++ async function getAccountId(website: { userId?: string; teamId?: string }): Promise<string | null> {+ if (website.userId) {+ return website.userId;+ }++ if (website.teamId) {+ const teamOwner = await prisma.client.teamUser.findFirst({+ where: {+ teamId: website.teamId,+ role: ROLES.teamOwner,+ },+ select: {+ userId: true,+ },+ });++ return teamOwner?.userId || null;+ }++ return null;+ }++ async function getWhiteLabel(accountId: string): Promise<WhiteLabel | null> {+ if (!redis.enabled) {+ return null;+ }++ const data = await redis.client.get(`white-label:${accountId}`);++ if (data) {+ return data as WhiteLabel;+ }++ return null;+ }-export async function GET(_request: Request, { params }: { params: Promise<{ shareId: string }> }) {- const { shareId } = await params;+export async function GET(_request: Request, { params }: { params: Promise<{ slug: string }> }) {+ const { slug } = await params;- const website = await getSharedWebsite(shareId);+ const share = await getShareByCode(slug);- if (!website) {+ if (!share) {return notFound();}- const data = {- const data: { websiteId: string; token: string; whiteLabel?: WhiteLabel } = {- websiteId: website.id,- token: createToken({ websiteId: website.id }, secret()),++ const website = await getWebsite(share.entityId);++++ const data: Record<string, any> = {+ shareId: share.id,+ websiteId: share.entityId,+ parameters: share.parameters,};- const token = createToken(data, secret());- return json({ ...data, token });++ data.token = createToken(data, secret());+++ const accountId = await getAccountId(website);++ if (accountId) {+ const whiteLabel = await getWhiteLabel(accountId);++ if (whiteLabel) {+ data.whiteLabel = whiteLabel;+ }+ }++ return json(data);}diff --cc src/app/share/[...shareId]/SharePage.tsxindex 3e1cedc06,7a76a29bb..9e8bd8bfc--- a/src/app/share/[...shareId]/SharePage.tsx+++ b/src/app/share/[...shareId]/SharePage.tsx@@@ -56,42 -26,18 +56,43 @@@ export function SharePage({ shareId, pareturn null;}- const { websiteId, parameters = {} } = shareToken;- const { whiteLabel } = shareToken;++ const { websiteId, parameters = {}, whiteLabel } = shareToken;++ // Check if the requested path is allowed+ const pageKey = path || '';+ const isAllowed = pageKey === '' || pageKey === 'overview' || parameters[pageKey] !== false;++ if (!isAllowed) {+ return null;+ }++ const PageComponent = PAGE_COMPONENTS[pageKey] || WebsitePage;return (<Column backgroundColor="2">- <PageBody gap>- <Header whiteLabel={whiteLabel} />- <WebsiteProvider websiteId={shareToken.websiteId}>- <WebsiteHeader showActions={false} allowLink={false} />- <WebsitePage websiteId={shareToken.websiteId} />- </WebsiteProvider>- <Footer whiteLabel={whiteLabel} />- </PageBody>+ <Header />+ <Grid columns={{ xs: '1fr', lg: 'auto 1fr' }} width="100%" height="100%">+ <Column+ display={{ xs: 'none', lg: 'flex' }}+ width="240px"+ height="100%"+ border="right"+ backgroundColor+ marginRight="2"+ >+ <ShareNav shareId={shareId} parameters={parameters} />+ </Column>+ <PageBody gap>+ <WebsiteProvider websiteId={websiteId}>- <WebsiteHeader showActions={false} />++ <Header whiteLabel={whiteLabel} />+ <Column>+ <PageComponent websiteId={websiteId} />+ </Column>++ <Footer whiteLabel={whiteLabel} />+ </WebsiteProvider>+ </PageBody>+ </Grid>+ <Footer /></Column>);}