Elffuss BraidHub

kikocis/continue public

fix: Update posthog + gh guide with latest flow (#7899)

Update with latest flow
Changesetee5f77772c0ce8ddd16b54fe9df6bf2b6588e96c548b08d56693bb8c820e2093
AuthorBekahHW <34313413+BekahHW@users.noreply.github.com> · 2025-09-23 12:48 -04:00
CommitterGitHub <noreply@github.com> · 2025-09-23 09:48 -07:00
Parents2cf8097f3ed4

Browse the files at this changeset

1 file changed

modified docs/guides/posthog-github-continuous-ai.mdx +217 −196
@@ -41,77 +41,118 @@
4141 </Steps>
4242
4343 <Tip>
44- Continue CLI handles all the complex API interactions - you just need to
45- provide the right prompts!
44+ Continue CLI handles the complex API interactions - you just need to provide
45+ the right prompts!
4646 </Tip>
4747
4848 ## Step 1: Set Up Your Credentials
4949
50-First, you'll need to gather your API credentials and add them as secrets in Continue CLI.
50+First, you'll need to gather your PostHog and GitHub API credentials and add them as secrets in Continue CLI.
51+
52+<Tabs>
53+ <Tab title="PostHog API Credentials">
54+ You'll need a **Personal API Key** (not a Project API key) to access session recordings:
55+
56+ 1. Go to [Personal API Keys](https://app.posthog.com/settings/user-api-keys) in PostHog
57+ 2. Click **+ Create a personal API Key**
58+ 3. Name it "Continue CLI Session Analysis"
59+ 4. Select these scopes:
60+ - `session_recording:read` - **Required** for accessing session data
61+ - `insight:read`
62+ - `query:read`
63+ - `session_recording_playlist:read`
64+ 5. Copy the key immediately (you won't see it again!)
65+ 6. Note your **Project ID** from your PostHog project settings
66+ 7. Note your PostHog host URL (e.g., `https://us.posthog.com` or your custom domain)
67+ 8. You'll also need your POSTHOG_AUTH_HEADER value, which is simply `Bearer YOUR_API_KEY`
68+
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>
73+
74+ </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+
86+ </Tab>
87+</Tabs>
5188
52-### Get Your PostHog API Credentials
89+### Add Secrets to Continue CLI
5390
54-You need a **Personal API Key** (not a Project API key) to access session recordings:
91+To add environment variables to your Continue Hub account:
5592
56-1. Go to [Personal API Keys](https://app.posthog.com/settings/user-api-keys) in PostHog
57-2. Click **+ Create a personal API Key**
58-3. Name it "Continue CLI Session Analysis"
59-4. Select these scopes:
60- - `session_recording:read` - **Required** for accessing session data
61- - `insight:read` - Optional, for additional analytics
62-5. Copy the key immediately (you won't see it again!)
93+1. Go to the [Continue Hub](https://hub.continue.dev)
94+2. Sign in to your account
95+3. Navigate to your user settings
96+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.)
6399
64-<Tip>
65- **Find Your Project Details**: Your Project ID is in your PostHog URL:
66- `https://app.posthog.com/project/YOUR_PROJECT_ID`
67-</Tip>
100+These environment variables will then be securely stored and available for use in
101+your Continue workflows.
68102
69-### Get Your GitHub Personal Access Token
103+## PostHog GitHub Continuous AI Workflow Options
70104
71-1. Go to [GitHub Personal Access Tokens](https://github.com/settings/personal-access-tokens/new)
72-2. Click **"Generate new token (classic)"**
73-3. Name it "Continue CLI PostHog Analysis"
74-4. Select these scopes:
75- - `repo` (or just `public_repo` if your repository is public)
76- - `issues:write` - **Required** for creating issues
77-5. Copy the token immediately
105+<Card title="🚀 Fastest Path to Success" icon="zap">
106+ Skip the manual setup and use our pre-built PostHog GitHub agent that includes
107+ optimized prompts, rules, and the PostHog MCP for more consistent results.
108+</Card>
78109
79-### Add Secrets to Continue CLI
110+After completing **Step 1** below, you have two paths to get started:
80111
81-Use Continue CLI's built-in environment setup helper:
112+<Tabs>
113+ <Tab title="⚡ Quick Start (Recommended)">
114+ **Perfect for:** Immediate results with optimized prompts and built-in debugging
82115
83-```bash
84-cn -p "Help me set up my environment for PostHog session analysis. Please:
85-1. Check if I have the required secrets configured in Continue CLI:
86- - POSTHOG_API_KEY
87- - POSTHOG_PROJECT_ID
88- - POSTHOG_HOST
89- - GITHUB_PAT
90-2. If any are missing, guide me through:
91- - How to get PostHog Personal API Key from PostHog settings
92- - How to find my PostHog Project ID from the URL
93- - How to create a GitHub Personal Access Token with issues:write permission
94- - How to add these as secrets in Continue CLI
95-3. Help me identify my GitHub repository owner and name by:
96- - Checking git remote origin URL
97- - Or asking me to provide them
98-4. Test the API connections by making a simple API call to both PostHog and GitHub to verify the credentials work.
99-Please walk me through this setup process step by step."
100-```
116+ <Steps>
117+ <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"**
101119
102-<Info>
103- Continue CLI will guide you through adding secrets and testing your API
104- connections. Follow the prompts to add: - `POSTHOG_API_KEY`: Your PostHog
105- Personal API Key - `POSTHOG_PROJECT_ID`: Your PostHog Project ID -
106- `POSTHOG_HOST`: `https://us.posthog.com` (or your custom PostHog host) -
107- `GITHUB_PAT`: Your GitHub Personal Access Token
108-</Info>
120+ 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)
132+ </Step>
133+
134+ <Step title="Run the Analysis">
135+ Navigate to your project directory and run:
136+ ```bash
137+ cn "Give me my PostHog Session data and create GitHub issues based on the problems."
138+ ```
139+
140+ That's it! The agent handles everything automatically.
141+ </Step>
142+ </Steps>
143+
144+ <Info>
145+ **Why Use the Agent?** Results are more consistent and debugging is easier thanks to the PostHog MCP integration and pre-tested prompts.
146+ </Info>
147+
148+ </Tab>
109149
110-## Step 2: Analyze PostHog Sessions with Continue CLI
150+ <Tab title="🛠️ Manual Setup">
151+ **Perfect for:** Learning the process and customizing prompts.
111152
112-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.
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.
113154
114-### Run the Analysis
155+### Run the PostHog Analysis
115156
116157 Use this prompt with Continue CLI to fetch and analyze your PostHog sessions:
117158
@@ -143,19 +184,7 @@
143184 Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data."
144185 ```
145186
146-<Info>
147- **What Continue CLI Does:** - Makes authenticated API calls to PostHog using
148- your stored secrets - Fetches and filters session recordings automatically -
149- Analyzes patterns in the data using AI - Generates structured issue
150- descriptions ready for GitHub
151-</Info>
152-
153-<Tip>
154- Save the analysis output to a file by adding `> analysis-results.txt` to the
155- command if you want to review it later.
156-</Tip>
157-
158-## Step 3: Create GitHub Issues Automatically
187+### Create GitHub Issues from PostHog Analysis
159188
160189 Now use Continue CLI to create GitHub issues from your analysis results:
161190
@@ -183,6 +212,21 @@
183212 "
184213 ```
185214
215+ </Tab>
216+</Tabs>
217+
218+<Accordion title="Agent Requirements">
219+ To use the pre-built agent, you need either:
220+ - **Continue CLI Pro Plan** with
221+ the models add-on, OR
222+ - **Your own API keys** added to Continue Hub secrets
223+ (same as Step 1 below) The agent will automatically detect and use your
224+ configuration.
225+
226+</Accordion>
227+
228+---
229+
186230 <Warning>
187231 **Repository Labels Required**: Make sure your GitHub repository has these labels:
188232 - `bug`, `enhancement`
@@ -200,7 +244,7 @@
200244 issues to avoid spam - Provides confirmation with issue URLs
201245 </Info>
202246
203-## Step 4: Set Up Automated GitHub Actions Workflow
247+## Setting Up Automated GitHub Actions Workflow
204248
205249 Create a GitHub Actions workflow that runs your Continue CLI analysis automatically on a schedule.
206250
@@ -211,26 +255,23 @@
211255 1. Go to **Repository Settings → Secrets and variables → Actions**
212256 2. Click **"New repository secret"** and add:
213257 - `CONTINUE_API_KEY`: Your Continue API key from hub.continue.dev
214- - `POSTHOG_API_KEY`: Your PostHog Personal API Key
215- - `POSTHOG_PROJECT_ID`: Your PostHog Project ID
216- - `POSTHOG_HOST`: `https://us.posthog.com` (or your custom PostHog host)
217- - `GITHUB_PAT`: Your GitHub Personal Access Token
218258
219259 ### Create GitHub Actions Workflow
220260
221261 Create `.github/workflows/posthog-analysis.yml` in your repository:
222262
263+<Tabs>
264+ <Tab title="⚡ Using Pre-Built Agent (Recommended)">
223265 ```yaml
224-name: PostHog Session Analysis with Continue CLI
266+name: PostHog Session Analysis with Continue CLI Agent
225267
226268 on:
227- schedule:
228- - cron: "0 6 * * *" # Run at 6 AM UTC daily
229- workflow_dispatch: # Allow manual triggering
269+schedule: - cron: "0 6 \* \* \*" # Run at 6 AM UTC daily
270+workflow_dispatch: # Allow manual triggering
230271
231272 jobs:
232- analyze:
233- runs-on: ubuntu-latest
273+analyze:
274+runs-on: ubuntu-latest
234275
235276 permissions:
236277 contents: read
@@ -250,14 +291,72 @@
250291 echo "✅ Continue CLI installed"
251292 cn --version
252293
253- - name: Set up environment variables
294+ - name: Authenticate with Continue CLI
295+ run: |
296+ # Set Continue API key
297+ export CONTINUE_API_KEY="${{ secrets.CONTINUE_API_KEY }}"
298+ # Login to Continue CLI
299+ if ! cn auth login --api-key "$CONTINUE_API_KEY"; then
300+ echo "❌ Failed to authenticate with Continue CLI"
301+ exit 1
302+ fi
303+ echo "✅ Continue CLI authenticated"
304+
305+ - name: Load PostHog GitHub Agent
306+ run: |
307+ echo "🤖 Loading PostHog GitHub Continuous AI Agent..."
308+ cn --config continuedev/awesome-models-posthog-gh
309+ echo "✅ Agent loaded successfully"
310+
311+ - name: Run PostHog Analysis and Create GitHub Issues
312+ run: |
313+ echo "🎬 Starting automated PostHog session analysis..."
314+
315+ # Run the agent with the simple prompt
316+ cn -p "Tell me about my PostHog session recordings and create GitHub issues based on the problems."
317+
318+ echo "✅ Analysis and issue creation completed"
319+
320+ - name: Summary
321+ run: |
322+ echo "✅ PostHog analysis workflow completed!"
323+ echo "📊 Check the artifacts for detailed analysis results"
324+ echo "🐛 Check your repository issues for newly created UX issues"
325+ echo "🤖 Agent automatically handled both analysis and issue creation"
326+ ```
327+
328+ </Tab>
329+
330+ <Tab title="🛠️ Manual Setup Version">
331+
332+```yaml
333+name: PostHog Session Analysis with Continue CLI Manual
334+
335+on:
336+schedule: - cron: "0 6 \* \* \*" # Run at 6 AM UTC daily
337+workflow_dispatch: # Allow manual triggering
338+
339+jobs:
340+analyze:
341+runs-on: ubuntu-latest
342+
343+ permissions:
344+ contents: read
345+ issues: write
346+
347+ steps:
348+ - uses: actions/checkout@v4
349+
350+ - name: Set up Node.js
351+ uses: actions/setup-node@v4
352+ with:
353+ node-version: "18"
354+
355+ - name: Install Continue CLI
254356 run: |
255- echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> $GITHUB_ENV
256- echo "POSTHOG_PROJECT_ID=${{ secrets.POSTHOG_PROJECT_ID }}" >> $GITHUB_ENV
257- echo "POSTHOG_HOST=${{ secrets.POSTHOG_HOST || 'https://us.posthog.com' }}" >> $GITHUB_ENV
258- echo "GITHUB_PAT=${{ secrets.GITHUB_PAT }}" >> $GITHUB_ENV
259- echo "GITHUB_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
260- echo "GITHUB_REPO=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
357+ npm install -g @continuedev/cli
358+ echo "✅ Continue CLI installed"
359+ cn --version
261360
262361 - name: Authenticate with Continue CLI
263362 run: |
@@ -274,13 +373,12 @@
274373 run: |
275374 echo "🎬 Starting PostHog session analysis..."
276375 # Create the analysis prompt
277- cat > analysis_prompt.txt << 'EOF'
278376 I need you to help me analyze PostHog session recordings to identify UX issues. Please:
279377
280378 1. First, fetch session recordings from PostHog using these details:
281- - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from environment variables
282- - API endpoint: $POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=20
283- - Include Authorization header: "Bearer $POSTHOG_API_KEY"
379+ - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from my secrets
380+ - API endpoint: {POSTHOG_HOST}/api/projects/{POSTHOG_PROJECT_ID}/session_recordings/?limit=20
381+ - Include Authorization header: 'Bearer {POSTHOG_API_KEY}'
284382
285383 2. Filter the sessions to find problematic ones with either:
286384 - console_error_count > 0 (JavaScript errors)
@@ -300,43 +398,22 @@
300398 **Impact**: Quantify the impact (e.g., 'Affects 80% of sessions')
301399
302400 Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data.
303-
304- Environment context:
305- - POSTHOG_API_KEY: $POSTHOG_API_KEY
306- - POSTHOG_PROJECT_ID: $POSTHOG_PROJECT_ID
307- - POSTHOG_HOST: $POSTHOG_HOST
308- - GitHub Repo: $GITHUB_OWNER/$GITHUB_REPO
309401 EOF
310402
311- # Run the analysis
312- cn < analysis_prompt.txt > analysis-results.txt 2>&1
313-
314- # Check if analysis completed
315- if [ ! -s analysis-results.txt ]; then
316- echo "❌ Analysis failed or produced no output"
317- exit 1
318- fi
319-
320403 echo "✅ Analysis completed"
321- echo "📄 Analysis results preview:"
322- head -20 analysis-results.txt
404+
323405
324406 - name: Create GitHub Issues from Analysis
325407 run: |
326408 echo "📝 Creating GitHub issues from analysis..."
327409 # Create the issue creation prompt
328- cat > issue_prompt.txt << 'EOF'
329410 I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API.
330411
331- Use these details from environment variables:
332- - GITHUB_PAT: My GitHub Personal Access Token
333- - Repository: $GITHUB_OWNER/$GITHUB_REPO
334-
335412 For each issue in my analysis:
336413 1. Parse the issue title, body content, and priority level
337- 2. Create a GitHub issue via API POST to: https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/issues
414+ 2. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues
338415 3. Use these headers:
339- - Authorization: token $GITHUB_PAT
416+ - Authorization: token {GITHUB_PAT}
340417 - Accept: application/vnd.github.v3+json
341418 - Content-Type: application/json
342419 4. Set labels based on priority:
@@ -347,57 +424,16 @@
347424
348425 Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs.
349426
350- Here's my analysis to process:
351- EOF
352-
353- # Append the analysis results to the prompt
354- cat analysis-results.txt >> issue_prompt.txt
355-
356- # Run the issue creation
357- cn < issue_prompt.txt > issue-creation-results.txt 2>&1
358-
359427 echo "✅ Issue creation completed"
360- echo "📄 Issue creation results:"
361- cat issue-creation-results.txt
362-
363- - name: Upload Analysis Artifacts
364- uses: actions/upload-artifact@v4
365- if: always()
366- with:
367- name: analysis-results-${{ github.run_number }}
368- path: |
369- analysis-results.txt
370- issue-creation-results.txt
371- retention-days: 30
372428
373429 - name: Summary
374430 run: |
375431 echo "✅ PostHog analysis workflow completed!"
376- echo "📊 Check the artifacts for detailed analysis results"
377432 echo "🐛 Check your repository issues for newly created UX issues"
378-```
379-
380-## Step 5: Testing Your Workflow
381-
382-### Test Locally First
383-
384-Before setting up automation, test the workflow locally:
385-
386-**Test 1: Session Analysis**
387-
388-```bash
389-cn -p "[Paste the PostHog analysis prompt from Step 2]"
390-```
391-
392-Expected: Analysis output with 3 formatted GitHub issues
393-
394-**Test 2: Issue Creation**
395-
396-```bash
397-cn -p "[Paste the GitHub issue creation prompt from Step 3 with your analysis results]"
398-```
433+ ```
399434
400-Expected: Confirmation of GitHub issues created with URLs
435+ </Tab>
436+</Tabs>
401437
402438 ### Test the GitHub Actions Workflow
403439
@@ -406,48 +442,28 @@
406442 3. **Verify Issues**: Check that GitHub issues were created in your repository
407443
408444 <Check>
409- **Success Indicators:** - PostHog API returns session data (not empty) -
410- Continue CLI generates analysis with identified issues - GitHub issues are
411- created with proper labels and formatting - Workflow completes without errors
412-</Check>
413445
414-## Troubleshooting
446+ **Success Indicators:**
447+ - PostHog API returns session data (not empty)
448+ - Continue CLI generates analysis with identified issues
449+ - GitHub issues are created with proper labels and formatting
450+ - Workflow completes without errors
415451
416-If you encounter issues, use this helpful prompt to diagnose problems:
417-
418-```bash
419-cn -p "Help me set up my environment for PostHog session analysis. Please:
420-
421-1. Check if I have the required secrets configured in Continue CLI:
422- - POSTHOG_API_KEY
423- - POSTHOG_PROJECT_ID
424- - POSTHOG_HOST
425- - GITHUB_PAT
426-
427-2. If any are missing, guide me through:
428- - How to get PostHog Personal API Key from PostHog settings
429- - How to find my PostHog Project ID from the URL
430- - How to create a GitHub Personal Access Token with issues:write permission
431- - How to add these as secrets in Continue CLI
432-
433-3. Help me identify my GitHub repository owner and name by:
434- - Checking git remote origin URL
435- - Or asking me to provide them
436-
437-4. Test the API connections by making a simple API call to both PostHog and GitHub to verify the credentials work.
438-
439-Please walk me through this setup process step by step."
440-```
452+</Check>
441453
442454 ## What You've Built
443455
444456 After completing this guide, you have a complete **Continuous AI system** that:
445457
446-✅ **Monitors user experience** - Automatically fetches and analyzes PostHog session data
447-✅ **Identifies problems intelligently** - Uses AI to spot patterns and technical issues
448-✅ **Creates actionable tasks** - Generates GitHub issues with specific recommendations
449-✅ **Runs autonomously** - Operates daily without manual intervention using GitHub Actions
450-✅ **Scales with your team** - Handles growing amounts of session data automatically
458+- **Monitors user experience** - Automatically fetches and analyzes PostHog session data
459+
460+- **Identifies problems intelligently** - Uses AI to spot patterns and technical issues
461+
462+- **Creates actionable tasks** - Generates GitHub issues with specific recommendations
463+
464+- **Runs autonomously** - Operates daily without manual intervention using GitHub Actions
465+
466+- **Scales with your team** - Handles growing amounts of session data automatically
451467
452468 <Card title="Continuous AI" icon="rocket">
453469 Your system now operates at **[Level 2 Continuous
@@ -459,10 +475,15 @@
459475 ## Security Best Practices
460476
461477 <Warning>
462- **Protect Your API Keys:** - Store all credentials as GitHub Secrets, never in
463- code - Use Continue CLI's secure secret storage - Limit token scopes to
464- minimum required permissions - Rotate API keys regularly (every 90 days
465- recommended) - Monitor token usage for unusual activity
478+
479+ **Protect Your API Keys:**
480+ - Store all credentials as GitHub Secrets, never in
481+ code
482+ - Use Continue CLI's secure secret storage
483+ - Limit token scopes to minimum required permissions
484+ - Rotate API keys regularly (every 90 days recommended)
485+ - Monitor token usage for unusual activity
486+
466487 </Warning>
467488
468489 ## Advanced Prompts