mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-29 22:27:25 +02:00
Page view
This commit is contained in:
parent
66ff75096a
commit
65a46e42aa
5 changed files with 156 additions and 112 deletions
|
@ -2,6 +2,7 @@ import "tailwindcss/tailwind.css";
|
||||||
import "../../style.css";
|
import "../../style.css";
|
||||||
|
|
||||||
import languages from "@rallly/languages";
|
import languages from "@rallly/languages";
|
||||||
|
import { PostHogProvider } from "@rallly/posthog/client";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
@ -46,6 +47,7 @@ export default async function Root({
|
||||||
return (
|
return (
|
||||||
<html lang={locale} className={sans.className}>
|
<html lang={locale} className={sans.className}>
|
||||||
<body>
|
<body>
|
||||||
|
<PostHogProvider>
|
||||||
<I18nProvider locale={locale}>
|
<I18nProvider locale={locale}>
|
||||||
<div className="mx-auto flex min-h-full w-full max-w-7xl flex-col space-y-12 p-4 sm:p-8">
|
<div className="mx-auto flex min-h-full w-full max-w-7xl flex-col space-y-12 p-4 sm:p-8">
|
||||||
<header className="flex w-full items-center">
|
<header className="flex w-full items-center">
|
||||||
|
@ -60,7 +62,11 @@ export default async function Root({
|
||||||
</Link>
|
</Link>
|
||||||
<nav className="hidden items-center space-x-8 lg:flex">
|
<nav className="hidden items-center space-x-8 lg:flex">
|
||||||
<NavLink href="https://support.rallly.co/workflow/create">
|
<NavLink href="https://support.rallly.co/workflow/create">
|
||||||
<Trans t={t} i18nKey="howItWorks" defaults="How it Works" />
|
<Trans
|
||||||
|
t={t}
|
||||||
|
i18nKey="howItWorks"
|
||||||
|
defaults="How it Works"
|
||||||
|
/>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
<NavLink href="/pricing">
|
<NavLink href="/pricing">
|
||||||
<Trans t={t} i18nKey="pricing" />
|
<Trans t={t} i18nKey="pricing" />
|
||||||
|
@ -152,6 +158,7 @@ export default async function Root({
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
|
</PostHogProvider>
|
||||||
<Analytics />
|
<Analytics />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import "../../style.css";
|
||||||
import { PostHogProvider } from "@rallly/posthog/client";
|
import { PostHogProvider } from "@rallly/posthog/client";
|
||||||
import { Toaster } from "@rallly/ui/toaster";
|
import { Toaster } from "@rallly/ui/toaster";
|
||||||
import type { Viewport } from "next";
|
import type { Viewport } from "next";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
import { Inter } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
@ -12,6 +13,10 @@ import { Providers } from "@/app/providers";
|
||||||
import { getServerSession } from "@/auth";
|
import { getServerSession } from "@/auth";
|
||||||
import { SessionProvider } from "@/auth/session-provider";
|
import { SessionProvider } from "@/auth/session-provider";
|
||||||
|
|
||||||
|
const PostHogPageView = dynamic(() => import("@rallly/posthog/next"), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
const inter = Inter({
|
const inter = Inter({
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
display: "swap",
|
display: "swap",
|
||||||
|
@ -38,6 +43,7 @@ export default async function Root({
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<SessionProvider session={session}>
|
<SessionProvider session={session}>
|
||||||
<PostHogProvider distinctId={session?.user?.id}>
|
<PostHogProvider distinctId={session?.user?.id}>
|
||||||
|
<PostHogPageView />
|
||||||
<Providers>
|
<Providers>
|
||||||
{children}
|
{children}
|
||||||
<TimeZoneChangeDetector />
|
<TimeZoneChangeDetector />
|
||||||
|
|
|
@ -8,13 +8,15 @@
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
"./server": "./src/server/index.ts",
|
"./server": "./src/server/index.ts",
|
||||||
"./client": "./src/client/index.ts"
|
"./client": "./src/client/index.ts",
|
||||||
|
"./next": "./src/next.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"posthog-js": "^1.178.0",
|
"posthog-js": "^1.180.1",
|
||||||
"posthog-node": "^4.2.1"
|
"posthog-node": "^4.2.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^18.2.0"
|
"react": "^18.2.0",
|
||||||
|
"next": "^14.2.13"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
29
packages/posthog/src/next.ts
Normal file
29
packages/posthog/src/next.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
"use client";
|
||||||
|
import { usePathname, useSearchParams } from "next/navigation";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import { usePostHog } from "./client";
|
||||||
|
|
||||||
|
export default function PostHogPageView() {
|
||||||
|
const pathname = usePathname();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const posthog = usePostHog();
|
||||||
|
const previousUrl = React.useRef<string | null>(null);
|
||||||
|
React.useEffect(() => {
|
||||||
|
// Track pageviews
|
||||||
|
if (pathname && posthog) {
|
||||||
|
let url = window.origin + pathname;
|
||||||
|
if (searchParams?.toString()) {
|
||||||
|
url = url + `?${searchParams.toString()}`;
|
||||||
|
}
|
||||||
|
if (previousUrl.current !== url) {
|
||||||
|
posthog.capture("$pageview", {
|
||||||
|
$current_url: url,
|
||||||
|
});
|
||||||
|
previousUrl.current = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [pathname, searchParams, posthog]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
|
@ -12817,10 +12817,10 @@ postgres-range@^1.1.1:
|
||||||
resolved "https://registry.yarnpkg.com/postgres-range/-/postgres-range-1.1.4.tgz#a59c5f9520909bcec5e63e8cf913a92e4c952863"
|
resolved "https://registry.yarnpkg.com/postgres-range/-/postgres-range-1.1.4.tgz#a59c5f9520909bcec5e63e8cf913a92e4c952863"
|
||||||
integrity sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==
|
integrity sha512-i/hbxIE9803Alj/6ytL7UHQxRvZkI9O4Sy+J3HGc4F4oo/2eQAjTSNJ0bfxyse3bH0nuVesCk+3IRLaMtG3H6w==
|
||||||
|
|
||||||
posthog-js@^1.178.0:
|
posthog-js@^1.180.1:
|
||||||
version "1.178.0"
|
version "1.180.1"
|
||||||
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.178.0.tgz#80005798e6c67d4d6565a5648939a0f017b0879b"
|
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.180.1.tgz#e4b1bb2917b306f40c6063102a1508539f44ba2a"
|
||||||
integrity sha512-ILD4flNh72d5dycc4ZouKORlaVr+pDzl5TlZr1JgP0NBAoduHjhE7XZYwk7zdYkry7u0qAIpfv2306zJCW2vGg==
|
integrity sha512-LV65maVrpqkAh0wu32YvU7FpCSEjg6o+sZFYCs1+6tnEa9VvXuz8J6ReLiyRpJABI4j1qX/PB2jaVY5tDbLalQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
core-js "^3.38.1"
|
core-js "^3.38.1"
|
||||||
fflate "^0.4.8"
|
fflate "^0.4.8"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue