Skip to content

Commit

Permalink
chore(website): added analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
not-ani committed Nov 18, 2024
1 parent 9b0b92a commit 5ea7d4a
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
18 changes: 18 additions & 0 deletions apps/website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ const config = {
/** We already do linting and typechecking as separate tasks in CI */
eslint: { ignoreDuringBuilds: true },
typescript: { ignoreBuildErrors: true },
async rewrites() {
return [
{
source: "/ingest/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ingest/:path*",
destination: "https://us.i.posthog.com/:path*",
},
{
source: "/ingest/decide",
destination: "https://us.i.posthog.com/decide",
},
];
},
// This is required to support PostHog trailing slash API requests
skipTrailingSlashRedirect: true,
};

export default config;
1 change: 1 addition & 0 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"github-slugger": "^2.0.0",
"lucide-react": "^0.416.0",
"next": "^14.2.14",
"posthog-js": "^1.167.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-syntax-highlighter": "^15.5.0",
Expand Down
6 changes: 5 additions & 1 deletion apps/website/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import "~/app/globals.css";
import type { Metadata } from "next";
import { GeistSans } from "geist/font/sans";

import { CSPostHogProvider } from "./provides/posthog";

export const metadata: Metadata = {
title: {
default: "amaxa",
Expand Down Expand Up @@ -74,7 +76,9 @@ export default function RootLayout({
}>) {
return (
<html lang="en" className={`${GeistSans.variable}`}>
<body>{children}</body>
<body>
<CSPostHogProvider>{children}</CSPostHogProvider>
</body>
</html>
);
}
15 changes: 15 additions & 0 deletions apps/website/src/app/provides/posthog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ts-nocheck
"use client";

import posthog from "posthog-js";
import { PostHogProvider } from "posthog-js/react";

if (typeof window !== "undefined") {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {

Check warning on line 8 in apps/website/src/app/provides/posthog.tsx

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion

Check failure on line 8 in apps/website/src/app/provides/posthog.tsx

View workflow job for this annotation

GitHub Actions / lint

'process.env' is restricted from being used. Use `import { env } from '~/env'` instead to ensure validated types
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,

Check failure on line 9 in apps/website/src/app/provides/posthog.tsx

View workflow job for this annotation

GitHub Actions / lint

'process.env' is restricted from being used. Use `import { env } from '~/env'` instead to ensure validated types
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
});
}
export function CSPostHogProvider({ children }: { children: React.ReactNode }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 5ea7d4a

Please sign in to comment.