Skip to content

PostHog

PostHog is an open-source product analytics platform that helps teams understand user behavior, track events, and manage feature flags.

Bruin supports PostHog as a source for Ingestr assets. You can ingest data from PostHog into your data platform.

To set up a PostHog connection, add a configuration item in the .bruin.yml file and in your asset file. The configuration requires personal_api_key and project_id.

Configuration

Step 1: Add a connection to the .bruin.yml file

yaml
connections:
  posthog:
    - name: "posthog"
      personal_api_key: "phx_1234567890abcdef"
      project_id: "12345"
  • personal_api_key: Personal API key used to authenticate with the PostHog API.
  • project_id: The ID of the PostHog project to ingest data from.

Step 2: Create an asset file for data ingestion

Create an asset configuration file (e.g., posthog_ingestion.yml) inside the assets folder with the following content:

yaml
name: public.posthog
type: ingestr

parameters:
  source_connection: posthog
  source_table: 'persons'

  destination: postgres
  • name: The name of the asset.
  • type: Always ingestr for PostHog.
  • source_connection: The PostHog connection name defined in .bruin.yml.
  • source_table: Name of the PostHog table to ingest.
  • destination: The destination connection name.

Available Source Tables

TablePKInc KeyInc StrategyDetails
personsidlast_seen_atmergePerson profiles with their properties
feature_flagsidupdated_atmergeFeature flags configured in the project
eventsidtimestampappendEvents tracked in the project
cohortsidlast_calculationmergeCohorts defined in the project
event_definitionsidlast_updated_atmergeEvent definitions in the project
property_definitions:eventidupdated_atmergeEvent property definitions
property_definitions:personidupdated_atmergePerson property definitions
property_definitions:sessionidupdated_atmergeSession property definitions
annotationsidupdated_atmergeAnnotations created in the project

Step 3: Run asset to ingest data

bash
bruin run assets/posthog_ingestion.yml

Running this command ingests data from PostHog into your Postgres database.