Authentication

This provider requires authentication.

  • api_key: PostHog API key (required: True, sensitive: True)
  • project_id: PostHog project ID (required: True, sensitive: False)

Certain scopes may be required to perform specific actions or queries via the provider. Below is a summary of relevant scopes and their use cases:

  • session_recording:read: Read PostHog session recordings (mandatory)
  • session_recording_playlist:read: Read PostHog session recording playlists
  • project:read: Read PostHog project data (mandatory)

In workflows

This provider can be used in workflows.

As “step” to query data, example:

steps:
    - name: Query posthog
      provider: posthog
      config: "{{ provider.my_provider_name }}"
      with:
        query_type: {value}  # Type of query (e.g., "session_recording_domains", "session_recordings")
        hours: {value}  # Number of hours to look back
        limit: {value}  # Maximum number of items to fetch
        # Additional arguments

Check the following workflow example:

Provider Methods

The provider exposes the following Provider Methods. They are available in the AI Assistant.

  • get_session_recording_domains Get a list of domains from session recordings within a time period (action, scopes: session_recording:read, project:read)

    • hours: Number of hours to look back (default: 24)
    • limit: Maximum number of recordings to fetch (default: 100)
  • get_session_recordings Get session recordings within a time period (action, scopes: session_recording:read, project:read)

    • hours: Number of hours to look back (default: 24)
    • limit: Maximum number of recordings to fetch (default: 100)

Connecting with the Provider

API Key

To obtain the PostHog API key, follow these steps:

  1. Log in to your PostHog account.
  2. Navigate to “Project Settings” > “API Keys”.
  3. Create a new API key or use an existing one.
  4. Copy the API key value.

Project ID

To find your PostHog project ID:

  1. Log in to your PostHog account.
  2. The project ID is visible in your project settings or in the URL when you’re viewing your project.

Available Methods

The PostHog provider offers the following methods:

Get Session Recording Domains

Retrieve a list of domains from session recordings within a specified time period.

- name: get-posthog-domains
  provider:
    config: "{{ providers.posthog }}"
    type: posthog
    with:
      query_type: session_recording_domains
      hours: 24       # Number of hours to look back
      limit: 500      # Maximum number of recordings to fetch

Get Session Recordings

Retrieve session recordings data within a specified time period.

- name: get-posthog-recordings
  provider:
    config: "{{ providers.posthog }}"
    type: posthog
    with:
      query_type: session_recordings
      hours: 24       # Number of hours to look back
      limit: 100      # Maximum number of recordings to fetch

Example Workflow

Here’s an example workflow that tracks domains from PostHog session recordings over the last 24 hours and sends a summary to Slack:

workflow:
  id: posthog-domain-tracker
  name: PostHog Domain Tracker
  description: Tracks domains from PostHog session recordings over the last 24 hours and sends a summary to Slack.
  triggers:
    - type: manual
    - type: interval
      value: 86400  # Run daily (in seconds)
  steps:
    - name: get-posthog-domains
      provider:
        config: "{{ providers.posthog }}"
        type: posthog
        with:
          query_type: session_recording_domains
          hours: 24
          limit: 500
  actions:
      - name: send-to-slack
        provider:
          config: "{{ providers.slack }}"
          type: slack
          with:
            blocks:
              - type: header
                text:
                  type: plain_text
                  text: "PostHog Session Recording Domains (Last 24 Hours)"
                  emoji: true
              - type: section
                text:
                  type: mrkdwn
                  text: "Found *{{ steps.get-posthog-domains.results.unique_domains_count }}* unique domains across *{{ steps.get-posthog-domains.results.total_domains_found }}* occurrences"
              - type: divider
              - type: section
                text:
                  type: mrkdwn
                  text: "Domains:*"
              - type: section
                text:
                  type: mrkdwn
                  text: "{{#steps.get-posthog-domains.results.unique_domains}}
                    • *{{ . }}*
                    {{/steps.get-posthog-domains.results.unique_domains}}"
              - type: divider

Notes

The PostHog provider requires the following scopes:

  • session_recording:read - Allows reading session recordings data
  • project:read - Allows reading project data
  • session_recording_playlist:read - Optional access to recording playlists