From 25dc291a4a86c2e8609324d1c73a2d813b9aa2f9 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 14:21:17 -0400 Subject: [PATCH 01/16] Add posthog con ai post --- docs/guides/overview.mdx | 1 + docs/guides/posthog-session-analysis.mdx | 547 +++++++++++++++++++++++ 2 files changed, 548 insertions(+) create mode 100644 docs/guides/posthog-session-analysis.mdx diff --git a/docs/guides/overview.mdx b/docs/guides/overview.mdx index 3a609ac15..5fb282529 100644 --- a/docs/guides/overview.mdx +++ b/docs/guides/overview.mdx @@ -13,6 +13,7 @@ description: "Comprehensive collection of practical guides for Continue includin - [Continuous AI: A Developer's Guide](/guides/continuous-ai) - Integrating AI into development workflows - [How to Use Continue CLI (cn)](/guides/cli) - Command-line interface for Continue +- [PostHog Session Analysis with Continue CLI](/guides/posthog-session-analysis) - Analyze user behavior data to optimize your codebase with automatic issue creation ## What Advanced Tutorials Are Available diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx new file mode 100644 index 000000000..f37ba52bb --- /dev/null +++ b/docs/guides/posthog-session-analysis.mdx @@ -0,0 +1,547 @@ +--- +title: "PostHog Session Recording Analysis with Continue CLI" +description: "Automatically analyze PostHog session recordings to identify UX issues and generate code optimization suggestions using Continue CLI" +--- + +# Building a Continuous AI Workflow with PostHog and GitHub + +This guide shows you how to build an automated system that continuously monitors PostHog session recordings, analyzes user experience issues using AI, and automatically creates GitHub issues for your development team to address. + + + A fully automated workflow that fetches PostHog session data, uses Continue + CLI to identify UX problems, and creates GitHub issues with specific technical + recommendations + + +## Prerequisites + + + **Session Recordings Required**: This workflow requires PostHog session + recordings to be enabled. If you haven't set this up yet, follow [PostHog's + session recording installation + guide](https://posthog.com/docs/session-replay/installation) first. + + +Before starting, ensure you have: + +- GitHub repository where you want to create issues +- PostHog account with **session recordings enabled and collecting data** +- Node.js 18+ installed locally +- Basic familiarity with [Continue CLI](/guides/cli) + + + + ```bash npm i -g @continuedev/cli ``` + + + ```bash # macOS brew install gh # Ubuntu/Debian sudo apt install gh # + Windows winget install --id GitHub.cli + ``` + + Then authenticate: `gh auth login` + + + + Get your Personal API Key from PostHog settings + + Run your first automated analysis + + +## Step 1: Environment Setup + +### Get Your PostHog API Credentials + +You need a **Personal API Key** (not a Project API key) to access session recordings: + +1. Go to [Personal API Keys](https://app.posthog.com/settings/user-api-keys) in PostHog +2. Click **+ Create a personal API Key** +3. Name it "Continue CLI Session Analysis" +4. Select these scopes: + - `session_recording:read` - **Required** for accessing session data + - `insight:read` - Optional, for additional analytics +5. Copy the key immediately (you won't see it again!) + +### Set Up Your Environment Variables + + + +```bash Environment Setup +# Create working directory +mkdir posthog-continuous-ai +cd posthog-continuous-ai + +# Create environment file +cat > .env << EOF +# PostHog Configuration +POSTHOG_API_KEY=your_personal_api_key_here +POSTHOG_PROJECT_ID=your_project_id_here +POSTHOG_HOST=https://us.posthog.com + +# GitHub Configuration +GITHUB_OWNER=YourUsername +GITHUB_REPO=your-repository-name +EOF + +# Load environment +source .env +``` + +```bash Security Setup +# Protect sensitive files +cat > .gitignore << EOF +# Environment variables - contains API keys +.env + +# Generated data files +*.json +analysis-results.txt +daily-analysis.log + +# Temporary files +*.tmp +EOF +``` + + + + + **Find Your Project Details**: Your Project ID is in your PostHog URL: + `https://app.posthog.com/project/YOUR_PROJECT_ID` + + +### GitHub CLI Setup + +The workflow uses GitHub CLI instead of API tokens for better security and easier authentication: + + + GitHub CLI provides secure authentication without needing to manage Personal + Access Tokens in your environment files. + + +**Verify GitHub CLI is ready:** + +```bash +# Check if GitHub CLI is installed +gh --version + +# Check authentication status +gh auth status + +# If not authenticated, login +gh auth login +``` + + + **Authentication**: GitHub CLI handles authentication automatically once you + run `gh auth login`. No need to manage tokens in `.env` files! + + +## Step 2: Session Analysis Script + +Create an intelligent analysis script that fetches and analyzes session recordings: + +```bash +#!/bin/bash +# analyze-sessions.sh +set -e +source .env + +echo "đŸŽŦ Fetching session recordings from PostHog..." + +# Fetch recent session recordings with potential issues +curl -s -H "Authorization: Bearer $POSTHOG_API_KEY" \ + "$POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=20" \ + | jq '.results[] | { + id: .id, + duration: .recording_duration, + start_url: .start_url, + click_count: .click_count, + console_error_count: .console_error_count, + person_distinct_id: .person.distinct_ids[0], + start_time: .start_time + }' > sessions.json + +echo "📊 Found $(cat sessions.json | jq -s length) sessions" + +# Filter for problematic sessions (errors or long durations) +cat sessions.json | jq -s 'map(select(.console_error_count > 0 or .recording_duration > 300))' > problem-sessions.json + +echo "🚨 Found $(cat problem-sessions.json | jq length) problematic sessions" + +# Analyze with Continue CLI +cat problem-sessions.json | cn -p " +Analyze these PostHog session recordings to identify user experience issues. + +Each session contains: +- duration: how long the session lasted (in seconds) +- start_url: the page where the user started +- click_count: total number of clicks +- console_error_count: JavaScript errors encountered + +Look for patterns that suggest code issues: + +1. **High Error Sessions**: Sessions with console_error_count > 0 + - What pages/URLs are generating errors? + - Are users abandoning after errors occur? + +2. **Long Duration Sessions**: Sessions over 300 seconds (5+ minutes) + - Are users struggling to complete tasks? + - Low click count + high duration = user confusion + +3. **Abandonment Patterns**: + - Users starting on key pages but not progressing + - Short sessions on important conversion pages + +For each issue pattern you identify: +- Describe the user behavior problem +- Suggest likely technical causes (JS errors, slow loading, UI confusion) +- Recommend specific code areas to investigate +- Provide example fixes or improvements +- Priority: High (blocks user goals), Medium (hurts UX), Low (minor issue) + +Focus on actionable technical improvements that will measurably improve user experience. +" + +echo "✅ Analysis complete! Check the output above for optimization opportunities." +``` + + + **What This Script Does:** 1. **Fetches** recent session recordings from + PostHog API 2. **Filters** for problematic sessions (errors or long durations) + 3. **Analyzes** with Continue CLI to identify specific UX issues 4. + **Provides** actionable technical recommendations + + +Make the script executable: + +```bash +chmod +x analyze-sessions.sh +``` + +## Step 3: Automated GitHub Issue Creation + +Create a smart script that parses the AI analysis and automatically creates GitHub issues: + + + This script automatically extracts issues from Continue CLI analysis, + determines priority levels, assigns appropriate labels, and creates + well-formatted GitHub issues + + +```bash +#!/bin/bash +# create-github-issues.sh - Creates GitHub issues from Continue CLI analysis output +set -e +source .env + +# Input file containing Continue CLI analysis output +ANALYSIS_FILE="analysis-results.txt" + +# Check if analysis file exists +if [ ! -f "$ANALYSIS_FILE" ]; then + echo "❌ Analysis file not found: $ANALYSIS_FILE" + exit 1 +fi + +# Function to create a GitHub issue +create_github_issue() { + local title="$1" + local body="$2" + local labels="$3" + + echo "Creating issue: $title" + + response=$(curl -s -X POST \ + -H "Authorization: token $GITHUB_PERSONAL_ACCESS_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + -d "{\"title\":\"$title\", \"body\":\"$body\", \"labels\":$labels}" \ + "https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/issues") + + issue_number=$(echo "$response" | grep -o '"number": [0-9]*' | head -1 | cut -d' ' -f2) + + if [ -n "$issue_number" ]; then + echo "✅ Created issue #$issue_number" + else + echo "❌ Failed to create issue: $response" + fi +} + +# Extract and parse issues from analysis output +echo "🔍 Parsing analysis results for issues..." + +# Count the issues in the file by looking for ## Issue pattern +issue_count=$(grep -c "^## Issue" "$ANALYSIS_FILE" || echo 0) + +if [ "$issue_count" -eq 0 ]; then + echo "â„šī¸ No issues found in analysis output." + exit 0 +fi + +echo "📊 Found $issue_count potential issues to process" + +# Process each issue section +while IFS= read -r line || [[ -n "$line" ]]; do + if [[ $line =~ ^## ]]; then + # If we have a previous issue, create it + if [ -n "${issue_title:-}" ] && [ -n "${issue_body:-}" ]; then + # Determine appropriate labels based on priority in the issue body + if [[ "$issue_body" =~ "High Priority" ]]; then + labels="[\"bug\", \"high-priority\", \"user-experience\"]" + elif [[ "$issue_body" =~ "Medium Priority" ]]; then + labels="[\"enhancement\", \"medium-priority\", \"user-experience\"]" + else + labels="[\"low-priority\", \"user-experience\"]" + fi + + # Create the issue + create_github_issue "$issue_title" "$issue_body" "$labels" + fi + + # Start a new issue + issue_title="UX Issue: ${line#\#\# Issue }" + issue_body="" + elif [ -n "${issue_title:-}" ]; then + # Add line to current issue body + if [ -n "$issue_body" ]; then + issue_body="$issue_body\n$line" + else + issue_body="$line" + fi + fi +done < <(sed -n '/^## Issue/,/^## Issue\|^$/p' "$ANALYSIS_FILE") + +# Create the last issue if there is one +if [ -n "${issue_title:-}" ] && [ -n "${issue_body:-}" ]; then + # Determine appropriate labels based on priority in the issue body + if [[ "$issue_body" =~ "High Priority" ]]; then + labels="[\"bug\", \"high-priority\", \"user-experience\"]" + elif [[ "$issue_body" =~ "Medium Priority" ]]; then + labels="[\"enhancement\", \"medium-priority\", \"user-experience\"]" + else + labels="[\"low-priority\", \"user-experience\"]" + fi + + # Create the issue + create_github_issue "$issue_title" "$issue_body" "$labels" +fi + +echo "✅ GitHub issues creation process completed!" +``` + +Make it executable: + +```bash +chmod +x create-github-issues.sh +``` + + + **Smart Label Assignment**: The script automatically assigns labels based on + issue priority: - **High Priority** → `bug`, `high-priority`, + `user-experience` - **Medium Priority** → `enhancement`, `medium-priority`, + `user-experience` - **Low Priority** → `low-priority`, `user-experience` + + +## Step 4: Complete Automated Workflow + +Create the main orchestration script that runs the entire process: + +```bash +#!/bin/bash +# daily-analysis.sh +set -e + +echo "🔍 Starting daily PostHog session analysis..." + +# Run the session analysis +./analyze-sessions.sh > analysis-results.txt + +# Create GitHub issues based on the analysis +./create-github-issues.sh + +echo "✅ Daily analysis complete!" +``` + +Make it executable and test: + +```bash +chmod +x daily-analysis.sh +./daily-analysis.sh +``` + +## Step 5: Automation Options + + + + Perfect for teams already using GitHub workflows: + + Create `.github/workflows/daily-analysis.yml`: + +Create a file at `.github/workflows/daily-analysis.yml`: + +```yaml +name: Daily Session Analysis + +on: + schedule: + - cron: "0 6 * * *" # Run at 6 AM UTC daily + workflow_dispatch: # Allow manual triggering + +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up environment + run: | + echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> .env + echo "POSTHOG_PROJECT_ID=${{ secrets.POSTHOG_PROJECT_ID }}" >> .env + echo "POSTHOG_HOST=https://us.posthog.com" >> .env + echo "GITHUB_PERSONAL_ACCESS_TOKEN=${{ secrets.GH_PAT }}" >> .env + echo "GITHUB_OWNER=${{ github.repository_owner }}" >> .env + echo "GITHUB_REPO=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> .env + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y jq curl + npm install -g @continuedev/cli + + - name: Run analysis + run: ./daily-analysis.sh +``` + +**Required GitHub Secrets:** - `POSTHOG_API_KEY`: Your PostHog Personal API Key - `POSTHOG_PROJECT_ID`: Your PostHog Project ID - `GH_PAT`: Your GitHub Personal Access Token + + Add these in: Repository Settings → Secrets and variables → Actions + + + + + For running on your own server or VPS: + + ```bash + # Add to crontab (run 'crontab -e') + 0 6 * * * cd /path/to/your/project && ./daily-analysis.sh >> ~/logs/analysis.log 2>&1 + ``` + + **Benefits:** + - Full control over execution environment + - No GitHub Actions usage limits + - Can run more frequently if needed + + + + + For testing and development: + + ```bash + # Run manually + ./daily-analysis.sh + + # Or set up a simple loop for testing + while true; do + ./daily-analysis.sh + sleep 3600 # Run every hour + done + ``` + + + + +## Step 6: Testing Your Workflow + + + + ```bash # Test PostHog API curl -H "Authorization: Bearer $POSTHOG_API_KEY" + \ + "$POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=1" + # Test GitHub API curl -H "Authorization: token + $GITHUB_PERSONAL_ACCESS_TOKEN" \ + "https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO" + ``` + + + + ```bash ./analyze-sessions.sh ``` Expected: JSON files with session data and + AI analysis output + + + + ```bash ./create-github-issues.sh ``` Expected: New issues created in your + GitHub repository + + + + ```bash ./daily-analysis.sh ``` Expected: Complete end-to-end execution with + GitHub issues created + + + + + **Success Indicators:** - PostHog API returns session data (not empty) - + Continue CLI generates analysis with identified issues - GitHub issues are + created with proper labels and formatting - No error messages in the console + output + + +## What You've Built + +After completing this guide, you have a complete **Continuous AI system** that: + +✅ **Monitors user experience** - Automatically fetches and analyzes PostHog session data +✅ **Identifies problems intelligently** - Uses AI to spot patterns and technical issues +✅ **Creates actionable tasks** - Generates GitHub issues with specific recommendations +✅ **Runs autonomously** - Operates daily without manual intervention +✅ **Scales with your team** - Handles growing amounts of session data automatically + + + Your system now operates at **Level 2 Continuous AI** - AI handles routine + analysis tasks with human oversight through GitHub issue review and + prioritization. + + +## Security Best Practices + + + **Protect Your API Keys:** - Never commit `.env` files or secrets to version + control - Use GitHub Secrets for automation workflows - Limit token scopes to + minimum required permissions - Rotate API keys regularly (every 90 days + recommended) - Monitor token usage for unusual activity + + +## Advanced Extensions + +Ready to enhance your workflow? Consider these additions: + + + + Add PostHog and GitHub MCP servers for more sophisticated analysis + + + Train the AI on your specific codebase patterns and conventions + + + Get notifications when critical issues are detected + + + Track how fixes improve user experience metrics over time + + + +## Next Steps + +1. **Monitor your first issues** - Review the GitHub issues created and implement fixes +2. **Measure impact** - Track how resolved issues improve PostHog metrics +3. **Refine analysis** - Adjust the Continue CLI prompts based on issue quality +4. **Scale the system** - Add more data sources or create specialized analysis workflows + + + Check out the [Enhanced MCP + Integration](/guides/posthog-session-analysis#enhanced-workflow-with-mcp-tools) + section for direct PostHog and GitHub API access through structured tools. + From 63ffb1d591ed95664d3a62bbb94ae3255c302955 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 16:25:32 -0400 Subject: [PATCH 02/16] Reformat info callout --- docs/guides/posthog-session-analysis.mdx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index f37ba52bb..4d96c7286 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -206,10 +206,15 @@ echo "✅ Analysis complete! Check the output above for optimization opportuniti ``` - **What This Script Does:** 1. **Fetches** recent session recordings from - PostHog API 2. **Filters** for problematic sessions (errors or long durations) - 3. **Analyzes** with Continue CLI to identify specific UX issues 4. - **Provides** actionable technical recommendations + +**What This Script Does:** + +1. **Fetches** recent session recordings from + PostHog API +2. **Filters** for problematic sessions (errors or long durations) +3. **Analyzes** with Continue CLI to identify specific UX issues +4. **Provides** actionable technical recommendations + Make the script executable: From bd000fd9dec39fdb17da42e7dc78379029f17b94 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:10:41 -0400 Subject: [PATCH 03/16] Fix formatting --- docs/guides/posthog-session-analysis.mdx | 73 ++++++++++++++---------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index 4d96c7286..3572cf38c 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -416,7 +416,11 @@ jobs: run: ./daily-analysis.sh ``` -**Required GitHub Secrets:** - `POSTHOG_API_KEY`: Your PostHog Personal API Key - `POSTHOG_PROJECT_ID`: Your PostHog Project ID - `GH_PAT`: Your GitHub Personal Access Token +**Required GitHub Secrets:** + + - `POSTHOG_API_KEY`: Your PostHog Personal API Key + - `POSTHOG_PROJECT_ID`: Your PostHog Project ID + - `GH_PAT`: Your GitHub Personal Access Token Add these in: Repository Settings → Secrets and variables → Actions @@ -425,33 +429,34 @@ jobs: For running on your own server or VPS: - ```bash - # Add to crontab (run 'crontab -e') - 0 6 * * * cd /path/to/your/project && ./daily-analysis.sh >> ~/logs/analysis.log 2>&1 - ``` + ```bash + # Add to crontab (run 'crontab -e') + 0 6 * * * cd /path/to/your/project && ./daily-analysis.sh >> ~/logs/analysis.log 2>&1 + ``` - **Benefits:** - - Full control over execution environment - - No GitHub Actions usage limits - - Can run more frequently if needed + **Benefits:** + - Full control over execution environment + - No GitHub Actions usage limits + - Can run more frequently if needed + + - - For testing and development: - ```bash - # Run manually - ./daily-analysis.sh - - # Or set up a simple loop for testing - while true; do + ```bash + # Run manually ./daily-analysis.sh - sleep 3600 # Run every hour - done - ``` - + # Or set up a simple loop for testing + while true; do + ./daily-analysis.sh + sleep 3600 # Run every hour + done + ``` + + + ## Step 6: Testing Your Workflow @@ -484,10 +489,12 @@ jobs: - **Success Indicators:** - PostHog API returns session data (not empty) - - Continue CLI generates analysis with identified issues - GitHub issues are - created with proper labels and formatting - No error messages in the console - output + **Success Indicators:** + - PostHog API returns session data (not empty) + - Continue CLI generates analysis with identified issues + - GitHub issues are created with proper labels and formatting + - No error messages in the console output + ## What You've Built @@ -500,7 +507,7 @@ After completing this guide, you have a complete **Continuous AI system** that: ✅ **Runs autonomously** - Operates daily without manual intervention ✅ **Scales with your team** - Handles growing amounts of session data automatically - + Your system now operates at **Level 2 Continuous AI** - AI handles routine analysis tasks with human oversight through GitHub issue review and prioritization. @@ -509,10 +516,16 @@ After completing this guide, you have a complete **Continuous AI system** that: ## Security Best Practices - **Protect Your API Keys:** - Never commit `.env` files or secrets to version - control - Use GitHub Secrets for automation workflows - Limit token scopes to - minimum required permissions - Rotate API keys regularly (every 90 days - recommended) - Monitor token usage for unusual activity + **Protect Your API Keys:** + - Never commit `.env` files or secrets to version + control + - Use GitHub Secrets for automation workflows + - Limit token scopes to + minimum required permissions + - Rotate API keys regularly (every 90 days + recommended) + - Monitor token usage for unusual activity + ## Advanced Extensions From f32aebf4003f32a6776256d708215bf3fb26ddcd Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:20:28 -0400 Subject: [PATCH 04/16] Fix termal commands formatting --- docs/guides/posthog-session-analysis.mdx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index 3572cf38c..dff56d76e 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -34,8 +34,13 @@ Before starting, ensure you have: ```bash npm i -g @continuedev/cli ``` - ```bash # macOS brew install gh # Ubuntu/Debian sudo apt install gh # - Windows winget install --id GitHub.cli + ```bash + # macOS + brew install gh + # Ubuntu/Debian + sudo apt install gh + # Windows + winget install --id GitHub.cli ``` Then authenticate: `gh auth login` From dec42896f4ebd127c5f67ae556ff32559bcb230e Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:24:58 -0400 Subject: [PATCH 05/16] Change card text --- docs/guides/posthog-session-analysis.mdx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index dff56d76e..ef60eb7f6 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -538,12 +538,9 @@ After completing this guide, you have a complete **Continuous AI system** that: Ready to enhance your workflow? Consider these additions: - - Add PostHog and GitHub MCP servers for more sophisticated analysis + + For greater flexibility, consider enhancing this workflow with additional + PostHog data sources (funnel analysis, feature flags, etc.) Train the AI on your specific codebase patterns and conventions From 9f77e16b45c00c839d800db1b1436a83d6401c1f Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:39:40 -0400 Subject: [PATCH 06/16] Remove repetition --- docs/guides/posthog-session-analysis.mdx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index ef60eb7f6..645926ef3 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -346,9 +346,13 @@ chmod +x create-github-issues.sh **Smart Label Assignment**: The script automatically assigns labels based on - issue priority: - **High Priority** → `bug`, `high-priority`, - `user-experience` - **Medium Priority** → `enhancement`, `medium-priority`, - `user-experience` - **Low Priority** → `low-priority`, `user-experience` + issue priority: + - **High Priority** → `bug`, `high-priority`, + `user-experience` + - **Medium Priority** → `enhancement`, `medium-priority`, + `user-experience` + - **Low Priority** → `low-priority`, `user-experience` + ## Step 4: Complete Automated Workflow @@ -386,8 +390,6 @@ chmod +x daily-analysis.sh Create `.github/workflows/daily-analysis.yml`: -Create a file at `.github/workflows/daily-analysis.yml`: - ```yaml name: Daily Session Analysis From 31d98a24ec8428f260c09bb006efd736861e71c8 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:44:04 -0400 Subject: [PATCH 07/16] Clean up language and unnecessary text --- docs/guides/posthog-session-analysis.mdx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-session-analysis.mdx index 645926ef3..b1c1c7053 100644 --- a/docs/guides/posthog-session-analysis.mdx +++ b/docs/guides/posthog-session-analysis.mdx @@ -535,14 +535,14 @@ After completing this guide, you have a complete **Continuous AI system** that: -## Advanced Extensions +## Continue Your Workflow -Ready to enhance your workflow? Consider these additions: +Consider these additions: - - For greater flexibility, consider enhancing this workflow with additional - PostHog data sources (funnel analysis, feature flags, etc.) + + Enhance this workflow with additional PostHog data sources (funnel analysis, + feature flags, etc.) Train the AI on your specific codebase patterns and conventions @@ -561,9 +561,3 @@ Ready to enhance your workflow? Consider these additions: 2. **Measure impact** - Track how resolved issues improve PostHog metrics 3. **Refine analysis** - Adjust the Continue CLI prompts based on issue quality 4. **Scale the system** - Add more data sources or create specialized analysis workflows - - - Check out the [Enhanced MCP - Integration](/guides/posthog-session-analysis#enhanced-workflow-with-mcp-tools) - section for direct PostHog and GitHub API access through structured tools. - From 2254264432af32147ab2d3398a087aef87adb173 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:49:42 -0400 Subject: [PATCH 08/16] Change file name --- docs/guides/overview.mdx | 2 +- ...og-session-analysis.mdx => posthog-github-continuous-ai.mdx} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/guides/{posthog-session-analysis.mdx => posthog-github-continuous-ai.mdx} (100%) diff --git a/docs/guides/overview.mdx b/docs/guides/overview.mdx index 5fb282529..ba2fde21e 100644 --- a/docs/guides/overview.mdx +++ b/docs/guides/overview.mdx @@ -13,7 +13,7 @@ description: "Comprehensive collection of practical guides for Continue includin - [Continuous AI: A Developer's Guide](/guides/continuous-ai) - Integrating AI into development workflows - [How to Use Continue CLI (cn)](/guides/cli) - Command-line interface for Continue -- [PostHog Session Analysis with Continue CLI](/guides/posthog-session-analysis) - Analyze user behavior data to optimize your codebase with automatic issue creation +- [PostHog Session Analysis with Continue CLI](/guides/posthog-github-continuous-ai) - Analyze user behavior data to optimize your codebase with automatic issue creation ## What Advanced Tutorials Are Available diff --git a/docs/guides/posthog-session-analysis.mdx b/docs/guides/posthog-github-continuous-ai.mdx similarity index 100% rename from docs/guides/posthog-session-analysis.mdx rename to docs/guides/posthog-github-continuous-ai.mdx From 69cf4bcc3b40652f2fba6e7d65e32fc1eb7356c7 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Tue, 9 Sep 2025 18:50:19 -0400 Subject: [PATCH 09/16] Add to navigation --- docs/docs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/docs.json b/docs/docs.json index fa9e1604d..19bbdd3e7 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -232,6 +232,7 @@ "guides/codebase-documentation-awareness", "guides/cli", "guides/continuous-ai", + "guides/posthog-github-continuous-ai", "guides/plan-mode-guide", "guides/ollama-guide", "guides/instinct", From ec545a40e42fa1273c5596fb4e7923f709e6335c Mon Sep 17 00:00:00 2001 From: BekahHW Date: Wed, 10 Sep 2025 06:16:41 -0400 Subject: [PATCH 10/16] Fix title and description --- docs/guides/posthog-github-continuous-ai.mdx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index b1c1c7053..92462b410 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -1,12 +1,9 @@ --- -title: "PostHog Session Recording Analysis with Continue CLI" -description: "Automatically analyze PostHog session recordings to identify UX issues and generate code optimization suggestions using Continue CLI" +title: "Building a Continuous AI Workflow with PostHog and GitHub" +description: "This guide shows you how to build an automated system that continuously monitors PostHog session recordings, analyzes user experience issues using AI, and automatically creates GitHub issues for your development team to address." +sidebarTitle: "PostHog Session Analysis with Continue CLI" --- -# Building a Continuous AI Workflow with PostHog and GitHub - -This guide shows you how to build an automated system that continuously monitors PostHog session recordings, analyzes user experience issues using AI, and automatically creates GitHub issues for your development team to address. - A fully automated workflow that fetches PostHog session data, uses Continue CLI to identify UX problems, and creates GitHub issues with specific technical From 131491934d6cd5e3215f064954f67dab1f2f6d0e Mon Sep 17 00:00:00 2001 From: BekahHW Date: Wed, 10 Sep 2025 06:17:51 -0400 Subject: [PATCH 11/16] Remove repetitive warning --- docs/guides/posthog-github-continuous-ai.mdx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index 92462b410..1bcf595f3 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -12,17 +12,10 @@ sidebarTitle: "PostHog Session Analysis with Continue CLI" ## Prerequisites - - **Session Recordings Required**: This workflow requires PostHog session - recordings to be enabled. If you haven't set this up yet, follow [PostHog's - session recording installation - guide](https://posthog.com/docs/session-replay/installation) first. - - Before starting, ensure you have: - GitHub repository where you want to create issues -- PostHog account with **session recordings enabled and collecting data** +- PostHog account with **[session recordings enabled and collecting data](https://posthog.com/docs/session-replay/installation)** - Node.js 18+ installed locally - Basic familiarity with [Continue CLI](/guides/cli) From 57e35b6a4f19f02fa8fc8018549fbf3a0ede2911 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Wed, 10 Sep 2025 06:31:07 -0400 Subject: [PATCH 12/16] Add note about labeling conventions --- docs/guides/posthog-github-continuous-ai.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index 1bcf595f3..05484d40a 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -343,6 +343,9 @@ chmod +x create-github-issues.sh `user-experience` - **Low Priority** → `low-priority`, `user-experience` +**Be sure to customize the label logic** in the script to match your +repository's labeling conventions! + ## Step 4: Complete Automated Workflow From fedcf6e9efffd0bd9242297294c23d62f5674dc6 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Wed, 10 Sep 2025 06:37:52 -0400 Subject: [PATCH 13/16] Update to use gh cli --- docs/guides/posthog-github-continuous-ai.mdx | 83 +++++++++++++++++--- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index 05484d40a..7e6a0b6d7 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -237,32 +237,95 @@ source .env # Input file containing Continue CLI analysis output ANALYSIS_FILE="analysis-results.txt" +# File to track created issues to prevent duplicates +ISSUE_TRACKING_FILE=".created_issues.json" + # Check if analysis file exists if [ ! -f "$ANALYSIS_FILE" ]; then echo "❌ Analysis file not found: $ANALYSIS_FILE" exit 1 fi -# Function to create a GitHub issue +# Check if GitHub CLI is installed +if ! command -v gh &> /dev/null; then + echo "❌ GitHub CLI (gh) not found. Please install it first:" + echo " https://cli.github.com/manual/installation" + exit 1 +fi + +# Make sure gh is authenticated +if ! gh auth status &> /dev/null; then + echo "❌ GitHub CLI not authenticated. Please run 'gh auth login' first." + exit 1 +fi + +# Create issue tracking file if it doesn't exist +if [ ! -f "$ISSUE_TRACKING_FILE" ]; then + echo "[]" > "$ISSUE_TRACKING_FILE" +fi + +# Function to check if an issue with this title already exists +issue_exists() { + local title="$1" + local issue_hash=$(echo "$title" | md5sum | cut -d' ' -f1) + + # Check in our tracking file + if grep -q "\"$issue_hash\"" "$ISSUE_TRACKING_FILE"; then + return 0 # Issue exists + fi + + # Also check actual GitHub issues to be doubly sure + if gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --search "$title in:title" --json title | grep -q "$title"; then + # Add to tracking file if found on GitHub but not in our tracking + local tracking_data=$(cat "$ISSUE_TRACKING_FILE") + echo "$tracking_data" | jq --arg hash "$issue_hash" '. += [$hash]' > "$ISSUE_TRACKING_FILE" + return 0 # Issue exists + fi + + return 1 # Issue doesn't exist +} + +# Function to record that we created an issue +record_issue() { + local title="$1" + local issue_hash=$(echo "$title" | md5sum | cut -d' ' -f1) + + local tracking_data=$(cat "$ISSUE_TRACKING_FILE") + echo "$tracking_data" | jq --arg hash "$issue_hash" '. += [$hash]' > "$ISSUE_TRACKING_FILE" +} + +# Function to create a GitHub issue using GitHub CLI create_github_issue() { local title="$1" local body="$2" local labels="$3" + # Check if this issue already exists + if issue_exists "$title"; then + echo "â„šī¸ Issue already exists: $title" + return 0 + fi + echo "Creating issue: $title" - response=$(curl -s -X POST \ - -H "Authorization: token $GITHUB_PERSONAL_ACCESS_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - -d "{\"title\":\"$title\", \"body\":\"$body\", \"labels\":$labels}" \ - "https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/issues") + # Convert labels from JSON array format to comma-separated list + # Remove brackets, quotes, and add commas + labels_list=$(echo $labels | sed 's/\[//g' | sed 's/\]//g' | sed 's/"//g' | sed 's/,/,/g') - issue_number=$(echo "$response" | grep -o '"number": [0-9]*' | head -1 | cut -d' ' -f2) + # Create issue using GitHub CLI + issue_url=$(gh issue create \ + --repo "$GITHUB_OWNER/$GITHUB_REPO" \ + --title "$title" \ + --body "$body" \ + --label "$labels_list" \ + --web) - if [ -n "$issue_number" ]; then - echo "✅ Created issue #$issue_number" + if [ $? -eq 0 ]; then + echo "✅ Created issue: $issue_url" + # Record that we created this issue + record_issue "$title" else - echo "❌ Failed to create issue: $response" + echo "❌ Failed to create issue" fi } From 5524f2dbfc20b7f1970f6c2080111a48d43508d1 Mon Sep 17 00:00:00 2001 From: BekahHW Date: Mon, 15 Sep 2025 13:00:36 -0400 Subject: [PATCH 14/16] Update based on working code --- docs/guides/posthog-github-continuous-ai.mdx | 621 ++++++++++++------- 1 file changed, 394 insertions(+), 227 deletions(-) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index 7e6a0b6d7..4a51c27b7 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -17,12 +17,24 @@ Before starting, ensure you have: - GitHub repository where you want to create issues - PostHog account with **[session recordings enabled and collecting data](https://posthog.com/docs/session-replay/installation)** - Node.js 18+ installed locally -- Basic familiarity with [Continue CLI](/guides/cli) +- Continue CLI account with **active credits** (required for API usage) - ```bash npm i -g @continuedev/cli ``` + ```bash + npm i -g @continuedev/cli + ``` + + + 1. Visit [Continue Organizations](https://hub.continue.dev/settings/organizations) + 2. Sign up or log in to your Continue account + 3. Navigate to your organization settings + 4. Click **"API Keys"** and then **"+ New API Key"** + 5. Copy the API key immediately (you won't see it again!) + 6. Login to the CLI with `cn login` + + ```bash # macOS @@ -39,9 +51,10 @@ Before starting, ensure you have: Get your Personal API Key from PostHog settings - Run your first automated analysis +Now you're ready to start building your workflow! + ## Step 1: Environment Setup ### Get Your PostHog API Credentials @@ -67,12 +80,15 @@ cd posthog-continuous-ai # Create environment file cat > .env << EOF +# Continue CLI Configuration (REQUIRED) +CONTINUE_API_KEY=your_continue_api_key_here + # PostHog Configuration POSTHOG_API_KEY=your_personal_api_key_here POSTHOG_PROJECT_ID=your_project_id_here POSTHOG_HOST=https://us.posthog.com -# GitHub Configuration +# GitHub Configuration (auto-detected from git, or set manually) GITHUB_OWNER=YourUsername GITHUB_REPO=your-repository-name EOF @@ -86,19 +102,31 @@ source .env cat > .gitignore << EOF # Environment variables - contains API keys .env +.env.local + +# Continue CLI authentication +.continue/ # Generated data files *.json analysis-results.txt daily-analysis.log +.created_issues.json # Temporary files *.tmp +/tmp/ EOF ``` + + **Auto-Detection**: The scripts can automatically detect your GitHub owner and + repo from your git remote origin URL. Manual configuration in `.env` overrides + auto-detection. + + **Find Your Project Details**: Your Project ID is in your PostHog URL: `https://app.posthog.com/project/YOUR_PROJECT_ID` @@ -106,8 +134,6 @@ EOF ### GitHub CLI Setup -The workflow uses GitHub CLI instead of API tokens for better security and easier authentication: - GitHub CLI provides secure authentication without needing to manage Personal Access Tokens in your environment files. @@ -126,24 +152,46 @@ gh auth status gh auth login ``` - - **Authentication**: GitHub CLI handles authentication automatically once you - run `gh auth login`. No need to manage tokens in `.env` files! - - ## Step 2: Session Analysis Script -Create an intelligent analysis script that fetches and analyzes session recordings: +Create the main analysis script that fetches PostHog session recordings, filters for problematic sessions, and uses Continue CLI to analyze them. -```bash + + **How It Works:** + - **Fetches** recent session recordings from PostHog API + - **Filters** for problematic sessions (errors or long durations) + - **Authenticates** with Continue CLI using your API key + - **Analyzes** session data and generates exactly 3 structured GitHub issues + + + + + +```bash analyze-sessions.sh #!/bin/bash -# analyze-sessions.sh +# analyze-sessions.sh - Fetches PostHog sessions and analyzes them with Continue CLI set -e -source .env + +# Load .env if it exists +if [ -f .env ]; then + source .env +fi + +# Check for required environment variables +if [ -z "$POSTHOG_API_KEY" ] || [ -z "$POSTHOG_PROJECT_ID" ] || [ -z "$POSTHOG_HOST" ]; then + echo "❌ Missing required PostHog environment variables" + exit 1 +fi + +if [ -z "$CONTINUE_API_KEY" ]; then + echo "❌ Missing CONTINUE_API_KEY environment variable" + echo "Get your API key from: https://hub.continue.dev/settings/organizations" + exit 1 +fi echo "đŸŽŦ Fetching session recordings from PostHog..." -# Fetch recent session recordings with potential issues +# Fetch recent session recordings curl -s -H "Authorization: Bearer $POSTHOG_API_KEY" \ "$POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=20" \ | jq '.results[] | { @@ -158,64 +206,130 @@ curl -s -H "Authorization: Bearer $POSTHOG_API_KEY" \ echo "📊 Found $(cat sessions.json | jq -s length) sessions" -# Filter for problematic sessions (errors or long durations) +# Filter for problematic sessions cat sessions.json | jq -s 'map(select(.console_error_count > 0 or .recording_duration > 300))' > problem-sessions.json echo "🚨 Found $(cat problem-sessions.json | jq length) problematic sessions" -# Analyze with Continue CLI +# Verify Continue CLI authentication +if ! cn auth status > /dev/null 2>&1; then + echo "🔑 Continue CLI not authenticated, attempting login..." + export CONTINUE_API_KEY="$CONTINUE_API_KEY" + if ! cn auth login --api-key "$CONTINUE_API_KEY"; then + echo "❌ Failed to authenticate with Continue CLI" + exit 1 + fi +fi + +echo "✅ Continue CLI authenticated" + +# Analyze with Continue CLI using structured format for easy parsing cat problem-sessions.json | cn -p " -Analyze these PostHog session recordings to identify user experience issues. +Analyze these PostHog session recordings and create exactly 3 GitHub issues for the most critical user experience problems. -Each session contains: -- duration: how long the session lasted (in seconds) -- start_url: the page where the user started -- click_count: total number of clicks -- console_error_count: JavaScript errors encountered +Session data format: +- duration: session length in seconds +- start_url: starting page URL +- click_count: total clicks in session +- console_error_count: JavaScript errors -Look for patterns that suggest code issues: +Format your response with EXACTLY 3 issues using this structure: -1. **High Error Sessions**: Sessions with console_error_count > 0 - - What pages/URLs are generating errors? - - Are users abandoning after errors occur? +### 1. **Issue Title Here** +**Problem**: One sentence describing the user problem +**Technical Causes**: Brief technical explanation +**Affected Pages**: List the URLs +**Recommended Fix**: +- Specific action item 1 +- Specific action item 2 +**Priority**: **HIGH** or **MEDIUM** or **LOW** +**Impact**: Quantify the impact (e.g., 'Affects 80% of sessions') -2. **Long Duration Sessions**: Sessions over 300 seconds (5+ minutes) - - Are users struggling to complete tasks? - - Low click count + high duration = user confusion +### 2. **Second Issue Title** +[Same format as above] -3. **Abandonment Patterns**: - - Users starting on key pages but not progressing - - Short sessions on important conversion pages +### 3. **Third Issue Title** +[Same format as above] -For each issue pattern you identify: -- Describe the user behavior problem -- Suggest likely technical causes (JS errors, slow loading, UI confusion) -- Recommend specific code areas to investigate -- Provide example fixes or improvements -- Priority: High (blocks user goals), Medium (hurts UX), Low (minor issue) +Base all issues on actual patterns in the provided session data. +" > analysis-results.txt 2>&1 -Focus on actionable technical improvements that will measurably improve user experience. -" +echo "✅ Analysis complete!" -echo "✅ Analysis complete! Check the output above for optimization opportunities." +# Display the analysis +echo "" +echo "📋 Analysis Results:" +echo "==================" +cat analysis-results.txt +echo "==================" ``` - +```bash Environment Check Script +#!/bin/bash +# check-requirements.sh - Verify all requirements are met +set -e -**What This Script Does:** +echo "🔍 Checking requirements..." -1. **Fetches** recent session recordings from - PostHog API -2. **Filters** for problematic sessions (errors or long durations) -3. **Analyzes** with Continue CLI to identify specific UX issues -4. **Provides** actionable technical recommendations +# Check Continue CLI +if ! command -v cn &> /dev/null; then + echo "❌ Continue CLI not found. Install with: npm i -g @continuedev/cli" + exit 1 +fi +echo "✅ Continue CLI installed" - +# Check GitHub CLI +if ! command -v gh &> /dev/null; then + echo "❌ GitHub CLI not found. Install from: https://cli.github.com/" + exit 1 +fi +echo "✅ GitHub CLI installed" -Make the script executable: +# Check jq +if ! command -v jq &> /dev/null; then + echo "❌ jq not found. Install with: brew install jq" + exit 1 +fi +echo "✅ jq installed" + +# Check Continue CLI auth +if ! cn auth status &> /dev/null; then + echo "âš ī¸ Continue CLI not authenticated" + echo "Run: cn auth login --api-key YOUR_API_KEY" +else + echo "✅ Continue CLI authenticated" +fi + +# Check GitHub CLI auth +if ! gh auth status &> /dev/null; then + echo "âš ī¸ GitHub CLI not authenticated" + echo "Run: gh auth login" +else + echo "✅ GitHub CLI authenticated" +fi + +# Check .env file +if [ ! -f .env ]; then + echo "âš ī¸ .env file not found" + echo "Create .env with required environment variables" +else + echo "✅ .env file exists" +fi + +echo "" +echo "🎉 Requirements check complete!" +``` + + + +Make the scripts executable: ```bash chmod +x analyze-sessions.sh +chmod +x check-requirements.sh + +# Test your requirements +./check-requirements.sh ``` ## Step 3: Automated GitHub Issue Creation @@ -225,170 +339,151 @@ Create a smart script that parses the AI analysis and automatically creates GitH This script automatically extracts issues from Continue CLI analysis, determines priority levels, assigns appropriate labels, and creates - well-formatted GitHub issues + well-formatted GitHub issues using GitHub CLI -```bash +```bash create-github-issues.sh #!/bin/bash -# create-github-issues.sh - Creates GitHub issues from Continue CLI analysis output +# create-github-issues.sh - Creates GitHub issues from Continue CLI analysis set -e -source .env -# Input file containing Continue CLI analysis output +# Load .env if it exists +if [ -f .env ]; then + source .env +fi + +# Input file ANALYSIS_FILE="analysis-results.txt" -# File to track created issues to prevent duplicates -ISSUE_TRACKING_FILE=".created_issues.json" +# Check requirements +if [ -z "$GITHUB_OWNER" ] || [ -z "$GITHUB_REPO" ]; then + echo "❌ Missing GITHUB_OWNER or GITHUB_REPO" + echo "These can be auto-detected from git remote or set in .env" + exit 1 +fi -# Check if analysis file exists if [ ! -f "$ANALYSIS_FILE" ]; then echo "❌ Analysis file not found: $ANALYSIS_FILE" + echo "Run analyze-sessions.sh first to generate analysis results" exit 1 fi -# Check if GitHub CLI is installed -if ! command -v gh &> /dev/null; then - echo "❌ GitHub CLI (gh) not found. Please install it first:" - echo " https://cli.github.com/manual/installation" +# Check GitHub CLI authentication +if ! gh auth status > /dev/null 2>&1; then + echo "❌ GitHub CLI not authenticated" + echo "Run: gh auth login" exit 1 fi -# Make sure gh is authenticated -if ! gh auth status &> /dev/null; then - echo "❌ GitHub CLI not authenticated. Please run 'gh auth login' first." - exit 1 -fi +echo "✅ GitHub CLI authenticated for $GITHUB_OWNER/$GITHUB_REPO" -# Create issue tracking file if it doesn't exist -if [ ! -f "$ISSUE_TRACKING_FILE" ]; then - echo "[]" > "$ISSUE_TRACKING_FILE" -fi - -# Function to check if an issue with this title already exists -issue_exists() { - local title="$1" - local issue_hash=$(echo "$title" | md5sum | cut -d' ' -f1) - - # Check in our tracking file - if grep -q "\"$issue_hash\"" "$ISSUE_TRACKING_FILE"; then - return 0 # Issue exists - fi - - # Also check actual GitHub issues to be doubly sure - if gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --search "$title in:title" --json title | grep -q "$title"; then - # Add to tracking file if found on GitHub but not in our tracking - local tracking_data=$(cat "$ISSUE_TRACKING_FILE") - echo "$tracking_data" | jq --arg hash "$issue_hash" '. += [$hash]' > "$ISSUE_TRACKING_FILE" - return 0 # Issue exists - fi - - return 1 # Issue doesn't exist -} - -# Function to record that we created an issue -record_issue() { - local title="$1" - local issue_hash=$(echo "$title" | md5sum | cut -d' ' -f1) - - local tracking_data=$(cat "$ISSUE_TRACKING_FILE") - echo "$tracking_data" | jq --arg hash "$issue_hash" '. += [$hash]' > "$ISSUE_TRACKING_FILE" -} - -# Function to create a GitHub issue using GitHub CLI +# Function to create GitHub issue using GitHub CLI create_github_issue() { local title="$1" local body="$2" local labels="$3" - # Check if this issue already exists - if issue_exists "$title"; then - echo "â„šī¸ Issue already exists: $title" + echo " Creating issue: $title" + + # Check if issue with similar title already exists + existing_issues=$(gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" \ + --search "$title in:title" --json title,state --limit 5) + + if echo "$existing_issues" | jq -r '.[].title' | grep -q "$title" 2>/dev/null; then + echo " â„šī¸ Issue with similar title already exists, skipping" return 0 fi - echo "Creating issue: $title" - - # Convert labels from JSON array format to comma-separated list - # Remove brackets, quotes, and add commas - labels_list=$(echo $labels | sed 's/\[//g' | sed 's/\]//g' | sed 's/"//g' | sed 's/,/,/g') - - # Create issue using GitHub CLI - issue_url=$(gh issue create \ + # Create the issue + if issue_url=$(gh issue create \ --repo "$GITHUB_OWNER/$GITHUB_REPO" \ - --title "$title" \ + --title "🔍 UX Issue: $title" \ --body "$body" \ - --label "$labels_list" \ - --web) - - if [ $? -eq 0 ]; then - echo "✅ Created issue: $issue_url" - # Record that we created this issue - record_issue "$title" + --label "$labels"); then + echo " ✅ Created: $issue_url" + return 0 else - echo "❌ Failed to create issue" + echo " ❌ Failed to create issue" + return 1 fi } -# Extract and parse issues from analysis output +# Parse and create issues echo "🔍 Parsing analysis results for issues..." -# Count the issues in the file by looking for ## Issue pattern -issue_count=$(grep -c "^## Issue" "$ANALYSIS_FILE" || echo 0) +issues_created=0 +current_title="" +current_body="" +current_priority="" -if [ "$issue_count" -eq 0 ]; then - echo "â„šī¸ No issues found in analysis output." - exit 0 -fi +# Process the analysis file looking for structured issues +while IFS= read -r line || [ -n "$line" ]; do + # Check for issue header pattern: ### N. **Title** + if [[ $line =~ ^###\ [0-9]+\.\ \*\*(.+)\*\* ]]; then + # Create previous issue if exists + if [ -n "$current_title" ] && [ -n "$current_body" ]; then + # Determine labels based on priority + case "$current_priority" in + "HIGH") + labels="bug,high-priority,user-experience,automated" + ;; + "MEDIUM") + labels="enhancement,medium-priority,user-experience,automated" + ;; + *) + labels="low-priority,user-experience,automated" + ;; + esac -echo "📊 Found $issue_count potential issues to process" - -# Process each issue section -while IFS= read -r line || [[ -n "$line" ]]; do - if [[ $line =~ ^## ]]; then - # If we have a previous issue, create it - if [ -n "${issue_title:-}" ] && [ -n "${issue_body:-}" ]; then - # Determine appropriate labels based on priority in the issue body - if [[ "$issue_body" =~ "High Priority" ]]; then - labels="[\"bug\", \"high-priority\", \"user-experience\"]" - elif [[ "$issue_body" =~ "Medium Priority" ]]; then - labels="[\"enhancement\", \"medium-priority\", \"user-experience\"]" - else - labels="[\"low-priority\", \"user-experience\"]" + if create_github_issue "$current_title" "$current_body" "$labels"; then + ((issues_created++)) fi - - # Create the issue - create_github_issue "$issue_title" "$issue_body" "$labels" fi - # Start a new issue - issue_title="UX Issue: ${line#\#\# Issue }" - issue_body="" - elif [ -n "${issue_title:-}" ]; then - # Add line to current issue body - if [ -n "$issue_body" ]; then - issue_body="$issue_body\n$line" - else - issue_body="$line" - fi - fi -done < <(sed -n '/^## Issue/,/^## Issue\|^$/p' "$ANALYSIS_FILE") - -# Create the last issue if there is one -if [ -n "${issue_title:-}" ] && [ -n "${issue_body:-}" ]; then - # Determine appropriate labels based on priority in the issue body - if [[ "$issue_body" =~ "High Priority" ]]; then - labels="[\"bug\", \"high-priority\", \"user-experience\"]" - elif [[ "$issue_body" =~ "Medium Priority" ]]; then - labels="[\"enhancement\", \"medium-priority\", \"user-experience\"]" + # Start new issue + current_title="${BASH_REMATCH[1]}" + current_body="" + current_priority="" else - labels="[\"low-priority\", \"user-experience\"]" + # Part of current issue body + if [ -n "$current_title" ]; then + # Extract priority if found + if [[ $line =~ \*\*Priority\*\*:\ \*\*(HIGH|MEDIUM|LOW)\*\* ]]; then + current_priority="${BASH_REMATCH[1]}" + fi + current_body="${current_body}${line}"$'\n' + fi fi +done < "$ANALYSIS_FILE" - # Create the issue - create_github_issue "$issue_title" "$issue_body" "$labels" +# Create last issue +if [ -n "$current_title" ] && [ -n "$current_body" ]; then + case "$current_priority" in + "HIGH") + labels="bug,high-priority,user-experience,automated" + ;; + "MEDIUM") + labels="enhancement,medium-priority,user-experience,automated" + ;; + *) + labels="low-priority,user-experience,automated" + ;; + esac + + if create_github_issue "$current_title" "$current_body" "$labels"; then + ((issues_created++)) + fi fi -echo "✅ GitHub issues creation process completed!" +echo "✅ GitHub issues creation complete!" +echo "📊 Created $issues_created issue(s)" + +# Show created issues +if [ $issues_created -gt 0 ]; then + echo "" + echo "📋 Recent automated issues:" + gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --label "automated" --limit 5 +fi ``` Make it executable: @@ -397,38 +492,101 @@ Make it executable: chmod +x create-github-issues.sh ``` - - **Smart Label Assignment**: The script automatically assigns labels based on - issue priority: - - **High Priority** → `bug`, `high-priority`, - `user-experience` - - **Medium Priority** → `enhancement`, `medium-priority`, - `user-experience` - - **Low Priority** → `low-priority`, `user-experience` + +**Repository Labels Required**: The script uses these labels which must exist in your GitHub repository: +- `bug`, `enhancement` +- `high-priority`, `medium-priority`, `low-priority` +- `user-experience`, `automated` -**Be sure to customize the label logic** in the script to match your -repository's labeling conventions! +Create missing labels in your repo at: **Settings → Labels → New label** or edit the `labels=` lines in the script to match your repository's existing label system. - + ## Step 4: Complete Automated Workflow Create the main orchestration script that runs the entire process: -```bash +```bash daily-analysis.sh #!/bin/bash -# daily-analysis.sh +# daily-analysis.sh - Main entry point for PostHog analysis and GitHub issue creation set -e -echo "🔍 Starting daily PostHog session analysis..." +# Load .env for local development +if [ -f .env ]; then + echo "🔧 Loading .env file for local development..." + source .env +fi -# Run the session analysis -./analyze-sessions.sh > analysis-results.txt +# Detect environment +if [ -n "$GITHUB_ACTIONS" ]; then + echo "🚀 Running in GitHub Actions" + export GITHUB_OWNER="${GITHUB_REPOSITORY_OWNER}" + export GITHUB_REPO="${GITHUB_REPOSITORY##*/}" +else + echo "đŸ’ģ Running locally" -# Create GitHub issues based on the analysis -./create-github-issues.sh + # Auto-detect from git if not set + if [ -z "$GITHUB_OWNER" ] || [ -z "$GITHUB_REPO" ]; then + if git remote get-url origin > /dev/null 2>&1; then + REMOTE_URL=$(git remote get-url origin) + if [[ $REMOTE_URL =~ github.com[:/]([^/]+)/([^/.]+)(\.git)?$ ]]; then + export GITHUB_OWNER="${BASH_REMATCH[1]}" + export GITHUB_REPO="${BASH_REMATCH[2]}" + echo "📍 Auto-detected: $GITHUB_OWNER/$GITHUB_REPO" + fi + fi + fi +fi + +# Validate required environment variables +MISSING_VARS=() +[ -z "$CONTINUE_API_KEY" ] && MISSING_VARS+=("CONTINUE_API_KEY") +[ -z "$POSTHOG_API_KEY" ] && MISSING_VARS+=("POSTHOG_API_KEY") +[ -z "$POSTHOG_PROJECT_ID" ] && MISSING_VARS+=("POSTHOG_PROJECT_ID") +[ -z "$POSTHOG_HOST" ] && MISSING_VARS+=("POSTHOG_HOST") +[ -z "$GITHUB_OWNER" ] && MISSING_VARS+=("GITHUB_OWNER") +[ -z "$GITHUB_REPO" ] && MISSING_VARS+=("GITHUB_REPO") + +if [ ${#MISSING_VARS[@]} -ne 0 ]; then + echo "❌ Missing required environment variables:" + for var in "${MISSING_VARS[@]}"; do + echo " - $var" + done + exit 1 +fi + +# Check GitHub CLI authentication +if ! gh auth status > /dev/null 2>&1; then + echo "❌ GitHub CLI not authenticated" + echo "Run: gh auth login" + exit 1 +fi + +echo "✅ GitHub CLI authenticated" + +# Determine script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Run the analysis +echo "đŸŽŦ Running PostHog session analysis..." +if ! bash "$SCRIPT_DIR/analyze-sessions.sh"; then + echo "❌ Analysis failed" + exit 1 +fi + +# Create GitHub issues +echo "📝 Creating GitHub issues from analysis..." +if ! bash "$SCRIPT_DIR/create-github-issues.sh"; then + echo "❌ Issue creation failed" + exit 1 +fi echo "✅ Daily analysis complete!" + +# Show created issues +echo "" +echo "📊 Recent issues in $GITHUB_OWNER/$GITHUB_REPO:" +gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --limit 5 --label "automated" ``` Make it executable and test: @@ -442,7 +600,17 @@ chmod +x daily-analysis.sh - Perfect for teams already using GitHub workflows: + Perfect for teams already using GitHub workflows. + + **Required GitHub Secrets:** + + - `CONTINUE_API_KEY`: Your Continue API key from hub.continue.dev + - `POSTHOG_API_KEY`: Your PostHog Personal API Key + - `POSTHOG_PROJECT_ID`: Your PostHog Project ID + +Add these in: **Repository Settings → Secrets and variables → Actions** + + Create `.github/workflows/daily-analysis.yml`: @@ -457,36 +625,49 @@ on: jobs: analyze: runs-on: ubuntu-latest + + permissions: + contents: read + issues: write + steps: - uses: actions/checkout@v3 + with: + # Deploy key is REQUIRED for Continue CLI integration + ssh-key: ${{ secrets.CONTINUE_DEPLOY_KEY }} - name: Set up environment run: | - echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> .env - echo "POSTHOG_PROJECT_ID=${{ secrets.POSTHOG_PROJECT_ID }}" >> .env - echo "POSTHOG_HOST=https://us.posthog.com" >> .env - echo "GITHUB_PERSONAL_ACCESS_TOKEN=${{ secrets.GH_PAT }}" >> .env - echo "GITHUB_OWNER=${{ github.repository_owner }}" >> .env - echo "GITHUB_REPO=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> .env + # Export environment variables for the entire job + echo "CONTINUE_API_KEY=${{ secrets.CONTINUE_API_KEY }}" >> $GITHUB_ENV + echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> $GITHUB_ENV + echo "POSTHOG_PROJECT_ID=${{ secrets.POSTHOG_PROJECT_ID }}" >> $GITHUB_ENV + echo "POSTHOG_HOST=${{ secrets.POSTHOG_HOST || 'https://us.posthog.com' }}" >> $GITHUB_ENV + echo "GH_PAT=${{ secrets.GH_PAT }}" >> $GITHUB_ENV + echo "GITHUB_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV + echo "GITHUB_REPO=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y jq curl + # Install Continue CLI for AI analysis npm install -g @continuedev/cli + # GitHub CLI is pre-installed on GitHub-hosted runners - - name: Run analysis - run: ./daily-analysis.sh + - name: Make scripts executable + run: | + chmod +x ./posthog-continuous-ai/daily-analysis.sh + chmod +x ./posthog-continuous-ai/analyze-sessions.sh + chmod +x ./posthog-continuous-ai/create-github-issues.sh + + - name: Run analysis and create issues + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GH_TOKEN: ${{ secrets.GH_PAT }} + run: ./posthog-continuous-ai/daily-analysis.sh ``` -**Required GitHub Secrets:** - - - `POSTHOG_API_KEY`: Your PostHog Personal API Key - - `POSTHOG_PROJECT_ID`: Your PostHog Project ID - - `GH_PAT`: Your GitHub Personal Access Token - - Add these in: Repository Settings → Secrets and variables → Actions - @@ -497,11 +678,6 @@ jobs: 0 6 * * * cd /path/to/your/project && ./daily-analysis.sh >> ~/logs/analysis.log 2>&1 ``` - **Benefits:** - - Full control over execution environment - - No GitHub Actions usage limits - - Can run more frequently if needed - @@ -524,17 +700,7 @@ jobs: ## Step 6: Testing Your Workflow - - - ```bash # Test PostHog API curl -H "Authorization: Bearer $POSTHOG_API_KEY" - \ - "$POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=1" - # Test GitHub API curl -H "Authorization: token - $GITHUB_PERSONAL_ACCESS_TOKEN" \ - "https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO" - ``` - - + ```bash ./analyze-sessions.sh ``` Expected: JSON files with session data and AI analysis output @@ -571,9 +737,10 @@ After completing this guide, you have a complete **Continuous AI system** that: ✅ **Scales with your team** - Handles growing amounts of session data automatically - Your system now operates at **Level 2 Continuous AI** - AI handles routine - analysis tasks with human oversight through GitHub issue review and - prioritization. + Your system now operates at **[Level 2 Continuous + AI](https://blog.continue.dev/what-is-continuous-ai-a-developers-guide/)** - + AI handles routine analysis tasks with human oversight through GitHub issue + review and prioritization. ## Security Best Practices From a705b3e21f6a314ae6426bee4645449a30bfa08a Mon Sep 17 00:00:00 2001 From: BekahHW Date: Mon, 15 Sep 2025 13:02:56 -0400 Subject: [PATCH 15/16] Fix merge conflicts for docs.json --- docs/docs.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/docs.json b/docs/docs.json index 28e12b2b9..0196cbc82 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -233,11 +233,8 @@ "guides/codebase-documentation-awareness", "guides/cli", "guides/continuous-ai", -<<<<<<< HEAD "guides/posthog-github-continuous-ai", -======= "guides/continuous-ai-readiness-assessment", ->>>>>>> main "guides/plan-mode-guide", "guides/ollama-guide", "guides/instinct", From 60ce544158c94f53b1029410d25c8851ee8e434d Mon Sep 17 00:00:00 2001 From: BekahHW Date: Mon, 15 Sep 2025 17:30:47 -0400 Subject: [PATCH 16/16] Change guide approach --- docs/guides/posthog-github-continuous-ai.mdx | 914 +++++++------------ 1 file changed, 312 insertions(+), 602 deletions(-) diff --git a/docs/guides/posthog-github-continuous-ai.mdx b/docs/guides/posthog-github-continuous-ai.mdx index 4a51c27b7..1127f8166 100644 --- a/docs/guides/posthog-github-continuous-ai.mdx +++ b/docs/guides/posthog-github-continuous-ai.mdx @@ -1,13 +1,13 @@ --- title: "Building a Continuous AI Workflow with PostHog and GitHub" -description: "This guide shows you how to build an automated system that continuously monitors PostHog session recordings, analyzes user experience issues using AI, and automatically creates GitHub issues for your development team to address." +description: "Build an automated system that continuously monitors PostHog session recordings, analyzes UX issues using Continue CLI, and creates GitHub issues automatically." sidebarTitle: "PostHog Session Analysis with Continue CLI" --- - A fully automated workflow that fetches PostHog session data, uses Continue - CLI to identify UX problems, and creates GitHub issues with specific technical - recommendations + A fully automated workflow that uses Continue CLI to fetch PostHog session + data, analyze user experience issues with AI, and automatically create GitHub + issues with specific technical recommendations ## Prerequisites @@ -32,30 +32,22 @@ Before starting, ensure you have: 3. Navigate to your organization settings 4. Click **"API Keys"** and then **"+ New API Key"** 5. Copy the API key immediately (you won't see it again!) - 6. Login to the CLI with `cn login` + 6. Login to the CLI: `cn login` - - ```bash - # macOS - brew install gh - # Ubuntu/Debian - sudo apt install gh - # Windows - winget install --id GitHub.cli - ``` - - Then authenticate: `gh auth login` - - - - Get your Personal API Key from PostHog settings + + Continue CLI will securely store your API keys as secrets that can be referenced in prompts. -Now you're ready to start building your workflow! + + Continue CLI handles all the complex API interactions - you just need to + provide the right prompts! + -## Step 1: Environment Setup +## Step 1: Set Up Your Credentials + +First, you'll need to gather your API credentials and add them as secrets in Continue CLI. ### Get Your PostHog API Credentials @@ -69,172 +61,75 @@ You need a **Personal API Key** (not a Project API key) to access session record - `insight:read` - Optional, for additional analytics 5. Copy the key immediately (you won't see it again!) -### Set Up Your Environment Variables - - - -```bash Environment Setup -# Create working directory -mkdir posthog-continuous-ai -cd posthog-continuous-ai - -# Create environment file -cat > .env << EOF -# Continue CLI Configuration (REQUIRED) -CONTINUE_API_KEY=your_continue_api_key_here - -# PostHog Configuration -POSTHOG_API_KEY=your_personal_api_key_here -POSTHOG_PROJECT_ID=your_project_id_here -POSTHOG_HOST=https://us.posthog.com - -# GitHub Configuration (auto-detected from git, or set manually) -GITHUB_OWNER=YourUsername -GITHUB_REPO=your-repository-name -EOF - -# Load environment -source .env -``` - -```bash Security Setup -# Protect sensitive files -cat > .gitignore << EOF -# Environment variables - contains API keys -.env -.env.local - -# Continue CLI authentication -.continue/ - -# Generated data files -*.json -analysis-results.txt -daily-analysis.log -.created_issues.json - -# Temporary files -*.tmp -/tmp/ -EOF -``` - - - - - **Auto-Detection**: The scripts can automatically detect your GitHub owner and - repo from your git remote origin URL. Manual configuration in `.env` overrides - auto-detection. - - **Find Your Project Details**: Your Project ID is in your PostHog URL: `https://app.posthog.com/project/YOUR_PROJECT_ID` -### GitHub CLI Setup +### Get Your GitHub Personal Access Token - - GitHub CLI provides secure authentication without needing to manage Personal - Access Tokens in your environment files. - +1. Go to [GitHub Personal Access Tokens](https://github.com/settings/personal-access-tokens/new) +2. Click **"Generate new token (classic)"** +3. Name it "Continue CLI PostHog Analysis" +4. Select these scopes: + - `repo` (or just `public_repo` if your repository is public) + - `issues:write` - **Required** for creating issues +5. Copy the token immediately -**Verify GitHub CLI is ready:** +### Add Secrets to Continue CLI + +Use Continue CLI's built-in environment setup helper: ```bash -# Check if GitHub CLI is installed -gh --version - -# Check authentication status -gh auth status - -# If not authenticated, login -gh auth login +cn -p "Help me set up my environment for PostHog session analysis. Please: +1. Check if I have the required secrets configured in Continue CLI: + - POSTHOG_API_KEY + - POSTHOG_PROJECT_ID + - POSTHOG_HOST + - GITHUB_PAT +2. If any are missing, guide me through: + - How to get PostHog Personal API Key from PostHog settings + - How to find my PostHog Project ID from the URL + - How to create a GitHub Personal Access Token with issues:write permission + - How to add these as secrets in Continue CLI +3. Help me identify my GitHub repository owner and name by: + - Checking git remote origin URL + - Or asking me to provide them +4. Test the API connections by making a simple API call to both PostHog and GitHub to verify the credentials work. +Please walk me through this setup process step by step." ``` -## Step 2: Session Analysis Script - -Create the main analysis script that fetches PostHog session recordings, filters for problematic sessions, and uses Continue CLI to analyze them. - - **How It Works:** - - **Fetches** recent session recordings from PostHog API - - **Filters** for problematic sessions (errors or long durations) - - **Authenticates** with Continue CLI using your API key - - **Analyzes** session data and generates exactly 3 structured GitHub issues - + Continue CLI will guide you through adding secrets and testing your API + connections. Follow the prompts to add: - `POSTHOG_API_KEY`: Your PostHog + Personal API Key - `POSTHOG_PROJECT_ID`: Your PostHog Project ID - + `POSTHOG_HOST`: `https://us.posthog.com` (or your custom PostHog host) - + `GITHUB_PAT`: Your GitHub Personal Access Token - +## Step 2: Analyze PostHog Sessions with Continue CLI -```bash analyze-sessions.sh -#!/bin/bash -# analyze-sessions.sh - Fetches PostHog sessions and analyzes them with Continue CLI -set -e +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. -# Load .env if it exists -if [ -f .env ]; then - source .env -fi +### Run the Analysis -# Check for required environment variables -if [ -z "$POSTHOG_API_KEY" ] || [ -z "$POSTHOG_PROJECT_ID" ] || [ -z "$POSTHOG_HOST" ]; then - echo "❌ Missing required PostHog environment variables" - exit 1 -fi +Use this prompt with Continue CLI to fetch and analyze your PostHog sessions: -if [ -z "$CONTINUE_API_KEY" ]; then - echo "❌ Missing CONTINUE_API_KEY environment variable" - echo "Get your API key from: https://hub.continue.dev/settings/organizations" - exit 1 -fi +```bash +cn -p "I need you to help me analyze PostHog session recordings to identify UX issues. Please: -echo "đŸŽŦ Fetching session recordings from PostHog..." +1. First, fetch session recordings from PostHog using these details: + - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from my secrets + - API endpoint: {POSTHOG_HOST}/api/projects/{POSTHOG_PROJECT_ID}/session_recordings/?limit=20 + - Include Authorization header: 'Bearer {POSTHOG_API_KEY}' -# Fetch recent session recordings -curl -s -H "Authorization: Bearer $POSTHOG_API_KEY" \ - "$POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=20" \ - | jq '.results[] | { - id: .id, - duration: .recording_duration, - start_url: .start_url, - click_count: .click_count, - console_error_count: .console_error_count, - person_distinct_id: .person.distinct_ids[0], - start_time: .start_time - }' > sessions.json +2. Filter the sessions to find problematic ones with either: + - console_error_count > 0 (JavaScript errors) + - recording_duration > 300 (sessions longer than 5 minutes) -echo "📊 Found $(cat sessions.json | jq -s length) sessions" - -# Filter for problematic sessions -cat sessions.json | jq -s 'map(select(.console_error_count > 0 or .recording_duration > 300))' > problem-sessions.json - -echo "🚨 Found $(cat problem-sessions.json | jq length) problematic sessions" - -# Verify Continue CLI authentication -if ! cn auth status > /dev/null 2>&1; then - echo "🔑 Continue CLI not authenticated, attempting login..." - export CONTINUE_API_KEY="$CONTINUE_API_KEY" - if ! cn auth login --api-key "$CONTINUE_API_KEY"; then - echo "❌ Failed to authenticate with Continue CLI" - exit 1 - fi -fi - -echo "✅ Continue CLI authenticated" - -# Analyze with Continue CLI using structured format for easy parsing -cat problem-sessions.json | cn -p " -Analyze these PostHog session recordings and create exactly 3 GitHub issues for the most critical user experience problems. - -Session data format: -- duration: session length in seconds -- start_url: starting page URL -- click_count: total clicks in session -- console_error_count: JavaScript errors - -Format your response with EXACTLY 3 issues using this structure: +3. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems. +4. Format each issue like this: ### 1. **Issue Title Here** **Problem**: One sentence describing the user problem **Technical Causes**: Brief technical explanation @@ -245,377 +140,88 @@ Format your response with EXACTLY 3 issues using this structure: **Priority**: **HIGH** or **MEDIUM** or **LOW** **Impact**: Quantify the impact (e.g., 'Affects 80% of sessions') -### 2. **Second Issue Title** -[Same format as above] - -### 3. **Third Issue Title** -[Same format as above] - -Base all issues on actual patterns in the provided session data. -" > analysis-results.txt 2>&1 - -echo "✅ Analysis complete!" - -# Display the analysis -echo "" -echo "📋 Analysis Results:" -echo "==================" -cat analysis-results.txt -echo "==================" +Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data." ``` -```bash Environment Check Script -#!/bin/bash -# check-requirements.sh - Verify all requirements are met -set -e + + **What Continue CLI Does:** - Makes authenticated API calls to PostHog using + your stored secrets - Fetches and filters session recordings automatically - + Analyzes patterns in the data using AI - Generates structured issue + descriptions ready for GitHub + -echo "🔍 Checking requirements..." + + Save the analysis output to a file by adding `> analysis-results.txt` to the + command if you want to review it later. + -# Check Continue CLI -if ! command -v cn &> /dev/null; then - echo "❌ Continue CLI not found. Install with: npm i -g @continuedev/cli" - exit 1 -fi -echo "✅ Continue CLI installed" +## Step 3: Create GitHub Issues Automatically -# Check GitHub CLI -if ! command -v gh &> /dev/null; then - echo "❌ GitHub CLI not found. Install from: https://cli.github.com/" - exit 1 -fi -echo "✅ GitHub CLI installed" - -# Check jq -if ! command -v jq &> /dev/null; then - echo "❌ jq not found. Install with: brew install jq" - exit 1 -fi -echo "✅ jq installed" - -# Check Continue CLI auth -if ! cn auth status &> /dev/null; then - echo "âš ī¸ Continue CLI not authenticated" - echo "Run: cn auth login --api-key YOUR_API_KEY" -else - echo "✅ Continue CLI authenticated" -fi - -# Check GitHub CLI auth -if ! gh auth status &> /dev/null; then - echo "âš ī¸ GitHub CLI not authenticated" - echo "Run: gh auth login" -else - echo "✅ GitHub CLI authenticated" -fi - -# Check .env file -if [ ! -f .env ]; then - echo "âš ī¸ .env file not found" - echo "Create .env with required environment variables" -else - echo "✅ .env file exists" -fi - -echo "" -echo "🎉 Requirements check complete!" -``` - - - -Make the scripts executable: +Now use Continue CLI to create GitHub issues from your analysis results: ```bash -chmod +x analyze-sessions.sh -chmod +x check-requirements.sh +cn -p "I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API. -# Test your requirements -./check-requirements.sh -``` +Use these details from my secrets: +- GITHUB_PAT: My GitHub Personal Access Token +- Repository: Extract from git remote or ask me to specify -## Step 3: Automated GitHub Issue Creation +For each issue in my analysis: +1. Parse the issue title, body content, and priority level +2. Create a GitHub issue via API POST to: https://api.github.com/repos/{owner}/{repo}/issues +3. Use these headers: + - Authorization: token {GITHUB_PAT} + - Accept: application/vnd.github.v3+json + - Content-Type: application/json +4. Set labels based on priority: + - HIGH: [\"bug\", \"high-priority\", \"user-experience\", \"automated\"] + - MEDIUM: [\"enhancement\", \"medium-priority\", \"user-experience\", \"automated\"] + - LOW: [\"low-priority\", \"user-experience\", \"automated\"] +5. Format the issue title as: \"🔍 UX Issue: {original title}\" -Create a smart script that parses the AI analysis and automatically creates GitHub issues: - - - This script automatically extracts issues from Continue CLI analysis, - determines priority levels, assigns appropriate labels, and creates - well-formatted GitHub issues using GitHub CLI - - -```bash create-github-issues.sh -#!/bin/bash -# create-github-issues.sh - Creates GitHub issues from Continue CLI analysis -set -e - -# Load .env if it exists -if [ -f .env ]; then - source .env -fi - -# Input file -ANALYSIS_FILE="analysis-results.txt" - -# Check requirements -if [ -z "$GITHUB_OWNER" ] || [ -z "$GITHUB_REPO" ]; then - echo "❌ Missing GITHUB_OWNER or GITHUB_REPO" - echo "These can be auto-detected from git remote or set in .env" - exit 1 -fi - -if [ ! -f "$ANALYSIS_FILE" ]; then - echo "❌ Analysis file not found: $ANALYSIS_FILE" - echo "Run analyze-sessions.sh first to generate analysis results" - exit 1 -fi - -# Check GitHub CLI authentication -if ! gh auth status > /dev/null 2>&1; then - echo "❌ GitHub CLI not authenticated" - echo "Run: gh auth login" - exit 1 -fi - -echo "✅ GitHub CLI authenticated for $GITHUB_OWNER/$GITHUB_REPO" - -# Function to create GitHub issue using GitHub CLI -create_github_issue() { - local title="$1" - local body="$2" - local labels="$3" - - echo " Creating issue: $title" - - # Check if issue with similar title already exists - existing_issues=$(gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" \ - --search "$title in:title" --json title,state --limit 5) - - if echo "$existing_issues" | jq -r '.[].title' | grep -q "$title" 2>/dev/null; then - echo " â„šī¸ Issue with similar title already exists, skipping" - return 0 - fi - - # Create the issue - if issue_url=$(gh issue create \ - --repo "$GITHUB_OWNER/$GITHUB_REPO" \ - --title "🔍 UX Issue: $title" \ - --body "$body" \ - --label "$labels"); then - echo " ✅ Created: $issue_url" - return 0 - else - echo " ❌ Failed to create issue" - return 1 - fi -} - -# Parse and create issues -echo "🔍 Parsing analysis results for issues..." - -issues_created=0 -current_title="" -current_body="" -current_priority="" - -# Process the analysis file looking for structured issues -while IFS= read -r line || [ -n "$line" ]; do - # Check for issue header pattern: ### N. **Title** - if [[ $line =~ ^###\ [0-9]+\.\ \*\*(.+)\*\* ]]; then - # Create previous issue if exists - if [ -n "$current_title" ] && [ -n "$current_body" ]; then - # Determine labels based on priority - case "$current_priority" in - "HIGH") - labels="bug,high-priority,user-experience,automated" - ;; - "MEDIUM") - labels="enhancement,medium-priority,user-experience,automated" - ;; - *) - labels="low-priority,user-experience,automated" - ;; - esac - - if create_github_issue "$current_title" "$current_body" "$labels"; then - ((issues_created++)) - fi - fi - - # Start new issue - current_title="${BASH_REMATCH[1]}" - current_body="" - current_priority="" - else - # Part of current issue body - if [ -n "$current_title" ]; then - # Extract priority if found - if [[ $line =~ \*\*Priority\*\*:\ \*\*(HIGH|MEDIUM|LOW)\*\* ]]; then - current_priority="${BASH_REMATCH[1]}" - fi - current_body="${current_body}${line}"$'\n' - fi - fi -done < "$ANALYSIS_FILE" - -# Create last issue -if [ -n "$current_title" ] && [ -n "$current_body" ]; then - case "$current_priority" in - "HIGH") - labels="bug,high-priority,user-experience,automated" - ;; - "MEDIUM") - labels="enhancement,medium-priority,user-experience,automated" - ;; - *) - labels="low-priority,user-experience,automated" - ;; - esac - - if create_github_issue "$current_title" "$current_body" "$labels"; then - ((issues_created++)) - fi -fi - -echo "✅ GitHub issues creation complete!" -echo "📊 Created $issues_created issue(s)" - -# Show created issues -if [ $issues_created -gt 0 ]; then - echo "" - echo "📋 Recent automated issues:" - gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --label "automated" --limit 5 -fi -``` - -Make it executable: - -```bash -chmod +x create-github-issues.sh +Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs. +" ``` -**Repository Labels Required**: The script uses these labels which must exist in your GitHub repository: +**Repository Labels Required**: Make sure your GitHub repository has these labels: - `bug`, `enhancement` - `high-priority`, `medium-priority`, `low-priority` - `user-experience`, `automated` -Create missing labels in your repo at: **Settings → Labels → New label** or edit the `labels=` lines in the script to match your repository's existing label system. +Create missing labels in your repo at: **Settings → Labels → New label** -## Step 4: Complete Automated Workflow - -Create the main orchestration script that runs the entire process: - -```bash daily-analysis.sh -#!/bin/bash -# daily-analysis.sh - Main entry point for PostHog analysis and GitHub issue creation -set -e - -# Load .env for local development -if [ -f .env ]; then - echo "🔧 Loading .env file for local development..." - source .env -fi - -# Detect environment -if [ -n "$GITHUB_ACTIONS" ]; then - echo "🚀 Running in GitHub Actions" - export GITHUB_OWNER="${GITHUB_REPOSITORY_OWNER}" - export GITHUB_REPO="${GITHUB_REPOSITORY##*/}" -else - echo "đŸ’ģ Running locally" - - # Auto-detect from git if not set - if [ -z "$GITHUB_OWNER" ] || [ -z "$GITHUB_REPO" ]; then - if git remote get-url origin > /dev/null 2>&1; then - REMOTE_URL=$(git remote get-url origin) - if [[ $REMOTE_URL =~ github.com[:/]([^/]+)/([^/.]+)(\.git)?$ ]]; then - export GITHUB_OWNER="${BASH_REMATCH[1]}" - export GITHUB_REPO="${BASH_REMATCH[2]}" - echo "📍 Auto-detected: $GITHUB_OWNER/$GITHUB_REPO" - fi - fi - fi -fi - -# Validate required environment variables -MISSING_VARS=() -[ -z "$CONTINUE_API_KEY" ] && MISSING_VARS+=("CONTINUE_API_KEY") -[ -z "$POSTHOG_API_KEY" ] && MISSING_VARS+=("POSTHOG_API_KEY") -[ -z "$POSTHOG_PROJECT_ID" ] && MISSING_VARS+=("POSTHOG_PROJECT_ID") -[ -z "$POSTHOG_HOST" ] && MISSING_VARS+=("POSTHOG_HOST") -[ -z "$GITHUB_OWNER" ] && MISSING_VARS+=("GITHUB_OWNER") -[ -z "$GITHUB_REPO" ] && MISSING_VARS+=("GITHUB_REPO") - -if [ ${#MISSING_VARS[@]} -ne 0 ]; then - echo "❌ Missing required environment variables:" - for var in "${MISSING_VARS[@]}"; do - echo " - $var" - done - exit 1 -fi - -# Check GitHub CLI authentication -if ! gh auth status > /dev/null 2>&1; then - echo "❌ GitHub CLI not authenticated" - echo "Run: gh auth login" - exit 1 -fi - -echo "✅ GitHub CLI authenticated" - -# Determine script directory -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# Run the analysis -echo "đŸŽŦ Running PostHog session analysis..." -if ! bash "$SCRIPT_DIR/analyze-sessions.sh"; then - echo "❌ Analysis failed" - exit 1 -fi - -# Create GitHub issues -echo "📝 Creating GitHub issues from analysis..." -if ! bash "$SCRIPT_DIR/create-github-issues.sh"; then - echo "❌ Issue creation failed" - exit 1 -fi - -echo "✅ Daily analysis complete!" - -# Show created issues -echo "" -echo "📊 Recent issues in $GITHUB_OWNER/$GITHUB_REPO:" -gh issue list --repo "$GITHUB_OWNER/$GITHUB_REPO" --limit 5 --label "automated" -``` - -Make it executable and test: - -```bash -chmod +x daily-analysis.sh -./daily-analysis.sh -``` - -## Step 5: Automation Options - - - - Perfect for teams already using GitHub workflows. - **Required GitHub Secrets:** - - - `CONTINUE_API_KEY`: Your Continue API key from hub.continue.dev - - `POSTHOG_API_KEY`: Your PostHog Personal API Key - - `POSTHOG_PROJECT_ID`: Your PostHog Project ID - -Add these in: **Repository Settings → Secrets and variables → Actions** - + **What Continue CLI Does:** - Parses your analysis results automatically - + Makes authenticated GitHub API calls using your stored token - Creates + properly formatted issues with appropriate labels - Checks for duplicate + issues to avoid spam - Provides confirmation with issue URLs - Create `.github/workflows/daily-analysis.yml`: +## Step 4: Set Up Automated GitHub Actions Workflow + +Create a GitHub Actions workflow that runs your Continue CLI analysis automatically on a schedule. + +### Add GitHub Secrets + +First, add these secrets to your GitHub repository: + +1. Go to **Repository Settings → Secrets and variables → Actions** +2. Click **"New repository secret"** and add: + - `CONTINUE_API_KEY`: Your Continue API key from hub.continue.dev + - `POSTHOG_API_KEY`: Your PostHog Personal API Key + - `POSTHOG_PROJECT_ID`: Your PostHog Project ID + - `POSTHOG_HOST`: `https://us.posthog.com` (or your custom PostHog host) + - `GITHUB_PAT`: Your GitHub Personal Access Token + +### Create GitHub Actions Workflow + +Create `.github/workflows/posthog-analysis.yml` in your repository: ```yaml -name: Daily Session Analysis +name: PostHog Session Analysis with Continue CLI on: schedule: @@ -631,101 +237,208 @@ jobs: issues: write steps: - - uses: actions/checkout@v3 - with: - # Deploy key is REQUIRED for Continue CLI integration - ssh-key: ${{ secrets.CONTINUE_DEPLOY_KEY }} + - uses: actions/checkout@v4 - - name: Set up environment + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "18" + + - name: Install Continue CLI + run: | + npm install -g @continuedev/cli + echo "✅ Continue CLI installed" + cn --version + + - name: Set up environment variables run: | - # Export environment variables for the entire job - echo "CONTINUE_API_KEY=${{ secrets.CONTINUE_API_KEY }}" >> $GITHUB_ENV echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> $GITHUB_ENV echo "POSTHOG_PROJECT_ID=${{ secrets.POSTHOG_PROJECT_ID }}" >> $GITHUB_ENV echo "POSTHOG_HOST=${{ secrets.POSTHOG_HOST || 'https://us.posthog.com' }}" >> $GITHUB_ENV - echo "GH_PAT=${{ secrets.GH_PAT }}" >> $GITHUB_ENV + echo "GITHUB_PAT=${{ secrets.GITHUB_PAT }}" >> $GITHUB_ENV echo "GITHUB_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV echo "GITHUB_REPO=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV - - name: Install dependencies + - name: Authenticate with Continue CLI run: | - sudo apt-get update - sudo apt-get install -y jq curl - # Install Continue CLI for AI analysis - npm install -g @continuedev/cli - # GitHub CLI is pre-installed on GitHub-hosted runners + # Set Continue API key + export CONTINUE_API_KEY="${{ secrets.CONTINUE_API_KEY }}" + # Login to Continue CLI + if ! cn auth login --api-key "$CONTINUE_API_KEY"; then + echo "❌ Failed to authenticate with Continue CLI" + exit 1 + fi + echo "✅ Continue CLI authenticated" - - name: Make scripts executable + - name: Run PostHog Session Analysis run: | - chmod +x ./posthog-continuous-ai/daily-analysis.sh - chmod +x ./posthog-continuous-ai/analyze-sessions.sh - chmod +x ./posthog-continuous-ai/create-github-issues.sh + echo "đŸŽŦ Starting PostHog session analysis..." + # Create the analysis prompt + cat > analysis_prompt.txt << 'EOF' + I need you to help me analyze PostHog session recordings to identify UX issues. Please: - - name: Run analysis and create issues - env: - GITHUB_TOKEN: ${{ secrets.GH_PAT }} - GH_TOKEN: ${{ secrets.GH_PAT }} - run: ./posthog-continuous-ai/daily-analysis.sh + 1. First, fetch session recordings from PostHog using these details: + - Use the POSTHOG_API_KEY, POSTHOG_PROJECT_ID, and POSTHOG_HOST from environment variables + - API endpoint: $POSTHOG_HOST/api/projects/$POSTHOG_PROJECT_ID/session_recordings/?limit=20 + - Include Authorization header: "Bearer $POSTHOG_API_KEY" + + 2. Filter the sessions to find problematic ones with either: + - console_error_count > 0 (JavaScript errors) + - recording_duration > 300 (sessions longer than 5 minutes) + + 3. Analyze the filtered sessions and create exactly 3 GitHub issues for the most critical UX problems. + + 4. Format each issue like this: + ### 1. **Issue Title Here** + **Problem**: One sentence describing the user problem + **Technical Causes**: Brief technical explanation + **Affected Pages**: List the URLs + **Recommended Fix**: + - Specific action item 1 + - Specific action item 2 + **Priority**: **HIGH** or **MEDIUM** or **LOW** + **Impact**: Quantify the impact (e.g., 'Affects 80% of sessions') + + Please make the API call, analyze the data, and provide the 3 formatted issues. Base all recommendations on actual patterns in the session data. + + Environment context: + - POSTHOG_API_KEY: $POSTHOG_API_KEY + - POSTHOG_PROJECT_ID: $POSTHOG_PROJECT_ID + - POSTHOG_HOST: $POSTHOG_HOST + - GitHub Repo: $GITHUB_OWNER/$GITHUB_REPO + EOF + + # Run the analysis + cn < analysis_prompt.txt > analysis-results.txt 2>&1 + + # Check if analysis completed + if [ ! -s analysis-results.txt ]; then + echo "❌ Analysis failed or produced no output" + exit 1 + fi + + echo "✅ Analysis completed" + echo "📄 Analysis results preview:" + head -20 analysis-results.txt + + - name: Create GitHub Issues from Analysis + run: | + echo "📝 Creating GitHub issues from analysis..." + # Create the issue creation prompt + cat > issue_prompt.txt << 'EOF' + I have analyzed PostHog session data and identified UX issues. Now I need you to create GitHub issues using the GitHub API. + + Use these details from environment variables: + - GITHUB_PAT: My GitHub Personal Access Token + - Repository: $GITHUB_OWNER/$GITHUB_REPO + + For each issue in my analysis: + 1. Parse the issue title, body content, and priority level + 2. Create a GitHub issue via API POST to: https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/issues + 3. Use these headers: + - Authorization: token $GITHUB_PAT + - Accept: application/vnd.github.v3+json + - Content-Type: application/json + 4. Set labels based on priority: + - HIGH: ["bug", "high-priority", "user-experience", "automated"] + - MEDIUM: ["enhancement", "medium-priority", "user-experience", "automated"] + - LOW: ["low-priority", "user-experience", "automated"] + 5. Format the issue title as: "🔍 UX Issue: {original title}" + + Please create the GitHub issues and confirm they were successfully created with issue numbers and URLs. + + Here's my analysis to process: + EOF + + # Append the analysis results to the prompt + cat analysis-results.txt >> issue_prompt.txt + + # Run the issue creation + cn < issue_prompt.txt > issue-creation-results.txt 2>&1 + + echo "✅ Issue creation completed" + echo "📄 Issue creation results:" + cat issue-creation-results.txt + + - name: Upload Analysis Artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: analysis-results-${{ github.run_number }} + path: | + analysis-results.txt + issue-creation-results.txt + retention-days: 30 + + - name: Summary + run: | + echo "✅ PostHog analysis workflow completed!" + echo "📊 Check the artifacts for detailed analysis results" + echo "🐛 Check your repository issues for newly created UX issues" ``` - - - - For running on your own server or VPS: +## Step 5: Testing Your Workflow - ```bash - # Add to crontab (run 'crontab -e') - 0 6 * * * cd /path/to/your/project && ./daily-analysis.sh >> ~/logs/analysis.log 2>&1 - ``` +### Test Locally First - +Before setting up automation, test the workflow locally: - - For testing and development: +**Test 1: Session Analysis** - ```bash - # Run manually - ./daily-analysis.sh +```bash +cn -p "[Paste the PostHog analysis prompt from Step 2]" +``` - # Or set up a simple loop for testing - while true; do - ./daily-analysis.sh - sleep 3600 # Run every hour - done - ``` +Expected: Analysis output with 3 formatted GitHub issues - +**Test 2: Issue Creation** - +```bash +cn -p "[Paste the GitHub issue creation prompt from Step 3 with your analysis results]" +``` -## Step 6: Testing Your Workflow +Expected: Confirmation of GitHub issues created with URLs - - - ```bash ./analyze-sessions.sh ``` Expected: JSON files with session data and - AI analysis output - +### Test the GitHub Actions Workflow - - ```bash ./create-github-issues.sh ``` Expected: New issues created in your - GitHub repository - - - - ```bash ./daily-analysis.sh ``` Expected: Complete end-to-end execution with - GitHub issues created - - +1. **Manual Trigger**: Go to **Actions** tab in your repository and manually trigger the workflow +2. **Check Artifacts**: Download the analysis results from the workflow run +3. **Verify Issues**: Check that GitHub issues were created in your repository - **Success Indicators:** - - PostHog API returns session data (not empty) - - Continue CLI generates analysis with identified issues - - GitHub issues are created with proper labels and formatting - - No error messages in the console output - + **Success Indicators:** - PostHog API returns session data (not empty) - + Continue CLI generates analysis with identified issues - GitHub issues are + created with proper labels and formatting - Workflow completes without errors +## Troubleshooting + +If you encounter issues, use this helpful prompt to diagnose problems: + +```bash +cn -p "Help me set up my environment for PostHog session analysis. Please: + +1. Check if I have the required secrets configured in Continue CLI: + - POSTHOG_API_KEY + - POSTHOG_PROJECT_ID + - POSTHOG_HOST + - GITHUB_PAT + +2. If any are missing, guide me through: + - How to get PostHog Personal API Key from PostHog settings + - How to find my PostHog Project ID from the URL + - How to create a GitHub Personal Access Token with issues:write permission + - How to add these as secrets in Continue CLI + +3. Help me identify my GitHub repository owner and name by: + - Checking git remote origin URL + - Or asking me to provide them + +4. Test the API connections by making a simple API call to both PostHog and GitHub to verify the credentials work. + +Please walk me through this setup process step by step." +``` + ## What You've Built After completing this guide, you have a complete **Continuous AI system** that: @@ -733,7 +446,7 @@ After completing this guide, you have a complete **Continuous AI system** that: ✅ **Monitors user experience** - Automatically fetches and analyzes PostHog session data ✅ **Identifies problems intelligently** - Uses AI to spot patterns and technical issues ✅ **Creates actionable tasks** - Generates GitHub issues with specific recommendations -✅ **Runs autonomously** - Operates daily without manual intervention +✅ **Runs autonomously** - Operates daily without manual intervention using GitHub Actions ✅ **Scales with your team** - Handles growing amounts of session data automatically @@ -746,35 +459,32 @@ After completing this guide, you have a complete **Continuous AI system** that: ## Security Best Practices - **Protect Your API Keys:** - - Never commit `.env` files or secrets to version - control - - Use GitHub Secrets for automation workflows - - Limit token scopes to - minimum required permissions - - Rotate API keys regularly (every 90 days - recommended) - - Monitor token usage for unusual activity - + **Protect Your API Keys:** - Store all credentials as GitHub Secrets, never in + code - Use Continue CLI's secure secret storage - Limit token scopes to + minimum required permissions - Rotate API keys regularly (every 90 days + recommended) - Monitor token usage for unusual activity -## Continue Your Workflow +## Advanced Prompts -Consider these additions: +Consider enhancing your workflow with these advanced Continue CLI prompts: - - Enhance this workflow with additional PostHog data sources (funnel analysis, - feature flags, etc.) + + "Analyze PostHog performance metrics alongside session recordings to + identify slow page loads affecting user experience" - - Train the AI on your specific codebase patterns and conventions + + "Cross-reference JavaScript console errors with user actions to identify the + root cause of UX issues" - - Get notifications when critical issues are detected + + "Analyze how PostHog feature flags impact user behavior in session + recordings" - - Track how fixes improve user experience metrics over time + + "Create Slack alerts when critical UX issues are detected in PostHog + sessions" @@ -782,5 +492,5 @@ Consider these additions: 1. **Monitor your first issues** - Review the GitHub issues created and implement fixes 2. **Measure impact** - Track how resolved issues improve PostHog metrics -3. **Refine analysis** - Adjust the Continue CLI prompts based on issue quality +3. **Refine prompts** - Adjust the Continue CLI prompts based on issue quality 4. **Scale the system** - Add more data sources or create specialized analysis workflows