Add PostHog analytics tracking and feature flags to your Convex backend functions with server-side event capture and A/B testing.
npm install @posthog/convexThe official PostHog component for Convex that integrates analytics event tracking and feature flags into your backend functions. It provides both local feature flag evaluation (cached definitions with reactive queries) and remote evaluation options, plus comprehensive event capture methods for user analytics. Events are captured asynchronously via ctx.scheduler.runAfter to avoid blocking mutations and actions.
Use @posthog/convex to capture analytics events directly from your Convex mutations and actions. The component provides server-side PostHog integration that lets you track user actions, conversions, and custom events without relying on client-side tracking.
Implement feature flags in your Convex functions using @posthog/convex to control backend behavior. You can gate database operations, API calls, and business logic based on PostHog feature flag configurations.
Track third-party API calls and external service interactions by integrating PostHog analytics into your Convex actions. This enables comprehensive product analytics across your entire backend workflow.
Run server-side A/B tests in your Convex functions using PostHog feature flags. Test different database query strategies, business logic variations, or API integrations based on user segments.
@posthog/convex can be used in both Convex mutations and actions to track events and check feature flags. Since it integrates with PostHog's server-side APIs, it works in any Convex function context.
The @posthog/convex component makes HTTP requests to PostHog's APIs, which adds network latency to your functions. Consider using it in actions rather than mutations for time-sensitive operations, or implement async event tracking patterns.
Yes, @posthog/convex allows you to check feature flags within your Convex functions to conditionally execute different database queries or business logic. This enables server-side experimentation with your data layer.
@posthog/convex provides server-side tracking only and complements client-side PostHog integration. You typically use both together for comprehensive analytics covering frontend interactions and backend operations.