Skip to content

Commit 9e5fb63

Browse files
committed
Add krakens analytics
1 parent 5cbcb62 commit 9e5fb63

6 files changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/docker-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868
platforms: linux/amd64
6969
build-args: |
7070
NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}
71+
NEXT_PUBLIC_KRAKENS_PROJECT_ID=${{ secrets.NEXT_PUBLIC_KRAKENS_PROJECT_ID }}
7172
7273
- name: 🐳 Build and push Docker image (server)
7374
if: inputs.service == 'server'

client/.env.local.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# API Base URL (optional - defaults to http://localhost:3001 in development)
22
NEXT_PUBLIC_API_URL=
3+
# track user traffics through krakens dashboard
4+
NEXT_PUBLIC_KRAKENS_PROJECT_ID=

client/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ COPY . .
1717

1818
# NEXT_PUBLIC_* vars must be available at build time (they are inlined by Next.js)
1919
ARG NEXT_PUBLIC_API_URL
20+
ARG NEXT_PUBLIC_KRAKENS_PROJECT_ID
21+
22+
ENV NEXT_PUBLIC_KRAKENS_PROJECT_ID=$NEXT_PUBLIC_KRAKENS_PROJECT_ID
2023
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
2124

2225
RUN npm run build

client/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from 'next';
22
import { Inter } from 'next/font/google';
33
import { ThemeProvider } from '@/components/providers/ThemeProvider';
44
import '@/styles/globals.css';
5+
import { KrakensAnalytics } from '@/components/krakens-analytics';
56

67
/**
78
* Root layout - wraps all pages
@@ -50,6 +51,7 @@ export default function RootLayout({
5051
return (
5152
<html lang="en" suppressHydrationWarning className={inter.variable}>
5253
<body>
54+
<KrakensAnalytics />
5355
<ThemeProvider
5456
attribute="class"
5557
defaultTheme="system"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use client';
2+
3+
import Script from 'next/script';
4+
5+
export function KrakensAnalytics() {
6+
return (
7+
<Script
8+
src="https://krakens.nesohq.org/krakens.js"
9+
strategy="afterInteractive"
10+
onLoad={() => {
11+
const projectId = process.env.NEXT_PUBLIC_KRAKENS_PROJECT_ID;
12+
if (typeof window !== 'undefined' && (window as any).Krakens && projectId) {
13+
(window as any).Krakens.init(projectId);
14+
}
15+
}}
16+
/>
17+
);
18+
}

client/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)