Skip to content

Commit

Permalink
Merge pull request #48 from SkidGod4444/feature/auth
Browse files Browse the repository at this point in the history
add posthog analytics
  • Loading branch information
SkidGod4444 authored Nov 13, 2024
2 parents 8a7dc6b + eb38c9c commit 1433a02
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 31 deletions.
39 changes: 21 additions & 18 deletions apps/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppSidebar } from "@/components/custom/sidebar/sidebar";
import { cookies } from "next/headers";
import Infobar from "@/components/custom/infobar/infobar";
import ProgressBar from "@/components/custom/progress.bar";
import { PosthogProvider } from "@/hooks/posthog";

export const metadata: Metadata = {
title: "Plura",
Expand All @@ -23,25 +24,27 @@ async function RootLayout({

return (
<html lang="en" suppressHydrationWarning>
<body
className={`min-h-screen bg-background font-sans ${GeistSans.variable} antialiased`}
>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
<PosthogProvider>
<body
className={`min-h-screen bg-background font-sans ${GeistSans.variable} antialiased`}
>
<SidebarProvider defaultOpen={defaultOpen}>
<AppSidebar />
<div className="p-2">
<ProgressBar />
<Infobar />
{children}
</div>
</SidebarProvider>
</ThemeProvider>
</body>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
<SidebarProvider defaultOpen={defaultOpen}>
<AppSidebar />
<div className="p-2">
<ProgressBar />
<Infobar />
{children}
</div>
</SidebarProvider>
</ThemeProvider>
</body>
</PosthogProvider>
</html>
);
}
Expand Down
17 changes: 17 additions & 0 deletions apps/app/hooks/posthog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"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!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST!,
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
});
}
export function PosthogProvider({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
29 changes: 16 additions & 13 deletions apps/www/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { GeistSans } from "geist/font/sans";
import "./globals.css";
import { ThemeProvider } from "@/hooks/theme-provider";
import { PosthogProvider } from "@/hooks/posthog";

export const metadata: Metadata = {
title: "Plura",
Expand All @@ -15,20 +16,22 @@ export default function RootLayout({
}>) {
return (
<html lang="en" suppressHydrationWarning>
<body
className={` bg-background font-sans min-h-screen ${GeistSans.variable} antialiased`}
>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
<PosthogProvider>
<body
className={` bg-background font-sans min-h-screen ${GeistSans.variable} antialiased`}
>
<div className="flex flex-col items-center bg-background mx-auto">
{children}
</div>
</ThemeProvider>
</body>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
disableTransitionOnChange
>
<div className="flex flex-col items-center bg-background mx-auto">
{children}
</div>
</ThemeProvider>
</body>
</PosthogProvider>
</html>
);
}
17 changes: 17 additions & 0 deletions apps/www/hooks/posthog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"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!, {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST!,
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
});
}
export function PosthogProvider({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"next": "15.0.2",
"next-auth": "5.0.0-beta.25",
"postcss": "^8",
"posthog-js": "^1.184.1",
"supertest": "^7.0.0",
"tailwindcss": "^3.4.1",
"typescript": "^5",
Expand Down
33 changes: 33 additions & 0 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 1433a02

Please sign in to comment.