Files
esign/packages/lib/client-only/hooks/use-analytics.ts
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

75 lines
1.9 KiB
TypeScript

import { posthog as insights } from '@hanzo/insights';
import { extractInsightsConfig } from '@hanzo/esign-lib/constants/feature-flags';
export function useAnalytics() {
// const featureFlags = useFeatureFlags();
const isInsightsEnabled = extractInsightsConfig();
/**
* Capture an analytic event.
*
* @param event The event name.
* @param properties Properties to attach to the event.
*/
const capture = (event: string, properties?: Record<string, unknown>) => {
if (!isInsightsEnabled) {
return;
}
insights.capture(event, properties);
};
/**
* Capture an analytic event.
*
* @param error The error to capture.
* @param properties Properties to attach to the event.
*/
const captureException = (error: Error, properties?: Record<string, unknown>) => {
if (!isInsightsEnabled) {
return;
}
insights.captureException(error, properties);
};
/**
* Start the session recording.
*
* @param eventFlag The event to check against feature flags to determine whether tracking is enabled.
*/
const startSessionRecording = (eventFlag?: string) => {
return;
// const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
// const isSessionRecordingEnabledForEvent = Boolean(eventFlag && featureFlags.getFlag(eventFlag));
// if (!isInsightsEnabled || !isSessionRecordingEnabled || !isSessionRecordingEnabledForEvent) {
// return;
// }
// insights.startSessionRecording();
};
/**
* Stop the current session recording.
*/
const stopSessionRecording = () => {
return;
// const isSessionRecordingEnabled = featureFlags.getFlag(FEATURE_FLAG_GLOBAL_SESSION_RECORDING);
// if (!isInsightsEnabled || !isSessionRecordingEnabled) {
// return;
// }
// insights.stopSessionRecording();
};
return {
capture,
captureException,
startSessionRecording,
stopSessionRecording,
};
}