Skip to content

Commit

Permalink
feat: add umami analysis support
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-guoba committed Mar 20, 2024
1 parent 58bdbca commit d7e52b2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ The Notion API has frequency limitations, and for some deeply nested pages, mult

## TODO

- [ ] Deploy on Vercel

## Reference

Expand Down
11 changes: 11 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SiteHeader } from "@/components/layouts/site-header";
import { SiteFooter } from "@/components/layouts/site-footer";

import { defaultMeta } from "@/lib/seo";
import { env } from "@/env.mjs";

export const metadata: Metadata = defaultMeta();

Expand All @@ -23,9 +24,19 @@ export const viewport: Viewport = {
],
};

function Analytics() {
if (env.NEXT_ANALYTICS_UMAMI_ID) {
return <script defer src="https://analytics.us.umami.is/script.js" data-website-id={env.NEXT_ANALYTICS_UMAMI_ID}></script>
}
return null;
}

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<Analytics></Analytics>
</head>
{/* <head /> */}
{/* <body className={`${inter.className} min-h-screen bg-background antialiased`}> */}
<body className={cn("min-h-screen bg-background font-sans antialiased", fontSans.variable, fontMono.variable)}>
Expand Down
2 changes: 2 additions & 0 deletions env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const env = createEnv({
NOTION_API_LOG_LEVEL: z.enum(["debug", "info", "warn", "error"]).default("warn"),
POST_PAGE_SIZES: z.coerce.number().default(8),
REVALIDATE_PAGES: z.coerce.number().default(600),
NEXT_ANALYTICS_UMAMI_ID: z.string().default(''),
},

/**
Expand Down Expand Up @@ -47,6 +48,7 @@ export const env = createEnv({
NOTION_API_LOG_LEVEL: process.env.NOTION_API_LOG_LEVEL,
POST_PAGE_SIZES: process.env.POST_PAGE_SIZES,
REVALIDATE_PAGES: process.env.NEXT_REVALIDATE_PAGES,
NEXT_ANALYTICS_UMAMI_ID: process.env.NEXT_ANALYTICS_UMAMI_ID,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
Expand Down

0 comments on commit d7e52b2

Please sign in to comment.