diff --git a/apps/web/app/(app)/environments/[environmentId]/components/PosthogIdentify.tsx b/apps/web/app/(app)/environments/[environmentId]/components/PosthogIdentify.tsx index 7bc4df1484..815938fc79 100644 --- a/apps/web/app/(app)/environments/[environmentId]/components/PosthogIdentify.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/components/PosthogIdentify.tsx @@ -19,25 +19,29 @@ export default function PosthogIdentify({ userTargetingBillingStatus, }: { session: Session; - environmentId: string; - teamId: string; - teamName: string; - inAppSurveyBillingStatus: TSubscriptionStatus; - linkSurveyBillingStatus: TSubscriptionStatus; - userTargetingBillingStatus: TSubscriptionStatus; + environmentId?: string; + teamId?: string; + teamName?: string; + inAppSurveyBillingStatus?: TSubscriptionStatus; + linkSurveyBillingStatus?: TSubscriptionStatus; + userTargetingBillingStatus?: TSubscriptionStatus; }) { const posthog = usePostHog(); useEffect(() => { if (posthogEnabled && session.user && posthog) { posthog.identify(session.user.id, { name: session.user.name, email: session.user.email }); - posthog.group("environment", environmentId, { name: environmentId }); - posthog.group("team", teamId, { - name: teamName, - inAppSurveyBillingStatus, - linkSurveyBillingStatus, - userTargetingBillingStatus, - }); + if (environmentId) { + posthog.group("environment", environmentId, { name: environmentId }); + } + if (teamId) { + posthog.group("team", teamId, { + name: teamName, + inAppSurveyBillingStatus, + linkSurveyBillingStatus, + userTargetingBillingStatus, + }); + } } }, [ posthog, diff --git a/apps/web/app/(app)/onboarding/layout.tsx b/apps/web/app/(app)/onboarding/layout.tsx index f967ef2400..05963e87c6 100644 --- a/apps/web/app/(app)/onboarding/layout.tsx +++ b/apps/web/app/(app)/onboarding/layout.tsx @@ -1,3 +1,4 @@ +import PosthogIdentify from "@/app/(app)/environments/[environmentId]/components/PosthogIdentify"; import { getServerSession } from "next-auth"; import { redirect } from "next/navigation"; @@ -12,6 +13,7 @@ export default async function EnvironmentLayout({ children }) { return (