mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
fix: wip
This commit is contained in:
@ -7,7 +7,7 @@ import {
|
||||
} from '@documenso/lib/constants/feature-flags';
|
||||
|
||||
export function useAnalytics() {
|
||||
const featureFlags = useFeatureFlags();
|
||||
// const featureFlags = useFeatureFlags();
|
||||
const isPostHogEnabled = extractPostHogConfig();
|
||||
|
||||
/**
|
||||
@ -30,27 +30,29 @@ export function useAnalytics() {
|
||||
* @param eventFlag The event to check against feature flags to determine whether tracking is enabled.
|
||||
*/
|
||||
const startSessionRecording = (eventFlag?: string) => {
|
||||
const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
|
||||
const isSessionRecordingEnabledForEvent = Boolean(eventFlag && featureFlags.getFlag(eventFlag));
|
||||
return;
|
||||
// const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
|
||||
// const isSessionRecordingEnabledForEvent = Boolean(eventFlag && featureFlags.getFlag(eventFlag));
|
||||
|
||||
if (!isPostHogEnabled || !isSessionRecordingEnabled || !isSessionRecordingEnabledForEvent) {
|
||||
return;
|
||||
}
|
||||
// if (!isPostHogEnabled || !isSessionRecordingEnabled || !isSessionRecordingEnabledForEvent) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
posthog.startSessionRecording();
|
||||
// posthog.startSessionRecording();
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop the current session recording.
|
||||
*/
|
||||
const stopSessionRecording = () => {
|
||||
const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
|
||||
return;
|
||||
// const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
|
||||
|
||||
if (!isPostHogEnabled || !isSessionRecordingEnabled) {
|
||||
return;
|
||||
}
|
||||
// if (!isPostHogEnabled || !isSessionRecordingEnabled) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
posthog.stopSessionRecording();
|
||||
// posthog.stopSessionRecording();
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@ -5,14 +5,15 @@ import type { Session, User } from '@prisma/client';
|
||||
|
||||
interface AuthProviderProps {
|
||||
children: React.ReactNode;
|
||||
session: Session;
|
||||
user: User;
|
||||
session: DocumensoSession | null;
|
||||
}
|
||||
|
||||
const SessionContext = createContext<{
|
||||
export type DocumensoSession = {
|
||||
user: User; // Todo: Exclude password
|
||||
session: Session;
|
||||
} | null>(null);
|
||||
};
|
||||
|
||||
const SessionContext = createContext<DocumensoSession | null>(null);
|
||||
|
||||
export const useSession = () => {
|
||||
const context = useContext(SessionContext);
|
||||
@ -24,6 +25,15 @@ export const useSession = () => {
|
||||
return context;
|
||||
};
|
||||
|
||||
export const SessionProvider = ({ children, session, user }: AuthProviderProps) => {
|
||||
return <SessionContext.Provider value={{ session, user }}>{children}</SessionContext.Provider>;
|
||||
export const useOptionalSession = () => {
|
||||
return (
|
||||
useContext(SessionContext) || {
|
||||
user: null,
|
||||
session: null,
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const SessionProvider = ({ children, session }: AuthProviderProps) => {
|
||||
return <SessionContext.Provider value={session}>{children}</SessionContext.Provider>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user