Skip to content

Commit

Permalink
Add visitor analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
krasun committed Oct 28, 2024
1 parent d1822e2 commit 73597fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ jobs:
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
echo "SCREENSHOTONE_API_ACCESS_KEY=${{ secrets.SCREENSHOTONE_API_ACCESS_KEY }}" >> .env
echo "SCREENSHOTONE_API_SECRET_KEY=${{ secrets.SCREENSHOTONE_API_SECRET_KEY }}" >> .env
echo "NEXT_PUBLIC_PIRSCH_CODE=${{ secrets.NEXT_PUBLIC_PIRSCH_CODE }}" >> .env
kamal deploy
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { Analytics } from "@/components/analytics";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
Expand Down Expand Up @@ -34,6 +35,7 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
<Analytics />
</body>
</html>
);
Expand Down
18 changes: 18 additions & 0 deletions src/components/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use client"

import Script from "next/script"

export function Analytics() {
if (process.env.NODE_ENV != "production") {
return <></>;
}

return (
<Script
src="https://api.pirsch.io/pirsch.js"
id="pirschjs"
data-code={process.env.NEXT_PUBLIC_PIRSCH_CODE}
strategy="afterInteractive"
/>
)
}

0 comments on commit 73597fc

Please sign in to comment.