📈 Stop using bootstrap data

This commit is contained in:
Luke Vella 2025-07-13 14:55:33 +01:00
parent b9b92bf0af
commit 371510a9cd
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
3 changed files with 0 additions and 27 deletions

View file

@ -4,10 +4,8 @@ import { Trans } from "@/components/trans";
import { usePostHog } from "@rallly/posthog/client"; import { usePostHog } from "@rallly/posthog/client";
import { Button } from "@rallly/ui/button"; import { Button } from "@rallly/ui/button";
import { Icon } from "@rallly/ui/icon"; import { Icon } from "@rallly/ui/icon";
import Cookies from "js-cookie";
import { LogOutIcon } from "lucide-react"; import { LogOutIcon } from "lucide-react";
import { signOut } from "next-auth/react"; import { signOut } from "next-auth/react";
import { POSTHOG_BOOTSTAP_DATA_COOKIE_NAME } from "node_modules/@rallly/posthog/src/constants";
export const SignOutButton = () => { export const SignOutButton = () => {
const posthog = usePostHog(); const posthog = usePostHog();
@ -17,7 +15,6 @@ export const SignOutButton = () => {
size="sm" size="sm"
onClick={() => { onClick={() => {
posthog?.reset(); posthog?.reset();
Cookies.remove(POSTHOG_BOOTSTAP_DATA_COOKIE_NAME);
signOut({ signOut({
redirectTo: "/", redirectTo: "/",
}); });

View file

@ -1,5 +1,4 @@
import { getPreferredLocale } from "@rallly/languages/get-preferred-locale"; import { getPreferredLocale } from "@rallly/languages/get-preferred-locale";
import { getPosthogBootstrapCookie } from "@rallly/posthog/utils";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import { withAuth } from "@/auth/edge"; import { withAuth } from "@/auth/edge";
@ -27,15 +26,6 @@ export const middleware = withAuth(async (req) => {
res.headers.set("x-locale", locale); res.headers.set("x-locale", locale);
res.headers.set("x-pathname", pathname); res.headers.set("x-pathname", pathname);
if (req.auth?.user?.id) {
const bootstrapCookie = getPosthogBootstrapCookie({
distinctID: req.auth.user.id,
});
if (bootstrapCookie) {
res.cookies.set(bootstrapCookie);
}
}
return res; return res;
}); });

View file

@ -1,23 +1,10 @@
"use client"; "use client";
import Cookies from "js-cookie";
import posthog from "posthog-js"; import posthog from "posthog-js";
import { POSTHOG_BOOTSTAP_DATA_COOKIE_NAME } from "./constants";
export { usePostHog } from "posthog-js/react"; export { usePostHog } from "posthog-js/react";
import { PostHogProvider as BasePostHogProvider } from "posthog-js/react"; import { PostHogProvider as BasePostHogProvider } from "posthog-js/react";
if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_API_KEY) { if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_API_KEY) {
let bootstrapData = {};
try {
const cookieData = Cookies.get(POSTHOG_BOOTSTAP_DATA_COOKIE_NAME);
if (cookieData) {
bootstrapData = JSON.parse(cookieData);
}
} catch (error) {
console.warn("Failed to parse PostHog bootstrap data:", error);
}
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_API_KEY, { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_API_KEY, {
debug: false, debug: false,
api_host: process.env.NEXT_PUBLIC_POSTHOG_API_HOST, api_host: process.env.NEXT_PUBLIC_POSTHOG_API_HOST,
@ -26,7 +13,6 @@ if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_API_KEY) {
disable_session_recording: true, disable_session_recording: true,
enable_heatmaps: false, enable_heatmaps: false,
persistence: "cookie", persistence: "cookie",
bootstrap: bootstrapData,
autocapture: false, autocapture: false,
opt_out_capturing_by_default: false, opt_out_capturing_by_default: false,
cross_subdomain_cookie: true, cross_subdomain_cookie: true,