mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
fix: rework sessions
This commit is contained in:
@ -3,7 +3,6 @@ import { useEffect } from 'react';
|
||||
import posthog from 'posthog-js';
|
||||
import { useLocation, useSearchParams } from 'react-router';
|
||||
|
||||
import { useOptionalSession } from '@documenso/lib/client-only/providers/session';
|
||||
import { extractPostHogConfig } from '@documenso/lib/constants/feature-flags';
|
||||
|
||||
export function PostHogPageview() {
|
||||
@ -12,19 +11,20 @@ export function PostHogPageview() {
|
||||
const { pathname } = useLocation();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const { user } = useOptionalSession();
|
||||
// const { sessionData } = useOptionalSession();
|
||||
// const user = sessionData?.user;
|
||||
|
||||
if (typeof window !== 'undefined' && postHogConfig) {
|
||||
posthog.init(postHogConfig.key, {
|
||||
api_host: postHogConfig.host,
|
||||
disable_session_recording: true,
|
||||
loaded: () => {
|
||||
if (user) {
|
||||
posthog.identify(user.email ?? user.id.toString());
|
||||
} else {
|
||||
posthog.reset();
|
||||
}
|
||||
},
|
||||
// loaded: () => {
|
||||
// if (user) {
|
||||
// posthog.identify(user.email ?? user.id.toString());
|
||||
// } else {
|
||||
// posthog.reset();
|
||||
// }
|
||||
// },
|
||||
custom_campaign_params: ['src'],
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import type { TGetTeamByUrlResponse } from '@documenso/lib/server-only/team/get-team';
|
||||
import type { TGetTeamsResponse } from '@documenso/lib/server-only/team/get-teams';
|
||||
|
||||
type TeamProviderValue = TGetTeamsResponse[0];
|
||||
|
||||
interface TeamProviderProps {
|
||||
children: React.ReactNode;
|
||||
team: TGetTeamByUrlResponse;
|
||||
team: TeamProviderValue;
|
||||
}
|
||||
|
||||
const TeamContext = createContext<TGetTeamByUrlResponse | null>(null);
|
||||
const TeamContext = createContext<TeamProviderValue | null>(null);
|
||||
|
||||
export const useCurrentTeam = () => {
|
||||
const context = useContext(TeamContext);
|
||||
|
||||
Reference in New Issue
Block a user