mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-27 05:07:50 +02:00
📈 Stop using bootstrap data
This commit is contained in:
parent
b9b92bf0af
commit
371510a9cd
3 changed files with 0 additions and 27 deletions
|
@ -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: "/",
|
||||||
});
|
});
|
||||||
|
|
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue