Elffuss BraidHub

kikocis/continue public

3ff29c567dd0 ยท 18.7 KiBRawPermalink
1---
2title: "Building a Continuous AI Workflow with PostHog and GitHub"
3description: "Build an automated system that continuously monitors PostHog session recordings, analyzes UX issues using Continue CLI, and creates GitHub issues automatically."
4sidebarTitle: "PostHog Session Analysis with Continue CLI"
5---
6
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
11</Card>
12
13## Prerequisites
14
15Before starting, ensure you have:
16
17- 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)**
19- Node.js 18+ installed locally
20- Continue CLI account with **active credits** (required for API usage)
21
22<Steps>
23 <Step title="Install Continue CLI">
24 ```bash
25 npm i -g @continuedev/cli
26 ```
27 </Step>
28
29 <Step title="Set up Continue CLI Account & API Key">
30 1. Visit [Continue Organizations](https://hub.continue.dev/settings/organizations)
31 2. Sign up or log in to your Continue account
32 3. Navigate to your organization settings
33 4. Click **"API Keys"** and then **"+ New API Key"**
34 5. Copy the API key immediately (you won't see it again!)
35 6. Login to the CLI: `cn login`
36 </Step>
37
38 <Step title="Add Required Secrets to Continue CLI">
39 Continue CLI will securely store your API keys as secrets that can be referenced in prompts.
40 </Step>
41</Steps>
42
43<Tip>
44 Continue CLI handles the complex API interactions - you just need to provide
45 the right prompts!
46</Tip>
47
48## Step 1: Set Up Your Credentials
49
50First, 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>
88
89### Add Secrets to Continue CLI
90
91To add environment variables to your Continue Hub account:
92
931. Go to the [Continue Hub](https://hub.continue.dev)
942. Sign in to your account
953. Navigate to your user settings
964. Look for the "Secrets" section
975. Add your variables there (like POSTHOG_API_KEY, POSTHOG_PROJECT_ID,
98 POSTHOG_HOST,GITHUB_PAT, etc.)
99
100These environment variables will then be securely stored and available for use in
101your Continue workflows.
102
103## PostHog GitHub Continuous AI Workflow Options
104
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>
109
110After completing **Step 1** below, you have two paths to get started:
111
112<Tabs>
113 <Tab title="โšก Quick Start (Recommended)">
114 **Perfect for:** Immediate results with optimized prompts and built-in debugging
115
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"**
119
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>
149
150 <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
157Use this prompt with Continue CLI to fetch and analyze your PostHog sessions:
158
159```bash
160cn -p "I need you to help me analyze PostHog session recordings to identify UX issues. Please:
161
1621. 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
1672. 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
1713. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems.
172
1734. 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
184Please 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
189Now use Continue CLI to create GitHub issues from your analysis results:
190
191```bash
192cn -p "I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API.
193
194Use 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
198For each issue in my analysis:
1991. Parse the issue title, body content, and priority level
2002. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues
2013. Use these headers:
202 - Authorization: token {GITHUB_PAT}
203 - Accept: application/vnd.github.v3+json
204 - Content-Type: application/json
2054. 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\"]
2095. Format the issue title as: \"๐Ÿ” UX Issue: {original title}\"
210
211Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs.
212"
213```
214
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
230<Warning>
231**Repository Labels Required**: Make sure your GitHub repository has these labels:
232- `bug`, `enhancement`
233- `high-priority`, `medium-priority`, `low-priority`
234- `user-experience`, `automated`
235
236Create missing labels in your repo at: **Settings โ†’ Labels โ†’ New label**
237
238</Warning>
239
240<Info>
241 **What Continue CLI Does:** - Parses your analysis results automatically -
242 Makes authenticated GitHub API calls using your stored token - Creates
243 properly formatted issues with appropriate labels - Checks for duplicate
244 issues to avoid spam - Provides confirmation with issue URLs
245</Info>
246
247## Setting Up Automated GitHub Actions Workflow
248
249Create a GitHub Actions workflow that runs your Continue CLI analysis automatically on a schedule.
250
251### Add GitHub Secrets
252
253First, add these secrets to your GitHub repository:
254
2551. Go to **Repository Settings โ†’ Secrets and variables โ†’ Actions**
2562. Click **"New repository secret"** and add:
257 - `CONTINUE_API_KEY`: Your Continue API key from hub.continue.dev
258
259### Create GitHub Actions Workflow
260
261Create `.github/workflows/posthog-analysis.yml` in your repository:
262
263<Tabs>
264 <Tab title="โšก Using Pre-Built Agent (Recommended)">
265```yaml
266name: PostHog Session Analysis with Continue CLI Agent
267
268on:
269schedule: - cron: "0 6 \* \* \*" # Run at 6 AM UTC daily
270workflow_dispatch: # Allow manual triggering
271
272jobs:
273analyze:
274runs-on: ubuntu-latest
275
276 permissions:
277 contents: read
278 issues: write
279
280 steps:
281 - uses: actions/checkout@v4
282
283 - name: Set up Node.js
284 uses: actions/setup-node@v4
285 with:
286 node-version: "18"
287
288 - name: Install Continue CLI
289 run: |
290 npm install -g @continuedev/cli
291 echo "โœ… Continue CLI installed"
292 cn --version
293
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
333name: PostHog Session Analysis with Continue CLI Manual
334
335on:
336schedule: - cron: "0 6 \* \* \*" # Run at 6 AM UTC daily
337workflow_dispatch: # Allow manual triggering
338
339jobs:
340analyze:
341runs-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
356 run: |
357 npm install -g @continuedev/cli
358 echo "โœ… Continue CLI installed"
359 cn --version
360
361 - name: Authenticate with Continue CLI
362 run: |
363 # Set Continue API key
364 export CONTINUE_API_KEY="${{ secrets.CONTINUE_API_KEY }}"
365 # Login to Continue CLI
366 if ! cn auth login --api-key "$CONTINUE_API_KEY"; then
367 echo "โŒ Failed to authenticate with Continue CLI"
368 exit 1
369 fi
370 echo "โœ… Continue CLI authenticated"
371
372 - name: Run PostHog Session Analysis
373 run: |
374 echo "๐ŸŽฌ Starting PostHog session analysis..."
375 # Create the analysis prompt
376 I need you to help me analyze PostHog session recordings to identify UX issues. Please:
377
378 1. First, fetch session recordings from PostHog using these details:
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}'
382
383 2. Filter the sessions to find problematic ones with either:
384 - console_error_count > 0 (JavaScript errors)
385 - recording_duration > 300 (sessions longer than 5 minutes)
386
387 3. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems.
388
389 4. Format each issue like this:
390 ### 1. **Issue Title Here**
391 **Problem**: One sentence describing the user problem
392 **Technical Causes**: Brief technical explanation
393 **Affected Pages**: List the URLs
394 **Recommended Fix**:
395 - Specific action item 1
396 - Specific action item 2
397 **Priority**: **HIGH** or **MEDIUM** or **LOW**
398 **Impact**: Quantify the impact (e.g., 'Affects 80% of sessions')
399
400 Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data.
401 EOF
402
403 echo "โœ… Analysis completed"
404
405
406 - name: Create GitHub Issues from Analysis
407 run: |
408 echo "๐Ÿ“ Creating GitHub issues from analysis..."
409 # Create the issue creation prompt
410 I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API.
411
412 For each issue in my analysis:
413 1. Parse the issue title, body content, and priority level
414 2. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues
415 3. Use these headers:
416 - Authorization: token {GITHUB_PAT}
417 - Accept: application/vnd.github.v3+json
418 - Content-Type: application/json
419 4. Set labels based on priority:
420 - HIGH: ["bug", "high-priority", "user-experience", "automated"]
421 - MEDIUM: ["enhancement", "medium-priority", "user-experience", "automated"]
422 - LOW: ["low-priority", "user-experience", "automated"]
423 5. Format the issue title as: "๐Ÿ” UX Issue: {original title}"
424
425 Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs.
426
427 echo "โœ… Issue creation completed"
428
429 - name: Summary
430 run: |
431 echo "โœ… PostHog analysis workflow completed!"
432 echo "๐Ÿ› Check your repository issues for newly created UX issues"
433 ```
434
435 </Tab>
436</Tabs>
437
438### Test the GitHub Actions Workflow
439
4401. **Manual Trigger**: Go to **Actions** tab in your repository and manually trigger the workflow
4412. **Check Artifacts**: Download the analysis results from the workflow run
4423. **Verify Issues**: Check that GitHub issues were created in your repository
443
444<Check>
445
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
451
452</Check>
453
454## What You've Built
455
456After completing this guide, you have a complete **Continuous AI system** that:
457
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
467
468<Card title="Continuous AI" icon="rocket">
469 Your system now operates at **[Level 2 Continuous
470 AI](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/)** -
471 AI handles routine analysis tasks with human oversight through GitHub issue
472 review and prioritization.
473</Card>
474
475## Security Best Practices
476
477<Warning>
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
487</Warning>
488
489## Advanced Prompts
490
491Consider enhancing your workflow with these advanced Continue CLI prompts:
492
493<CardGroup cols={2}>
494 <Card title="Performance Analysis" icon="chart-line">
495 "Analyze PostHog performance metrics alongside session recordings to
496 identify slow page loads affecting user experience"
497 </Card>
498 <Card title="Error Correlation" icon="bug">
499 "Cross-reference JavaScript console errors with user actions to identify the
500 root cause of UX issues"
501 </Card>
502 <Card title="Feature Flag Analysis" icon="flag">
503 "Analyze how PostHog feature flags impact user behavior in session
504 recordings"
505 </Card>
506 <Card title="Custom Slack Alerts" icon="slack">
507 "Create Slack alerts when critical UX issues are detected in PostHog
508 sessions"
509 </Card>
510</CardGroup>
511
512## Next Steps
513
5141. **Monitor your first issues** - Review the GitHub issues created and implement fixes
5152. **Measure impact** - Track how resolved issues improve PostHog metrics
5163. **Refine prompts** - Adjust the Continue CLI prompts based on issue quality
5174. **Scale the system** - Add more data sources or create specialized analysis workflows