Files
prowler/ui/lib/posthog.ts
Amit Sharma bc34c9df4a feat: centralize PostHog analytics with proper error handling
- Create lib/analytics.ts with centralized tracking functions
- Use arrow functions and camelCase naming per code standards
- Add error handling to prevent analytics failures from crashing app
- Update auth forms and provider workflows to use new analytics lib
- Export TypeScript interfaces for type-safe analytics payloads

Addresses PR review comments:
- Convert to arrow functions (requested by @paabloLC)
- Use camelCase for event and property names
- Centralize analytics logic for better maintainability
2025-07-29 19:49:12 -07:00

14 lines
402 B
TypeScript

import { PostHog } from "posthog-node";
// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
const PostHogClient = () => {
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
flushAt: 1,
flushInterval: 0,
});
return posthogClient;
};
export default PostHogClient;