Files
ever-gauzy/packages/plugins/posthog
samuel mbabhazi 292e6eaa6d [feat] Integrate PostHog plugin (#8911)
* feat(plugin-posthog): initial setup of PostHog plugin

* feat(posthog): add interfaces for PostHog module configuration

* feat(posthog): add constant for injection token

* feat(posthog): implement PosthogService with track, identify and shutdown methods

* feat(posthog): implement core module with support for sync and async config

* feat(posthog): create main module with forRoot and forRootAsync

* chore(posthog):install latest posthog-node

* feat(posthog): update PostHog interfaces to match official client options

* feat(posthog): enhance PostHog service with feature flag support and alignment with official client

* feat(posthog): update PostHog interfaces to match official client options

* feat(middleware): add PosthogRequestMiddleware for capturing request context

* feat(middleware): enhance PosthogTraceMiddleware with performance metrics

* feat(interceptor): implement PosthogErrorInterceptor for error tracking

* feat(plugin): create base PosthogPlugin structure

* feat(interceptor): implement PosthogCustomInterceptor

* feat(config):Add config posthog

* add plugin

* feat(posthog): Refactor service logic && update config

* Remove unnecessary changes

* feat(posthog):Refactor and reorganize the plugin codebase for better structure and maintainability

* fix: deepscan

* feadback integration

* suggestion integration

* remove unecessary changes
2025-04-20 09:52:22 +02:00
..

@gauzy/plugin-posthog

Overview

The PostHog Plugin seamlessly integrates your server with PostHog, an open-source analytics platform. This integration enables you to capture, monitor, and analyze user behavior and application events in real time.

Features

  • Error Tracking: Automatically report exceptions and errors to PostHog’s new error tracking feature.
  • User Behavior Insights: Gain comprehensive insights into user interactions within your application.
  • Event Tracking: Capture custom application events for detailed analysis.

Configuration

The plugin can be configured using the following environment variables:

  • POSTHOG_KEY: Your PostHog API key
  • POSTHOG_HOST: PostHog server URL (default: https://app.posthog.com)
  • POSTHOG_ENABLED: Enable/disable the plugin (default: false)
  • POSTHOG_FLUSH_INTERVAL: Interval for flushing events in milliseconds (default: 10000)

Building

Run yarn nx build plugin-posthog to build the library.

Running unit tests

Run yarn nx test plugin-posthog to execute the unit tests via Jest.

Publishing

After building your library with yarn nx build plugin-posthog, go to the dist folder dist/packages/plugins/posthog and run npm publish.

Installation

Install the PostHog Plugin using your preferred package manager:

npm install @gauzy/plugin-posthog
# or
yarn add @gauzy/plugin-posthog