Skip to content

Commit

Permalink
feat: umami
Browse files Browse the repository at this point in the history
  • Loading branch information
lcandy2 committed Dec 5, 2024
1 parent a6e583b commit 338967f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"lit": "^3.2.0",
"million": "^3.1.11",
"next": "14.2.5",
"next-umami": "^0.0.4",
"notistack": "^3.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/app/_libs/umami-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import UmamiProvider from 'next-umami';
import { ReactNode } from 'react';

interface UmamiProviderProps {
children: ReactNode;
}

export default function WPNUmamiProvider({ children }: UmamiProviderProps) {\
const websiteId = process.env.NEXT_PUBLIC_UMAMI_ID;
\
if (!websiteId) {
return <>{children}</>;
}
\
return (
<UmamiProvider
websiteId={websiteId}
src={process.env.NEXT_PUBLIC_UMAMI_SRC}
>
{children}
</UmamiProvider>
);
}
71 changes: 37 additions & 34 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Footer from './_libs/components/footer';
import * as Fonts from '@/app/_libs/fonts/fonts';
import { Analytics } from '@vercel/analytics/react';
import Script from 'next/script';
import WPNUmamiProvider from './_libs/umami-provider';

const APP_NAME = APP_MANIFEST.name;
const APP_DEFAULT_TITLE = APP_MANIFEST.name;
Expand Down Expand Up @@ -136,48 +137,50 @@ export default function RootLayout({
}}
>
<Experimental_CssVarsProvider theme={MuiTheme}>
<section className="flex flex-col sm:mb-l">
<div className="h-header block">
<Header />
</div>
<div className="grow flex flex-col justify-start sm:ml-xl sm:mr-l transition-all duration-md ease-md">
<div className="grow transition-all duration-md ease-md box-border overflow-auto w-full h-content-sm sm:h-content bg-surface sm:rounded-shape-xl rounded-t-shape-xl">
<div className="pt-xl scrollbar-track-primary scrollbar-thin overflow-y-auto h-full rounded-[inherit] box-border">
<div className="grow flex flex-row items-start box-border px-xl w-full h-full">
<div className="flex flex-col w-full h-full text-on-surface">
<main className="grow block w-full">
{children}
{modal}
</main>
<Footer />
<WPNUmamiProvider websiteId={process.env.UMAMI_ID}>
<section className="flex flex-col sm:mb-l">
<div className="h-header block">
<Header />
</div>
<div className="grow flex flex-col justify-start sm:ml-xl sm:mr-l transition-all duration-md ease-md">
<div className="grow transition-all duration-md ease-md box-border overflow-auto w-full h-content-sm sm:h-content bg-surface sm:rounded-shape-xl rounded-t-shape-xl">
<div className="pt-xl scrollbar-track-primary scrollbar-thin overflow-y-auto h-full rounded-[inherit] box-border">
<div className="grow flex flex-row items-start box-border px-xl w-full h-full">
<div className="flex flex-col w-full h-full text-on-surface">
<main className="grow block w-full">
{children}
{modal}
</main>
<Footer />
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="modal-root" />
<Analytics />
{process.env.CFTOKEN && (
<Script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon={`{"token": "${process.env.CFTOKEN}"}`}
></Script>
)}
{process.env.MSID && (
<Script
type="text/javascript"
strategy="lazyOnload"
id="clarity-script"
>
{`(function(c,l,a,r,i,t,y){
</section>
<section id="modal-root" />
<Analytics />
{process.env.CFTOKEN && (
<Script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon={`{"token": "${process.env.CFTOKEN}"}`}
></Script>
)}
{process.env.MSID && (
<Script
type="text/javascript"
strategy="lazyOnload"
id="clarity-script"
>
{`(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "${process.env.MSID}");`}
</Script>
)}
</Script>
)}
</WPNUmamiProvider>
</Experimental_CssVarsProvider>
</AppRouterCacheProvider>
</body>
Expand Down

0 comments on commit 338967f

Please sign in to comment.