mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-01 18:19:43 +00:00
fix(web): redact invite analytics URLs
This commit is contained in:
1 parent
ff2cf09170
commit
ade2c42d51
3 files changed
+50
-11
No files matched your search
@@ -2,16 +2,27 @@
|
||||
|
||||
import posthog from 'posthog-js'
|
||||
import { PostHogProvider as PHProvider } from 'posthog-js/react'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
||||
import { useEffect } from 'react'
|
||||
|
||||
function redactInviteUrl(defaultUrl: string): string {
|
||||
const url = new URL(defaultUrl)
|
||||
|
||||
if (url.pathname.startsWith('/join/')) {
|
||||
return `${url.origin}/join/[invite]`
|
||||
}
|
||||
|
||||
return defaultUrl
|
||||
}
|
||||
|
||||
export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
if (typeof window !== 'undefined' && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
|
||||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://eu.i.posthog.com',
|
||||
person_profiles: 'identified_only',
|
||||
capture_pageview: false, // We'll capture pageviews manually for better control
|
||||
capture_pageleave: true,
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://eu.i.posthog.com',
|
||||
person_profiles: 'identified_only',
|
||||
capture_pageview: false,
|
||||
capture_pageleave: false,
|
||||
get_current_url: redactInviteUrl,
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
Reference in new issue
Block a user