diff --git a/package.json b/package.json index e5ab64b08..9e22c7ef0 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "hey@posthog.com", "license": "MIT", "scripts": { - "start": "pnpm build-rollup -w", + "start": "pnpm build-react && pnpm build-rollup -w", "build": "pnpm build-rollup && pnpm build-react", "build-rollup": "rm -rf lib && tsc -b && rollup -c --bundleConfigAsCjs", "build-react": "cd react; pnpm i; pnpm build;", diff --git a/playground/nextjs/package.json b/playground/nextjs/package.json index 248f09b3f..d78b4bd50 100644 --- a/playground/nextjs/package.json +++ b/playground/nextjs/package.json @@ -3,7 +3,8 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev", + "clean-react": "cd ../../react && rm -rf ./node_modules/", + "dev": "pnpm run clean-react && next dev", "build": "next build", "start": "next start", "lint": "next lint" @@ -20,5 +21,10 @@ "react": "18.2.0", "react-dom": "18.2.0", "typescript": "4.9.5" + }, + "devDependencies": { + "autoprefixer": "^10.4.17", + "postcss": "^8.4.35", + "tailwindcss": "^3.4.1" } } diff --git a/playground/nextjs/pages/_app.tsx b/playground/nextjs/pages/_app.tsx index d36154d28..7de0a2204 100644 --- a/playground/nextjs/pages/_app.tsx +++ b/playground/nextjs/pages/_app.tsx @@ -6,6 +6,7 @@ import { useRouter } from 'next/router' import posthog from 'posthog-js' import { PostHogProvider } from 'posthog-js/react' +import { CookieBanner, cookieConsentGiven } from '@/src/CookieBanner' if (typeof window !== 'undefined') { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || '', { @@ -15,10 +16,11 @@ if (typeof window !== 'undefined') { }, debug: true, __preview_send_client_session_params: true, - __preview_measure_pageview_stats: true, scroll_root_selector: ['#scroll_element', 'html'], + persistence: cookieConsentGiven() ? 'localStorage+cookie' : 'memory', }) - ;(window as any).posthog = posthog + + window.posthog = posthog } export default function App({ Component, pageProps }: AppProps) { @@ -37,6 +39,8 @@ export default function App({ Component, pageProps }: AppProps) { return ( + + ) } diff --git a/playground/nextjs/pages/iframe.tsx b/playground/nextjs/pages/iframe.tsx index a159583f9..f96c427b9 100644 --- a/playground/nextjs/pages/iframe.tsx +++ b/playground/nextjs/pages/iframe.tsx @@ -27,6 +27,7 @@ export default function Home() { {otherHost && (