Skip to content

PostHog plugin#94

Open
adamkinniburgh wants to merge 3 commits into
mainfrom
work/ak/posthog
Open

PostHog plugin#94
adamkinniburgh wants to merge 3 commits into
mainfrom
work/ak/posthog

Conversation

@adamkinniburgh

@adamkinniburgh adamkinniburgh commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔌 Plugin overview

  • Plugin name: PostHog
  • Purpose / problem solved: Monitor PostHog product analytics in SquaredUp. Imports PostHog organizations, projects, members and feature flags into the graph, and provides data streams for event volume, active users, top events, feature-flag state/evaluations, web analytics, and ad-hoc HogQL queries.
  • Primary audience: Product teams, platform teams and SREs who use PostHog and want its analytics alongside the rest of their observability in SquaredUp.
  • Authentication method(s): API Key — a PostHog personal API key sent as a bearer token, plus a Region (US / EU Cloud) selector.

🖼️ Plugin screenshots

Plugin configuration

image

Default dashboards

Too revealing of sensitive info for a public repo


🧪 Testing

  • Validated with npx squaredup validate — passes (hybrid plugin, 16 data streams, 1 import definition, UI config, icon, default content, config validation and custom types all present).
  • CI validation and the auto-deploy check pass on this PR (see the Plugin PR Summary comment).
  • Manual testing against a live PostHog project (import of organizations/projects/members/feature flags, and each data stream) — author to confirm details.

⚠️ Known limitations

  • Billing data is unavailable — PostHog's billing API cannot be accessed with a personal API key, so spend/usage cost is not surfaced.
  • Rate limits — PostHog enforces per-key rate limits (lower on the analytics/query endpoints), so very frequent refreshes of many HogQL tiles may be throttled.
  • Query scopes — the query-based streams require the query:read scope; without it those streams return an auth error while imports still succeed.
  • HogQL result size — very large query results are capped (~6MB per request); narrow the timeframe or aggregate in the query.
  • Self-hosted PostHog is not supported in this version (US / EU Cloud only).

📚 Checklist

  • Plugin, datastream and UI naming follow SquaredUp guidelines
  • Logo added
  • One or more dashboards added
  • README added including configuration guidance
  • No secrets or credentials included
  • I agree to the Code of Conduct

🤖 Generated with Claude Code

@adamkinniburgh adamkinniburgh requested a review from a team July 16, 2026 13:57
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the PostHog v1 plugin configuration, authentication flow, indexed object streams, HogQL analytics streams, result transformations, scopes, documentation, and default dashboards.

Changes

PostHog plugin

Layer / File(s) Summary
Plugin contracts and authentication
plugins/PostHog/v1/metadata.json, plugins/PostHog/v1/ui.json, plugins/PostHog/v1/custom_types.json, plugins/PostHog/v1/configValidation.json, plugins/PostHog/v1/dataStreams/currentUser.json, plugins/PostHog/v1/dataStreams/scripts/currentUser.js, plugins/PostHog/v1/docs/README.md
Defines PostHog metadata, region and API-key inputs, custom object types, authentication validation, current-user retrieval, and plugin documentation.
Indexed objects and ingestion
plugins/PostHog/v1/dataStreams/organizations.json, plugins/PostHog/v1/dataStreams/projects.json, plugins/PostHog/v1/dataStreams/members.json, plugins/PostHog/v1/dataStreams/scripts/members.js, plugins/PostHog/v1/dataStreams/featureFlags.json, plugins/PostHog/v1/dataStreams/scripts/featureFlags.js, plugins/PostHog/v1/indexDefinitions/default.json
Adds organization, project, member, and feature-flag streams with transformations, dependencies, scopes, and object mappings.
Analytics data streams and transformations
plugins/PostHog/v1/dataStreams/*.json, plugins/PostHog/v1/dataStreams/scripts/*.js
Adds event, web analytics, active-user, active-hours, feature-flag evaluation, and HogQL query streams; scripts convert columnar responses into typed row objects.
Scopes and default dashboards
plugins/PostHog/v1/defaultContent/*, plugins/PostHog/v1/defaultContent/Project/*, plugins/PostHog/v1/defaultContent/scopes.json
Adds source-type scopes and default dashboards for accounts, organizations, projects, feature flags, and web analytics.

Sequence Diagram(s)

sequenceDiagram
  participant Dashboard
  participant DataStream
  participant PostHogAPI
  participant TransformScript
  Dashboard->>DataStream: Request scoped analytics data
  DataStream->>PostHogAPI: POST project query with HogQL and timeframe
  PostHogAPI->>TransformScript: Return columnar results
  TransformScript->>Dashboard: Return typed row objects
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic to identify the main change in the changeset. Use a specific title like "Add PostHog plugin with dashboards and data streams".
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description matches the plugin template well and covers overview, testing, limitations, screenshots, and checklist items.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@adamkinniburgh adamkinniburgh changed the title feat: PostHog plugin PostHog plugin Jul 16, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/PostHog/v1/dataStreams/eventVolume.json`:
- Line 16: Escape interpolated HogQL literals in the query predicates, using
variables_override or the existing SQL string-escaping mechanism, so event and
object.name values cannot break or alter filtering. Apply the same fix at
plugins/PostHog/v1/dataStreams/eventVolume.json:16,
plugins/PostHog/v1/dataStreams/flagEvaluations.json:16, and
plugins/PostHog/v1/dataStreams/flagVariants.json:16.

In `@plugins/PostHog/v1/dataStreams/members.json`:
- Around line 8-13: Configure nextUrl pagination in the stream definitions:
update plugins/PostHog/v1/dataStreams/members.json at lines 8-13 and
plugins/PostHog/v1/dataStreams/featureFlags.json at lines 8-13 to consume each
response’s documented next URL, ensuring all organization members and project
feature flags pages are imported.

In `@plugins/PostHog/v1/dataStreams/scripts/hogqlQuery.js`:
- Around line 5-8: Update the row transformation around cols and
Object.fromEntries to disambiguate duplicate column names before constructing
each object, preserving every returned cell while retaining unchanged names for
unique columns. Ensure the same disambiguated column keys are applied
consistently across all rows.

In `@plugins/PostHog/v1/defaultContent/featureFlag.dash.json`:
- Line 83: Update the tile titles in the feature flag dashboard configuration:
change “Evaluations over time” to “Evaluations Over Time” and the title at the
corresponding second tile entry to “Variant Split,” preserving all other
dashboard configuration.
- Around line 29-31: Update the tile object identified by "id":
"datastream-properties" to use the generated data-stream GUID reference pattern
used by the other dashboard tiles instead of the fixed non-GUID ID, while
preserving its existing name and pluginConfigId values.

In `@plugins/PostHog/v1/defaultContent/Project/webAnalytics.dash.json`:
- Line 24: Update the tile titles in the dashboard definition, including the
entries corresponding to “Unique visitors” and the other referenced title
fields, to use title case consistently. Preserve the existing titles’ meaning
while capitalizing each significant word according to the project’s naming
convention.

In `@plugins/PostHog/v1/ui.json`:
- Around line 23-29: Update the personalApiKey help text in the PostHog UI
configuration to explicitly include the Users read scope alongside Organization,
Project, Feature flag, and Query. Preserve the existing authentication and
validation settings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: b4748998-0b98-46a6-be7c-3eee2f45565e

📥 Commits

Reviewing files that changed from the base of the PR and between 9dafcf7 and 0d92a69.

⛔ Files ignored due to path filters (1)
  • plugins/PostHog/v1/icon.svg is excluded by !**/*.svg
📒 Files selected for processing (44)
  • plugins/PostHog/v1/configValidation.json
  • plugins/PostHog/v1/custom_types.json
  • plugins/PostHog/v1/dataStreams/activeHours.json
  • plugins/PostHog/v1/dataStreams/activeUsers.json
  • plugins/PostHog/v1/dataStreams/currentUser.json
  • plugins/PostHog/v1/dataStreams/eventBreakdown.json
  • plugins/PostHog/v1/dataStreams/eventVolume.json
  • plugins/PostHog/v1/dataStreams/featureFlags.json
  • plugins/PostHog/v1/dataStreams/flagEvaluations.json
  • plugins/PostHog/v1/dataStreams/flagVariants.json
  • plugins/PostHog/v1/dataStreams/frustratingPages.json
  • plugins/PostHog/v1/dataStreams/hogqlQuery.json
  • plugins/PostHog/v1/dataStreams/members.json
  • plugins/PostHog/v1/dataStreams/organizations.json
  • plugins/PostHog/v1/dataStreams/projects.json
  • plugins/PostHog/v1/dataStreams/scripts/activeHours.js
  • plugins/PostHog/v1/dataStreams/scripts/activeUsers.js
  • plugins/PostHog/v1/dataStreams/scripts/currentUser.js
  • plugins/PostHog/v1/dataStreams/scripts/eventBreakdown.js
  • plugins/PostHog/v1/dataStreams/scripts/eventVolume.js
  • plugins/PostHog/v1/dataStreams/scripts/featureFlags.js
  • plugins/PostHog/v1/dataStreams/scripts/flagEvaluations.js
  • plugins/PostHog/v1/dataStreams/scripts/flagVariants.js
  • plugins/PostHog/v1/dataStreams/scripts/frustratingPages.js
  • plugins/PostHog/v1/dataStreams/scripts/hogqlQuery.js
  • plugins/PostHog/v1/dataStreams/scripts/members.js
  • plugins/PostHog/v1/dataStreams/scripts/webBreakdown.js
  • plugins/PostHog/v1/dataStreams/scripts/webPaths.js
  • plugins/PostHog/v1/dataStreams/scripts/webVisitors.js
  • plugins/PostHog/v1/dataStreams/webBreakdown.json
  • plugins/PostHog/v1/dataStreams/webPaths.json
  • plugins/PostHog/v1/dataStreams/webVisitors.json
  • plugins/PostHog/v1/defaultContent/Project/manifest.json
  • plugins/PostHog/v1/defaultContent/Project/overview.dash.json
  • plugins/PostHog/v1/defaultContent/Project/webAnalytics.dash.json
  • plugins/PostHog/v1/defaultContent/account.dash.json
  • plugins/PostHog/v1/defaultContent/featureFlag.dash.json
  • plugins/PostHog/v1/defaultContent/manifest.json
  • plugins/PostHog/v1/defaultContent/organization.dash.json
  • plugins/PostHog/v1/defaultContent/scopes.json
  • plugins/PostHog/v1/docs/README.md
  • plugins/PostHog/v1/indexDefinitions/default.json
  • plugins/PostHog/v1/metadata.json
  • plugins/PostHog/v1/ui.json

Comment thread plugins/PostHog/v1/dataStreams/eventVolume.json Outdated
Comment thread plugins/PostHog/v1/dataStreams/members.json
Comment thread plugins/PostHog/v1/dataStreams/scripts/hogqlQuery.js
Comment thread plugins/PostHog/v1/defaultContent/featureFlag.dash.json
Comment thread plugins/PostHog/v1/defaultContent/featureFlag.dash.json Outdated
Comment thread plugins/PostHog/v1/defaultContent/Project/webAnalytics.dash.json Outdated
Comment thread plugins/PostHog/v1/ui.json
- Escape single quotes in interpolated HogQL string literals (event name,
  feature flag key) to prevent broken/altered queries
- Paginate members and feature-flag imports via nextUrl so all pages load
- Disambiguate duplicate column names in the HogQL query transform
- Use title case for web-analytics and feature-flag tile titles
- Document the required User read scope in the API-key help text

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🧩 Plugin PR Summary

📦 Modified Plugins

  • plugins/PostHog/v1

📋 Results

Step Status
Validation ✅ Passed
Deployment 🚀 Deployed

🔍 Validation Details

posthog
{
  "valid": true,
  "pluginName": "posthog",
  "pluginType": "hybrid",
  "summary": {
    "Data Streams": 16,
    "Import Definitions": 1,
    "UI Configuration": true,
    "Has Icon": true,
    "Has Default Content": true,
    "Config Validation": true,
    "Custom Types": true
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant