Changesets · Branches · Tags · Compare
| Changeset | 2a6fa8b977edbe79f87b6afcbb1fdca4b136fc11e4dc3433e6caf92cabce9ba8 |
|---|---|
| Author | BekahHW <rhawrot@gmail.com> · 2025-09-25 12:58 -04:00 |
| Committer | BekahHW <rhawrot@gmail.com> · 2025-09-25 12:58 -04:00 |
| Parents | 906a4cd5dac6 |
1 file changed
modified docs/guides/posthog-github-continuous-ai.mdx +109 −113
| @@ -1,23 +1,32 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | title: "Building a Continuous AI Workflow with PostHog and GitHub" |
| 3 | -description: "Build an automated system that continuously monitors PostHog session recordings, analyzes UX issues using Continue CLI, and creates GitHub issues automatically." | |
| 4 | -sidebarTitle: "PostHog Session Analysis with Continue CLI" | |
| 3 | +description: "Build an automated system that continuously monitors PostHog analytics, analyzes user behavior with AI, and creates GitHub issues automatically using PostHog MCP." | |
| 4 | +sidebarTitle: "PostHog Analytics with Continue CLI" | |
| 5 | 5 | --- |
| 6 | 6 | |
| 7 | 7 | <Card title="What You'll Build" icon="robot"> |
| 8 | - A fully automated workflow that uses Continue CLI to fetch PostHog session | |
| 9 | - data, analyze user experience issues with AI, and automatically create GitHub | |
| 10 | - issues with specific technical recommendations | |
| 8 | + A fully automated workflow that uses Continue CLI with the PostHog MCP to fetch analytics data, analyze user experience issues with AI, and automatically create GitHub | |
| 9 | + issues with the GitHub CLI. | |
| 11 | 10 | </Card> |
| 12 | 11 | |
| 12 | +## What You'll Learn | |
| 13 | + | |
| 14 | +This cookbook teaches you to: | |
| 15 | + | |
| 16 | +- Use [PostHog MCP](https://posthog.com/docs/model-context-protocol) to query [analytics](https://posthog.com/docs/web-analytics), [errors](https://posthog.com/docs/error-tracking), and [feature flags](https://posthog.com/docs/feature-flags) | |
| 17 | +- Analyze user behavior patterns with AI | |
| 18 | +- Automatically create GitHub issues using GitHub CLI | |
| 19 | +- Set up continuous monitoring with GitHub Actions | |
| 20 | + | |
| 13 | 21 | ## Prerequisites |
| 14 | 22 | |
| 15 | 23 | Before starting, ensure you have: |
| 16 | 24 | |
| 17 | 25 | - GitHub repository where you want to create issues |
| 18 | -- PostHog account with **[session recordings enabled and collecting data](https://posthog.com/docs/session-replay/installation)** | |
| 26 | +- [PostHog account](https://posthog.com) with [session recordings enabled](https://posthog.com/docs/session-replay/installation) and data collecting | |
| 19 | 27 | - Node.js 18+ installed locally |
| 20 | -- Continue CLI account with **active credits** (required for API usage) | |
| 28 | +- [Continue CLI](https://docs.continue.dev/guides/cli) with **active credits** (required for API usage) | |
| 29 | +- [GitHub CLI](https://cli.github.com/) installed (`gh` command) | |
| 21 | 30 | |
| 22 | 31 | <Steps> |
| 23 | 32 | <Step title="Install Continue CLI"> |
| @@ -66,39 +75,38 @@ | ||
| 66 | 75 | 7. Note your PostHog host URL (e.g., `https://us.posthog.com` or your custom domain) |
| 67 | 76 | 8. You'll also need your POSTHOG_AUTH_HEADER value, which is simply `Bearer YOUR_API_KEY` |
| 68 | 77 | |
| 69 | - <Tip> | |
| 70 | - **Find Your Project Details**: Your Project ID is in your PostHog URL: | |
| 71 | - `https://app.posthog.com/project/YOUR_PROJECT_ID` | |
| 72 | - </Tip> | |
| 78 | + <Info> | |
| 79 | + **Continue Secrets**: The `POSTHOG_AUTH_HEADER` secret should be stored in | |
| 80 | + Continue's secure secrets storage. This keeps your API key safe and the MCP | |
| 81 | + automatically connects to your default PostHog project. | |
| 82 | +</Info> | |
| 73 | 83 | |
| 74 | 84 | </Tab> |
| 75 | - <Tab title="GitHub Personal Access Token"> | |
| 76 | - You'll need a **Personal Access Token** to create issues in your GitHub repository: | |
| 77 | - | |
| 78 | - 1. Go to [GitHub Personal Access Tokens](https://github.com/settings/personal-access-tokens/new) | |
| 79 | - 2. Click **"Generate new token (classic)"** | |
| 80 | - 3. Name it "Continue CLI PostHog Analysis" | |
| 81 | - 4. Select these scopes: | |
| 82 | - - `repo` (or just `public_repo` if your repository is public) | |
| 83 | - - `issues:write` - **Required** for creating issues | |
| 84 | - 5. Copy the token immediately | |
| 85 | + <Tab title="Set Up GitHub CLI Authentication"> | |
| 86 | + GitHub CLI handles authentication automatically - no manual PAT needed: | |
| 85 | 87 | |
| 86 | - </Tab> | |
| 87 | -</Tabs> | |
| 88 | + 1. Install GitHub CLI if not already installed | |
| 89 | + 2. Run `gh auth login` and follow the prompts | |
| 90 | + 3. Choose authentication method (browser or token) | |
| 91 | + 4. Grant necessary permissions when prompted (`issues:write` is **required** for creating issues) | |
| 88 | 92 | |
| 89 | -### Add Secrets to Continue CLI | |
| 93 | + </Tab> | |
| 94 | +<Tab title= "Configure API Access in Continue CLI"> | |
| 95 | + | |
| 96 | +<Tip> | |
| 97 | +See https://docs.continue.dev/hub/secrets/secret-types#secret-types for adding secrets | |
| 98 | +</Tip> | |
| 90 | 99 | |
| 91 | -To add environment variables to your Continue Hub account: | |
| 100 | +You only need to configure the PostHog MCP credential - it automatically handles project selection. To add environment variables to your Continue Hub account: | |
| 92 | 101 | |
| 93 | 102 | 1. Go to the [Continue Hub](https://hub.continue.dev) |
| 94 | 103 | 2. Sign in to your account |
| 95 | 104 | 3. Navigate to your user settings |
| 96 | 105 | 4. Look for the "Secrets" section |
| 97 | -5. Add your variables there (like POSTHOG_API_KEY, POSTHOG_PROJECT_ID, | |
| 98 | - POSTHOG_HOST,GITHUB_PAT, etc.) | |
| 106 | +5. Add your Personal API Key from PostHog (phx_...) as POSTHOG_AUTH_HEADER secret with format: Bearer YOUR_API_KEY | |
| 99 | 107 | |
| 100 | -These environment variables will then be securely stored and available for use in | |
| 101 | -your Continue workflows. | |
| 108 | +</Tab> | |
| 109 | +</Tabs> | |
| 102 | 110 | |
| 103 | 111 | ## PostHog GitHub Continuous AI Workflow Options |
| 104 | 112 | |
| @@ -107,7 +115,17 @@ | ||
| 107 | 115 | optimized prompts, rules, and the PostHog MCP for more consistent results. |
| 108 | 116 | </Card> |
| 109 | 117 | |
| 110 | -After completing **Step 1** below, you have two paths to get started: | |
| 118 | +<Info> | |
| 119 | + **How PostHog MCP Works**: | |
| 120 | + - Your API key is tied to your PostHog account and | |
| 121 | + organization | |
| 122 | + - It automatically uses your default project (no project ID | |
| 123 | + needed) | |
| 124 | + - If you have multiple projects, use `mcp__posthog__switch-project` to | |
| 125 | + change | |
| 126 | + - The MCP connects via `https://mcp.posthog.com/sse` using your account context. | |
| 127 | + | |
| 128 | +</Info> | |
| 111 | 129 | |
| 112 | 130 | <Tabs> |
| 113 | 131 | <Tab title="⚡ Quick Start (Recommended)"> |
| @@ -115,20 +133,16 @@ | ||
| 115 | 133 | |
| 116 | 134 | <Steps> |
| 117 | 135 | <Step title="Add the Pre-Built Agent"> |
| 118 | - Visit the [PostHog GitHub Continuous AI Agent](https://hub.continue.dev/continuedev/awesome-models-posthog-gh) on Continue Hub and click **"Install Agent"** | |
| 136 | + Visit the [PostHog GitHub Continuous AI Agent](https://hub.continue.dev/continuedev/awesome-models-posthog-gh) on Continue Hub and click **"Install Agent"** or run: | |
| 137 | + | |
| 138 | + ```bash | |
| 139 | + cn --config continuedev/awesome-models-posthog-gh | |
| 140 | + ``` | |
| 119 | 141 | |
| 120 | 142 | This agent includes: |
| 121 | - - **Optimized prompts** for PostHog analysis and GitHub issue creation | |
| 122 | - - **Built-in rules** for consistent formatting and error handling | |
| 123 | - - **PostHog MCP** for more reliable API interactions | |
| 124 | - </Step> | |
| 125 | - | |
| 126 | - <Step title="Verify Your Secrets"> | |
| 127 | - The agent uses these Hub resources automatically: | |
| 128 | - - **Environment Variables**: [bekahhw/env-vars](https://hub.continue.dev/bekahhw/env-vars) | |
| 129 | - - **Analysis Rules**: [bekah-hawrot-weigel/posthog-github-continuous-ai-rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules) | |
| 130 | - - **Analysis Prompt**: [continuedev/posthog-analysis](https://hub.continue.dev/continuedev/posthog-analysis) | |
| 131 | - - **Issue Creation Prompt**: [continuedev/github-issues](https://hub.continue.dev/continuedev/github-issues) | |
| 143 | + - **Optimized prompts** for [PostHog analysis](https://hub.continue.dev/continuedev/posthog-analysis) and [GitHub issue creation](https://hub.continue.dev/continuedev/posthog-github-issues) | |
| 144 | + - **[Built-in rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules)** for consistent formatting and error handling | |
| 145 | + - **[PostHog MCP](https://hub.continue.dev/posthog/posthog-mcp)** for more reliable API interactions | |
| 132 | 146 | </Step> |
| 133 | 147 | |
| 134 | 148 | <Step title="Run the Analysis"> |
| @@ -148,72 +162,41 @@ | ||
| 148 | 162 | </Tab> |
| 149 | 163 | |
| 150 | 164 | <Tab title="🛠️ Manual Setup"> |
| 151 | - **Perfect for:** Learning the process and customizing prompts. | |
| 152 | - | |
| 153 | - Now you'll use Continue CLI to fetch PostHog session data and analyze it for UX issues. Continue CLI handles all the API calls and analysis automatically. | |
| 154 | - | |
| 155 | -### Run the PostHog Analysis | |
| 156 | - | |
| 157 | -Use this prompt with Continue CLI to fetch and analyze your PostHog sessions: | |
| 158 | - | |
| 159 | -```bash | |
| 160 | -cn -p "I need you to help me analyze PostHog session recordings to identify UX issues. Please: | |
| 161 | - | |
| 162 | -1. First, fetch session recordings from PostHog using these details: | |
| 163 | - - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from my secrets | |
| 164 | - - API endpoint: {POSTHOG_HOST}/api/projects/{POSTHOG_PROJECT_ID}/session_recordings/?limit=20 | |
| 165 | - - Include Authorization header: 'Bearer {POSTHOG_API_KEY}' | |
| 166 | - | |
| 167 | -2. Filter the sessions to find problematic ones with either: | |
| 168 | - - console_error_count > 0 (JavaScript errors) | |
| 169 | - - recording_duration > 300 (sessions longer than 5 minutes) | |
| 170 | - | |
| 171 | -3. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems. | |
| 172 | - | |
| 173 | -4. Format each issue like this: | |
| 174 | -### 1. **Issue Title Here** | |
| 175 | -**Problem**: One sentence describing the user problem | |
| 176 | -**Technical Causes**: Brief technical explanation | |
| 177 | -**Affected Pages**: List the URLs | |
| 178 | -**Recommended Fix**: | |
| 179 | -- Specific action item 1 | |
| 180 | -- Specific action item 2 | |
| 181 | -**Priority**: **HIGH** or **MEDIUM** or **LOW** | |
| 182 | -**Impact**: Quantify the impact (e.g., 'Affects 80% of sessions') | |
| 183 | - | |
| 184 | -Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data." | |
| 185 | -``` | |
| 186 | - | |
| 187 | -### Create GitHub Issues from PostHog Analysis | |
| 188 | - | |
| 189 | -Now use Continue CLI to create GitHub issues from your analysis results: | |
| 190 | - | |
| 191 | -```bash | |
| 192 | -cn -p "I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API. | |
| 193 | - | |
| 194 | -Use these details from my secrets: | |
| 195 | -- GITHUB_PAT: My GitHub Personal Access Token | |
| 196 | -- Repository: Extract from git remote or ask me to specify | |
| 197 | - | |
| 198 | -For each issue in my analysis: | |
| 199 | -1. Parse the issue title, body content, and priority level | |
| 200 | -2. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues | |
| 201 | -3. Use these headers: | |
| 202 | - - Authorization: token {GITHUB_PAT} | |
| 203 | - - Accept: application/vnd.github.v3+json | |
| 204 | - - Content-Type: application/json | |
| 205 | -4. Set labels based on priority: | |
| 206 | - - HIGH: [\"bug\", \"high-priority\", \"user-experience\", \"automated\"] | |
| 207 | - - MEDIUM: [\"enhancement\", \"medium-priority\", \"user-experience\", \"automated\"] | |
| 208 | - - LOW: [\"low-priority\", \"user-experience\", \"automated\"] | |
| 209 | -5. Format the issue title as: \"🔍 UX Issue: {original title}\" | |
| 210 | - | |
| 211 | -Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs. | |
| 212 | -" | |
| 213 | -``` | |
| 165 | + <Steps> | |
| 166 | + <Step title="Add PostHog MCP to Continue CLI"> | |
| 167 | + First, install the [PostHog MCP](https://hub.continue.dev/posthog/posthog-mcp) or run: | |
| 168 | + ```bash | |
| 169 | + npx -y mcp-remote@latest https://mcp.posthog.com/sse --header Authorization:${{ secrets.continuedev/awesome-models-posthog-gh/posthog/posthog-mcp/POSTHOG_AUTH_HEADER }} | |
| 170 | + ``` | |
| 171 | + </Step> | |
| 172 | + <Step title="Add PostHog + GitHub Analysis Rules"> | |
| 173 | + In the Continue Hub, add the [PostHog GitHub Continuous AI Rules](https://hub.continue.dev/bekah-hawrot-weigel/posthog-github-continuous-ai-rules) to your account for better formatting and error handling. | |
| 174 | + </Step> | |
| 175 | + <Step title="Create Your Custom Prompts"> | |
| 176 | + Use this prompt with Continue CLI to analyze PostHog data and create GitHub issues: | |
| 177 | + | |
| 178 | + ```bash | |
| 179 | + | |
| 180 | + # In cn TUI mode: | |
| 181 | + "Create GitHub issues from the PostHog analysis using gh CLI: | |
| 182 | + - For each issue, run: gh issue create --title '🔍 UX Issue: [title]' --body '[details]' | |
| 183 | + - Add labels: --label 'bug,user-experience,automated' | |
| 184 | + - Set priority labels (high/medium/low) | |
| 185 | + - Include session data and technical details in the body | |
| 186 | + Execute the commands and confirm each issue was created with URL." | |
| 187 | + ``` | |
| 188 | + </Step> | |
| 189 | +</Steps> | |
| 214 | 190 | |
| 215 | 191 | </Tab> |
| 216 | 192 | </Tabs> |
| 193 | +<Info> | |
| 194 | + | |
| 195 | + **Why GitHub CLI over GitHub MCP**: While GitHub MCP is available, it can be | |
| 196 | + token-expensive to run. The `gh` CLI is more efficient, requires no API tokens | |
| 197 | + (authenticated via `gh auth login`), and provides a cleaner command-line | |
| 198 | + experience. GitHub MCP remains an option if you prefer full MCP integration. | |
| 199 | +</Info> | |
| 217 | 200 | |
| 218 | 201 | <Accordion title="Agent Requirements"> |
| 219 | 202 | To use the pre-built agent, you need either: |
| @@ -492,16 +475,17 @@ | ||
| 492 | 475 | |
| 493 | 476 | <CardGroup cols={2}> |
| 494 | 477 | <Card title="Performance Analysis" icon="chart-line"> |
| 495 | - "Analyze PostHog performance metrics alongside session recordings to | |
| 496 | - identify slow page loads affecting user experience" | |
| 478 | + "Analyze [PostHog performance | |
| 479 | + metrics](https://posthog.com/docs/web-analytics) alongside session | |
| 480 | + recordings to identify slow page loads affecting user experience" | |
| 497 | 481 | </Card> |
| 498 | 482 | <Card title="Error Correlation" icon="bug"> |
| 499 | 483 | "Cross-reference JavaScript console errors with user actions to identify the |
| 500 | 484 | root cause of UX issues" |
| 501 | 485 | </Card> |
| 502 | 486 | <Card title="Feature Flag Analysis" icon="flag"> |
| 503 | - "Analyze how PostHog feature flags impact user behavior in session | |
| 504 | - recordings" | |
| 487 | + "Analyze how [PostHog feature flags](https://posthog.com/docs/feature-flags) | |
| 488 | + impact user behavior in session recordings" | |
| 505 | 489 | </Card> |
| 506 | 490 | <Card title="Custom Slack Alerts" icon="slack"> |
| 507 | 491 | "Create Slack alerts when critical UX issues are detected in PostHog |
| @@ -511,7 +495,19 @@ | ||
| 511 | 495 | |
| 512 | 496 | ## Next Steps |
| 513 | 497 | |
| 514 | -1. **Monitor your first issues** - Review the GitHub issues created and implement fixes | |
| 515 | -2. **Measure impact** - Track how resolved issues improve PostHog metrics | |
| 516 | -3. **Refine prompts** - Adjust the Continue CLI prompts based on issue quality | |
| 517 | -4. **Scale the system** - Add more data sources or create specialized analysis workflows | |
| 498 | +- Consider [GitHub MCP](https://hub.continue.dev/github/github-mcp) as an alternative (note: can be token-expensive) | |
| 499 | +- Configure [Slack MCP](https://hub.continue.dev/slack/slack-mcp) for alerts | |
| 500 | +- Set up [PostHog performance monitoring](https://posthog.com/docs/web-analytics) | |
| 501 | +- Join the [Continue Discord](https://discord.gg/continue) for support | |
| 502 | + | |
| 503 | +## Resources | |
| 504 | + | |
| 505 | +- [PostHog API Documentation](https://posthog.com/docs/api) | |
| 506 | +- [PostHog MCP Documentation](https://posthog.com/docs/model-context-protocol) | |
| 507 | +- [PostHog Session Replay](https://posthog.com/docs/session-replay) | |
| 508 | +- [PostHog Feature Flags](https://posthog.com/docs/feature-flags) | |
| 509 | +- [PostHog Error Tracking](https://posthog.com/docs/error-tracking) | |
| 510 | +- [GitHub CLI Documentation](https://cli.github.com/) | |
| 511 | +- [GitHub MCP on Continue Hub](https://hub.continue.dev/github/github-mcp) (alternative option) | |
| 512 | +- [Continue CLI Guide](https://docs.continue.dev/guides/cli) | |
| 513 | +- [Continuous AI Best Practices](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/) |