Skip to content

Commit

Permalink
chore: Add umami tracking script (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishiad authored Oct 1, 2024
2 parents f0452a1 + 6e22f30 commit f507e4d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ REDIS_URI=

# Club Resources OneDrive link
NEXT_PUBLIC_DRIVE_LINK=

# Umami
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
2 changes: 2 additions & 0 deletions .github/workflows/ci-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ jobs:
REDIS_URI: ${{ secrets.REDIS_URI }}
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
NEXT_PUBLIC_DRIVE_LINK: ${{ secrets.NEXT_PUBLIC_DRIVE_LINK }}
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
run: |
docker buildx build \
--secret id=DATABASE_URL \
--secret id=REDIS_URI \
--secret id=NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \
--secret id=NEXT_PUBLIC_DRIVE_LINK \
--secret id=NEXT_PUBLIC_UMAMI_WEBSITE_ID \
--file=Dockerfile -t csclub-website .
2 changes: 2 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
REDIS_URI: ${{ secrets.REDIS_URI }}
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
NEXT_PUBLIC_DRIVE_LINK: ${{ secrets.NEXT_PUBLIC_DRIVE_LINK }}
NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}
PRODUCTION_BUILD: 'true'
run: |
docker buildx build \
Expand All @@ -62,6 +63,7 @@ jobs:
--secret id=REDIS_URI \
--secret id=NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \
--secret id=NEXT_PUBLIC_DRIVE_LINK \
--secret id=NEXT_PUBLIC_UMAMI_WEBSITE_ID \
--output type=docker,dest=csclub-website.tar \
--platform=linux/arm64 --file=Dockerfile -t csclub-website .
gzip csclub-website.tar
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ RUN --mount=type=secret,id=DATABASE_URL,target=/run/secrets/DATABASE_URL \
--mount=type=secret,id=REDIS_URI,target=/run/secrets/REDIS_URI \
--mount=type=secret,id=NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,target=/run/secrets/NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \
--mount=type=secret,id=NEXT_PUBLIC_DRIVE_LINK,target=/run/secrets/NEXT_PUBLIC_DRIVE_LINK \
--mount=type=secret,id=NEXT_PUBLIC_UMAMI_WEBSITE_ID,target=/run/secrets/NEXT_PUBLIC_UMAMI_WEBSITE_ID \
DATABASE_URL=$(cat /run/secrets/DATABASE_URL) \
REDIS_URI=$(cat /run/secrets/REDIS_URI) \
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=$(cat /run/secrets/NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY) \
NEXT_PUBLIC_DRIVE_LINK=$(cat /run/secrets/NEXT_PUBLIC_DRIVE_LINK) \
NEXT_PUBLIC_UMAMI_WEBSITE_ID=$(cat /run/secrets/NEXT_PUBLIC_UMAMI_WEBSITE_ID) \
pnpm run build

# Final deployment image
Expand Down
7 changes: 7 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Footer from '@/components/Footer';
import Header from '@/components/Header';
import { env } from '@/env.mjs';
import '@/styles/globals.css';
import { ClerkProvider } from '@clerk/nextjs';
import type { Metadata, Viewport } from 'next';
import { Archivo } from 'next/font/google';
import Script from 'next/script';

export const metadata: Metadata = {
icons: '/favicon.ico',
Expand Down Expand Up @@ -47,6 +49,11 @@ export default function RootLayout({ children }: RootLayoutProps) {
}}
>
<html lang="en" className={archivo.className}>
<Script
defer
src="https://umami.csclub.org.au/script.js"
data-website-id={env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
/>
<body className="overflow-x-hidden bg-grey text-white">
<Header />
<div className="mx-auto min-h-screen w-responsive pb-6 pt-32 md:pt-40">
Expand Down
2 changes: 2 additions & 0 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const env = createEnv({
NEXT_PUBLIC_CLERK_SIGN_UP_URL: z.literal('/join'),
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL: z.literal('/'),
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL: z.literal('/'),
NEXT_PUBLIC_UMAMI_WEBSITE_ID: z.string().optional(),
},
experimental__runtimeEnv: {
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY,
Expand All @@ -29,6 +30,7 @@ export const env = createEnv({
NEXT_PUBLIC_CLERK_SIGN_UP_URL: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL,
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL: process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL,
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL: process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL,
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID,
},
skipValidation: process.env.SKIP_ENV_VALIDATION,
});

0 comments on commit f507e4d

Please sign in to comment.