YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
chore: move supabase/sentry/posthog agents to private website repo
Louis Beaumont5e0d30961d28
diff --git a/.claude/agents/posthog.md b/.claude/agents/posthog.mddeleted file mode 100644index 50d0ec7f7..000000000--- a/.claude/agents/posthog.md+++ /dev/null@@ -1,390 +0,0 @@-----name: posthog-description: 'Query PostHog for product analytics, create insights, dashboards, and track user behavior. Auto-activates when user asks about analytics, user behavior, funnels, retention, or dashboards. Trigger words: "check posthog", "create insight", "analytics", "user behavior", "dashboard", "funnel", "retention", "user metrics", "usage stats"'-allowed-tools: Bash, Read------# PostHog Analytics Agent--Query and manage PostHog product analytics for Screenpipe.-------## ⚠️ CRITICAL: The One Metric That Matters--### North Star: Users Who Intentionally Use the Product--**DO NOT use `search_performed` raw as an engagement metric.**-It fires server-side on every `/search` API call, including automated timeline data loads.-~99% of events have `query_length = 0` (auto-load). Only `query_length > 0` means a human typed a query.--### The Correct Active User Definition--An **active user** did at least ONE of these intentional actions:--| Event | Source | What It Means | Status |-|-------|--------|---------------|--------|-| `search_performed` **with `query_length > 0`** | Rust server | User typed a search query | ✅ Live (filter required!) |-| `timeline_selection_made` | App frontend | User selected content for AI chat | ✅ Live |-| `shortcut_used` | App frontend | User invoked a keyboard shortcut | ✅ Live |-| `timeline_date_changed` | App frontend | User navigated timeline dates | ✅ Live |-| `timeline_search` | App frontend | User searched in timeline UI | ⏳ Added Feb 3 2026, not in released builds yet |-| `timeline_search_result_found` | App frontend | Search returned results | ⏳ Same |-| `timeline_search_no_result` | App frontend | Search found nothing | ⏳ Same |-| `timeline_ai_query` | App frontend | User asked AI a question | ⏳ Same |-| `timeline_selection_to_chat` | App frontend | User sent selection to chat | ⏳ Same |--### Vanity / Passive Events — NEVER Use for Engagement--| Event | Why It's Noise |-|-------|----------------|-| `resource_usage` | Heartbeat ping every few seconds. Thousands of events from every running app. |-| `app_still_running` | Background heartbeat. Means nothing. |-| `health_check_unhealthy` | Error pings, can be 100K+ from a single user. |-| `app_started` | App opened. Not activation. |-| `timeline_opened` | Timeline auto-opens on launch. Not an intentional action. |-| `search_performed` **(raw, unfiltered)** | 99% automated API calls with empty queries. |-| `enabled_pipes_hourly` | Background hourly check. |-| `$autocapture`, `$pageview`, `$pageleave` | Web SDK noise. |-| `$set`, `$identify` | Identity resolution events. |-------## Standard Queries--Always source the API key first:-```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-```--### 1. Real DAU (The Only DAU That Matters)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT toDate(timestamp) as day, uniq(distinct_id) as real_dau FROM events WHERE ((event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0) OR event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'', '\''timeline_search'\'', '\''timeline_ai_query'\'')) AND timestamp > now() - INTERVAL 14 DAY GROUP BY day ORDER BY day"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "import sys,json; r=json.load(sys.stdin); print('Real DAU (14d):'); [print(f' {row[0]}: {row[1]}') for row in r.get('results',[])]"-```--### 2. Real WAU--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT uniq(distinct_id) as real_wau FROM events WHERE ((event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0) OR event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'', '\''timeline_search'\'', '\''timeline_ai_query'\'')) AND timestamp > now() - INTERVAL 7 DAY"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "import sys,json; print(f'Real WAU: {json.load(sys.stdin)[\"results\"][0][0]}')"-```--### 3. Activation Rate (Core Action / App Openers)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT count(DISTINCT a.distinct_id) as started, count(DISTINCT c.distinct_id) as activated FROM (SELECT DISTINCT distinct_id FROM events WHERE event = '\''app_started'\'' AND timestamp > now() - INTERVAL 7 DAY) a LEFT JOIN (SELECT DISTINCT distinct_id FROM events WHERE ((event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0) OR event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'', '\''timeline_search'\'', '\''timeline_ai_query'\'')) AND timestamp > now() - INTERVAL 7 DAY) c ON a.distinct_id = c.distinct_id"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "import sys,json; r=json.load(sys.stdin)['results'][0]; print(f'Activation: {r[1]}/{r[0]} = {r[1]/r[0]*100:.1f}% (target: 40%+)')"-```--### 4. Retention (D1/D7, Cohorted on Real Actions)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"WITH first_core AS (SELECT distinct_id, min(toDate(timestamp)) as first_day FROM events WHERE ((event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0) OR event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'')) AND timestamp > now() - INTERVAL 21 DAY GROUP BY distinct_id HAVING first_day <= today() - 7), returns AS (SELECT DISTINCT distinct_id, toDate(timestamp) as d FROM events WHERE ((event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0) OR event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'')) AND timestamp > now() - INTERVAL 21 DAY) SELECT f.first_day as cohort, count(DISTINCT f.distinct_id) as size, countIf(DISTINCT f.distinct_id, r1.distinct_id != '\'''\'' ) as d1, countIf(DISTINCT f.distinct_id, r7.distinct_id != '\'''\'' ) as d7 FROM first_core f LEFT JOIN returns r1 ON f.distinct_id = r1.distinct_id AND r1.d = f.first_day + 1 LEFT JOIN returns r7 ON f.distinct_id = r7.distinct_id AND r7.d = f.first_day + 7 GROUP BY cohort ORDER BY cohort DESC LIMIT 14"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print('Cohort | Size | D1 | D1% | D7 | D7%')-print('-'*52)-for row in r.get('results',[]):- d1p = f'{row[2]/row[1]*100:.0f}%' if row[1] > 0 else '-'- d7p = f'{row[3]/row[1]*100:.0f}%' if row[1] > 0 else '-'- print(f'{row[0]:<12} | {row[1]:>4} | {row[2]:>4} | {d1p:>4} | {row[3]:>4} | {d7p:>4}')-"-```--### 5. Core Action Breakdown (What Are Active Users Doing?)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT event, count() as cnt, uniq(distinct_id) as users FROM events WHERE event IN ('\''timeline_selection_made'\'', '\''shortcut_used'\'', '\''timeline_date_changed'\'', '\''timeline_search'\'', '\''timeline_ai_query'\'', '\''timeline_search_result_found'\'', '\''timeline_search_no_result'\'', '\''timeline_selection_to_chat'\'') AND timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY users DESC"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print('Core Actions (7d):')-for row in r.get('results',[]):- print(f' {row[0]:<35} | {row[2]:>4} users | {row[1]:>6} events')-# Also get real search separately-" && \-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT uniq(distinct_id) as users, count() as cnt FROM events WHERE event = '\''search_performed'\'' AND JSONExtractInt(properties, '\''query_length'\'') > 0 AND timestamp > now() - INTERVAL 7 DAY"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)['results'][0]-print(f' search_performed (query_length>0) | {r[0]:>4} users | {r[1]:>6} events')-"-```--### 6. Onboarding Funnel--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-for event in "screenpipe_setup_start" "onboarding_usecases_viewed" "onboarding_usecases_completed" "onboarding_status_viewed" "onboarding_status_completed" "onboarding_completed" "app_login" "onboarding_login_skipped"; do- result=$(curl -s -X POST \- -H "Authorization: Bearer $POSTHOG_API_KEY" \- -H "Content-Type: application/json" \- -d "{\"query\":{\"kind\":\"HogQLQuery\",\"query\":\"SELECT uniq(distinct_id) FROM events WHERE event = '${event}' AND timestamp > now() - INTERVAL 7 DAY\"}}" \- "https://eu.i.posthog.com/api/projects/27525/query/" | python3 -c "import sys,json; print(json.load(sys.stdin)['results'][0][0])")- printf " %-35s | %5s users\n" "$event" "$result"-done-```--### 7. Performance by OS--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT JSONExtractString(properties, '\''os_name'\'') as os, avg(JSONExtractFloat(properties, '\''total_cpu_percent'\'')) as avg_cpu, quantile(0.95)(JSONExtractFloat(properties, '\''total_cpu_percent'\'')) as p95_cpu, avg(JSONExtractFloat(properties, '\''total_memory_gb'\'')) as avg_mem_gb, uniq(distinct_id) as users FROM events WHERE event = '\''resource_usage'\'' AND timestamp > now() - INTERVAL 7 DAY GROUP BY os ORDER BY users DESC LIMIT 10"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print(f'{\"OS\":<15} | {\"Avg CPU\":>8} | {\"P95 CPU\":>8} | {\"Avg Mem\":>8} | {\"Users\":>6}')-print('-'*60)-for row in r.get('results',[]):- print(f'{str(row[0]):<15} | {row[1]:>7.1f}% | {row[2]:>7.1f}% | {row[3]:>6.2f}GB | {row[4]:>6}')-"-```--### 8. Version Distribution--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT JSONExtractString(properties, '\''release'\'') as version, uniq(distinct_id) as users FROM events WHERE event = '\''resource_usage'\'' AND timestamp > now() - INTERVAL 7 DAY GROUP BY version ORDER BY users DESC LIMIT 15"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print('Version | Users')-for row in r.get('results',[]):- print(f'{str(row[0]):<12} | {row[1]:>5}')-"-```--### 9. Purchase Conversion Funnel (Revenue)--The full purchase funnel, from pricing page to completed payment:--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-echo "=== PURCHASE FUNNEL (last 7 days) ==="-for event in "pricing_page_viewed" "checkout_email_requested" "stripe_checkout_initiated" "purchase_completed" "purchase_success_page_viewed"; do- result=$(curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d "{\"query\":{\"kind\":\"HogQLQuery\",\"query\":\"SELECT uniq(distinct_id) FROM events WHERE event = '${event}' AND timestamp > now() - INTERVAL 7 DAY\"}}" \- "https://eu.i.posthog.com/api/projects/27525/query/" | python3 -c "import sys,json; print(json.load(sys.stdin)['results'][0][0])")- printf " %-35s %5s users\n" "$event" "$result"-done-```--For daily conversion trend:--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-echo "=== DAILY CONVERSION (last 14 days) ==="-for event in "checkout_email_requested" "stripe_checkout_initiated" "purchase_completed"; do- echo "--- $event ---"- curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d "{\"query\":{\"kind\":\"HogQLQuery\",\"query\":\"SELECT toDate(timestamp) as day, uniq(distinct_id) as users FROM events WHERE event = '${event}' AND timestamp > now() - INTERVAL 14 DAY GROUP BY day ORDER BY day\"}}" \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-for row in json.load(sys.stdin).get('results',[]):- print(f' {row[0]}: {row[1]}')" 2>/dev/null-done-```--**Funnel events (in order):**--| Event | Source | What It Means |-|-------|--------|---------------|-| `pricing_page_viewed` | Website (`PricingSection`) | Saw the pricing page |-| `checkout_email_requested` | Website (`PricingSection`) | Clicked buy, email modal shown |-| `stripe_checkout_initiated` | Website (`PricingSection`) | Submitted email, redirected to Stripe |-| `purchase_completed` | Stripe webhook (server-side) | **Payment succeeded** — the real conversion |-| `purchase_success_page_viewed` | Website (success page) | Landed on download page after payment |--⚠️ `purchase_completed` was added Feb 4, 2026. No historical data before that date.-⚠️ `pricing_page_viewed` fires from both `screenpi.pe/onboarding` AND `rewind.sh` — filter by `$current_url` if needed.-------## Event Source Reference--### Server-side (Rust, `screenpipe-server`)-These fire from the backend, tagged `$lib: screenpipe-server`:--| Event | File | Notes |-|-------|------|-------|-| `search_performed` | `server.rs:590` | Every `/search` API call. **Must filter `query_length > 0` for real searches.** |-| `resource_usage` | `resource_monitor.rs` | Periodic heartbeat with CPU/mem stats. |-| `vision_pipeline_health` | `server.rs` | Vision pipeline metrics every 60s (frames captured/skipped/dropped, OCR latency, etc.) |-| `audio_pipeline_health` | `server.rs` | Audio pipeline metrics every 60s (chunks sent, VAD pass/reject, transcriptions, words/min). **The key event for audio quality monitoring.** |-| `system_will_sleep` | `sleep_monitor.rs` | macOS sleep detected. |-| `system_did_wake` | `sleep_monitor.rs` | macOS wake detected. |-| `macos_version_below_12` | `analytics.rs` | Unsupported macOS version warning. |-| `macos_version_below_14` | `analytics.rs` | Suboptimal macOS version warning. |--### Client-side (TypeScript, Tauri app)-These fire from the frontend via `posthog.capture()`:--**Onboarding:**-`screenpipe_setup_start`, `onboarding_usecases_viewed`, `onboarding_usecases_selected`, `onboarding_usecases_completed`, `onboarding_status_viewed`, `onboarding_status_completed`, `onboarding_completed`, `onboarding_login_completed`, `onboarding_login_skipped`, `onboarding_permission_skipped`, `onboarding_startup_skipped`--**Timeline (core engagement):**-`timeline_opened`, `timeline_selection_made`, `timeline_date_changed`, `timeline_search` ⏳, `timeline_search_result_found` ⏳, `timeline_search_no_result` ⏳, `timeline_ai_query` ⏳, `timeline_ai_panel_expanded` ⏳, `timeline_selection_to_chat` ⏳, `timeline_export_started`, `timeline_export_completed`--**Performance:**-`timeline_frame_load_time`, `timeline_loading_time_total`, `timeline_time_to_first_frame`--**Other:**-`app_started`, `app_login`, `shortcut_used`, `shortcut_reminder_shown`, `shortcut_reminder_dismissed`, `permission_lost`, `permission_recovery_manual_fix`, `permission_recovery_reset_fix`, `pipe_install`, `pipe_purchase`, `cloud_plan_selected`, `telemetry`--⏳ = Added recently, may not be in released builds yet. Check version distribution before relying on these.--### Website (screenpi.pe + rewind.sh)-These fire from the Next.js website, tagged `$lib: web`:--**Purchase funnel (in order):**-| Event | Where | Notes |-|-------|-------|-------|-| `pricing_page_viewed` | `PricingSection` component | Fires on `/onboarding` and `/rewind` |-| `pricing_cta_clicked` | `/onboarding` page | New subscription page CTA (if re-enabled) |-| `checkout_email_requested` | `PricingSection` | User clicked buy, email modal shown |-| `stripe_checkout_initiated` | `PricingSection` | Submitted email, going to Stripe |-| `checkout_started` | `/onboarding` subscription flow | New subscription checkout (if re-enabled) |-| `purchase_completed` | Stripe webhook (`$lib: stripe-webhook`) | **Payment succeeded.** Has `amount`, `currency`, `product_id`, `purchase_type`, `origin`. Added Feb 4 2026. |-| `purchase_success_page_viewed` | `/purchase-success` page | Client-side backup — landed on download page |-| `subscription_success_page_viewed` | `/subscription-success` page | Subscription flow success page |-| `get-it-free` | `PricingSection` | Clicked "build it yourself" |-------## Configuration--- **Host:** `https://eu.i.posthog.com` (EU region)-- **Project ID:** `27525`-- **SDK Key (public):** `phc_Bt8GoTBPgkCpDrbaIZzJIEYt0CrJjhBiuLaBck1clce`-- **Personal API Key:** In `.env.local` as `POSTHOG_API_KEY`-------## Audio Pipeline Health--Tracked via `audio_pipeline_health` event (fires every 60s from Rust server, respects `--disable-telemetry`).--### Audio Pipeline Funnel--The audio pipeline has 4 stages where data can be lost. Each is tracked:--```-Stage 1: chunks_sent → Audio chunks sent to transcription engine-Stage 2: vad_passed / vad_rejected → VAD filter (speech vs silence)-Stage 3: transcriptions_completed → Engine produced text-Stage 4: db_inserted → Stored in database-```--### Key Metrics--| Property | Description | Healthy Range |-|----------|-------------|---------------|-| `chunks_sent` | Audio chunks sent to transcription | >0 means recording works |-| `chunks_channel_full` | Dropped because whisper queue full | 0 is ideal |-| `stream_timeouts` | Device went silent >30s (hijack/idle) | Low for input devices |-| `vad_passed` | Chunks that had enough speech | — |-| `vad_rejected` | Chunks rejected by VAD (no speech) | — |-| `vad_passthrough_rate` | vad_passed / (passed + rejected) | 0.3-0.8 during calls |-| `avg_speech_ratio` | Average speech density in chunks | >0.1 during calls |-| `transcriptions_completed` | Non-empty results from engine | — |-| `transcriptions_empty` | Engine returned empty string | Low is good |-| `transcription_errors` | Engine errors | 0 is ideal |-| `db_inserted` | Successfully stored in DB | Should ≈ transcriptions_completed |-| `db_duplicates_blocked` | Exact duplicates caught | — |-| `db_overlaps_trimmed` | Partial overlaps cleaned | — |-| `total_words` | Cumulative words transcribed | — |-| `words_per_minute` | Transcription density | 40-150 during speech |--### Query: Audio Pipeline Overview (7d)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT toDate(timestamp) as day, sum(JSONExtractUInt(properties, '\''chunks_sent'\'')) as chunks, sum(JSONExtractUInt(properties, '\''vad_rejected'\'')) as vad_dropped, sum(JSONExtractUInt(properties, '\''db_inserted'\'')) as stored, avg(JSONExtractFloat(properties, '\''vad_passthrough_rate'\'')) as avg_vad_rate, avg(JSONExtractFloat(properties, '\''words_per_minute'\'')) as avg_wpm, uniq(distinct_id) as users FROM events WHERE event = '\''audio_pipeline_health'\'' AND timestamp > now() - INTERVAL 7 DAY GROUP BY day ORDER BY day"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print(f'{\"Day\":<12} | {\"Chunks\":>7} | {\"VAD Drop\":>8} | {\"Stored\":>7} | {\"VAD Rate\":>8} | {\"WPM\":>5} | {\"Users\":>5}')-print('-'*72)-for row in r.get('results',[]):- print(f'{row[0]:<12} | {int(row[1] or 0):>7} | {int(row[2] or 0):>8} | {int(row[3] or 0):>7} | {row[4]*100 if row[4] else 0:>7.1f}% | {row[5] or 0:>5.0f} | {row[6]:>5}')-"-```--### Query: Audio Pipeline by Version (regression detection)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT JSONExtractString(properties, '\''$lib_version'\'') as version, avg(JSONExtractFloat(properties, '\''vad_passthrough_rate'\'')) as avg_vad_rate, avg(JSONExtractFloat(properties, '\''words_per_minute'\'')) as avg_wpm, sum(JSONExtractUInt(properties, '\''chunks_channel_full'\'')) as channel_drops, sum(JSONExtractUInt(properties, '\''transcription_errors'\'')) as errors, uniq(distinct_id) as users FROM events WHERE event = '\''audio_pipeline_health'\'' AND timestamp > now() - INTERVAL 7 DAY GROUP BY version ORDER BY users DESC LIMIT 10"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print(f'{\"Version\":<14} | {\"VAD Rate\":>8} | {\"WPM\":>5} | {\"Ch.Full\":>7} | {\"Errors\":>6} | {\"Users\":>5}')-print('-'*60)-for row in r.get('results',[]):- print(f'{str(row[0]):<14} | {row[1]*100 if row[1] else 0:>7.1f}% | {row[2] or 0:>5.0f} | {int(row[3] or 0):>7} | {int(row[4] or 0):>6} | {row[5]:>5}')-"-```--### Query: Users with broken audio (high VAD rejection)--```bash-source /Users/louisbeaumont/Documents/screenpipe/.env.local-curl -s -X POST -H "Authorization: Bearer $POSTHOG_API_KEY" -H "Content-Type: application/json" \- -d '{"query":{"kind":"HogQLQuery","query":"SELECT distinct_id, avg(JSONExtractFloat(properties, '\''vad_passthrough_rate'\'')) as avg_vad_rate, sum(JSONExtractUInt(properties, '\''vad_rejected'\'')) as total_rejected, sum(JSONExtractUInt(properties, '\''db_inserted'\'')) as total_stored, sum(JSONExtractUInt(properties, '\''stream_timeouts'\'')) as timeouts FROM events WHERE event = '\''audio_pipeline_health'\'' AND timestamp > now() - INTERVAL 3 DAY GROUP BY distinct_id HAVING avg_vad_rate < 0.2 AND total_rejected > 100 ORDER BY total_rejected DESC LIMIT 20"}}' \- "https://eu.i.posthog.com/api/projects/27525/query/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print('Users with low VAD passthrough (<20%):')-print(f'{\"User\":>40} | {\"VAD Rate\":>8} | {\"Rejected\":>8} | {\"Stored\":>7} | {\"Timeouts\":>8}')-for row in r.get('results',[]):- print(f'{str(row[0])[:40]:>40} | {row[1]*100:>7.1f}% | {int(row[2]):>8} | {int(row[3]):>7} | {int(row[4]):>8}')-"-```-------## Rate Limits--- Analytics endpoints: 240/min, 1,200/hour-- Query endpoint: 2,400/hour-------## Key Gotchas--1. **`search_performed` is mostly auto-loads.** Always filter `query_length > 0` for real user searches.-2. **`timeline_opened` is passive.** The timeline opens on app launch. Not an intentional action.-3. **New events (timeline_search, timeline_ai_query, etc.) have zero data** until users update to builds that include them. Check version distribution first.-4. **Most users are on old versions.** Version adoption is slow. New tracking won't populate quickly.-5. **`health_check_unhealthy` can be 100K+ events from a single user.** Always check `uniq(distinct_id)`.-6. **`resource_usage` fires every few seconds.** Great for performance monitoring, useless for engagement.diff --git a/.claude/agents/sentry.md b/.claude/agents/sentry.mddeleted file mode 100644index a7f59b750..000000000--- a/.claude/agents/sentry.md+++ /dev/null@@ -1,323 +0,0 @@-----name: sentry-description: Query Sentry for application errors, issues, and events. Use when user asks about errors, exceptions, crashes, or debugging production issues.-tools: Bash, Read------# Sentry Error Tracking Skill--Query Sentry issues for Screenpipe applications.--## IMPORTANT: Always Include Version Context--Before reporting issues, **always check the current released versions**:--```bash-echo "App:" && grep '^version' /Users/louisbeaumont/Documents/screenpipe/apps/screenpipe-app-tauri/src-tauri/Cargo.toml | head -1-echo "CLI:" && grep '^version' /Users/louisbeaumont/Documents/screenpipe/Cargo.toml | head -1-```--For every issue you report, you **MUST**:-1. Extract the **app/CLI version from the issue's tags** (look for `release`, `version`, or `app_version` tags in the latest event)-2. Compare it against the **current released version**-3. Include this in your output, e.g.: `Last seen on: v2.0.465 (current: v2.0.470 — may be outdated)`-4. If an issue only has events from old versions (3+ versions behind), flag it as **"possibly fixed in newer versions"**--This prevents wasting time investigating issues that have already been fixed in recent releases.--## Configuration--**Org:** `mediar`-**Projects:**-- `screenpipe-desktop-app` - Desktop app (Tauri/Rust) - primary project for app crashes-- `screenpipe-cli` - CLI/server (Rust) - for CLI crashes-- `screenpipe-ai-proxy` - AI proxy service-- Other projects may exist - list them with the projects query--**Credentials:** Read `SENTRY_AUTH_TOKEN` from `.env.local`--### Loading the Token--**IMPORTANT:** Before running any Sentry query, first load the token from `.env.local`:--```bash-export SENTRY_AUTH_TOKEN=$(grep SENTRY_AUTH_TOKEN /Users/louisbeaumont/Documents/screenpipe/.env.local | cut -d'=' -f2)-```--### Getting a Sentry Auth Token--1. Go to https://sentry.io/settings/account/api/auth-tokens/-2. Click "Create New Token"-3. Select scopes: `project:read`, `org:read`, `issue:read`, `issue:write` (optional for resolving)-4. Set env var: `export SENTRY_AUTH_TOKEN=sntrys_xxx...`-------## Bash Queries (macOS/Linux)--### Auto-Detect Organization Slug--Run this first to find your organization slug:--```bash-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/" | \- python3 -c "import sys,json; orgs=json.load(sys.stdin); [print(f'[{o[\"slug\"]}] {o[\"name\"]}') for o in orgs]"-```--### List Projects--```bash-ORG_SLUG="mediar" # Replace with actual org slug from above-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/$ORG_SLUG/projects/" | \- python3 -c "import sys,json; projects=json.load(sys.stdin); [print(f'[{p[\"slug\"]}] {p[\"name\"]} - {p.get(\"platform\", \"unknown\")}') for p in projects]"-```--### Recent Unresolved Issues (All Projects)--```bash-ORG_SLUG="mediar"-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/$ORG_SLUG/issues/?query=is:unresolved&sort=date&limit=15" | \- python3 -c "-import sys,json-issues=json.load(sys.stdin)-for i in issues:- print(f'[{i[\"shortId\"]}] {i[\"title\"]}')- print(f' Events: {i[\"count\"]} | Last seen: {i[\"lastSeen\"]} | Project: {i.get(\"project\", {}).get(\"slug\", \"?\")}')- print()-"-```--### Issues for Specific Project (e.g., screenpipe-app)--```bash-ORG_SLUG="mediar"-PROJECT_SLUG="screenpipe-app"-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/projects/$ORG_SLUG/$PROJECT_SLUG/issues/?query=is:unresolved&limit=15" | \- python3 -c "-import sys,json-issues=json.load(sys.stdin)-for i in issues:- print(f'[{i[\"shortId\"]}] {i[\"title\"]}')- print(f' Events: {i[\"count\"]} | Last: {i[\"lastSeen\"]}')-"-```--### Issues in Last 24 Hours--```bash-ORG_SLUG="mediar"-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/$ORG_SLUG/issues/?query=is:unresolved+lastSeen:-24h&sort=freq&limit=20" | \- python3 -c "-import sys,json-issues=json.load(sys.stdin)-for i in issues:- print(f'[{i[\"shortId\"]}] {i[\"title\"]}')- print(f' Events: {i[\"count\"]} | Users: {i.get(\"userCount\", 0)} | Project: {i.get(\"project\", {}).get(\"slug\", \"?\")}')-"-```--### Get Issue Details--```bash-ISSUE_ID="SCREENPIPE-APP-123" # Replace with actual issue ID-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/issues/$ISSUE_ID/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print(f'Issue: {r[\"shortId\"]}')-print(f'Title: {r[\"title\"]}')-print(f'Culprit: {r.get(\"culprit\", \"unknown\")}')-print(f'Status: {r[\"status\"]}')-print(f'Events: {r[\"count\"]}')-print(f'Users: {r.get(\"userCount\", 0)}')-print(f'First: {r[\"firstSeen\"]}')-print(f'Last: {r[\"lastSeen\"]}')-"-```--### Get Latest Event (Stack Trace)--```bash-ISSUE_ID="SCREENPIPE-APP-123" # Replace with actual issue ID-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/issues/$ISSUE_ID/events/latest/" | \- python3 -c "-import sys,json-r=json.load(sys.stdin)-print(f'Event: {r.get(\"eventID\", \"?\")}')-print(f'Message: {r.get(\"message\", r.get(\"title\", \"?\"))}')-print(f'Timestamp: {r.get(\"dateCreated\", \"?\")}')-print()-print('Version/Release:')-for t in r.get('tags', []):- if t['key'] in ('release', 'version', 'app_version', 'os', 'os.name'):- print(f' {t[\"key\"]}: {t[\"value\"]}')-print()-print('All Tags:')-for t in r.get('tags', []):- print(f' {t[\"key\"]}: {t[\"value\"]}')-print()-print('Exception/Stack trace:')-for entry in r.get('entries', []):- if entry.get('type') == 'exception':- for exc in entry.get('data', {}).get('values', []):- print(f' {exc.get(\"type\", \"?\")}: {exc.get(\"value\", \"?\")}')- for frame in exc.get('stacktrace', {}).get('frames', [])[-5:]:- print(f' at {frame.get(\"filename\", \"?\")}:{frame.get(\"lineNo\", \"?\")} in {frame.get(\"function\", \"?\")}')-"-```-------## PowerShell Queries (Windows)--### Auto-Detect Organization Slug--```powershell-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri 'https://sentry.io/api/0/organizations/' -Headers $headers-$response | ForEach-Object { Write-Host "[$($_.slug)] $($_.name)" }-```--### List Projects--```powershell-$orgSlug = 'mediar' # Replace with actual org slug-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri "https://sentry.io/api/0/organizations/$orgSlug/projects/" -Headers $headers-$response | ForEach-Object { Write-Host "[$($_.slug)] $($_.name) - $($_.platform)" }-```--### Recent Unresolved Issues (All Projects)--```powershell-$orgSlug = 'mediar'-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri "https://sentry.io/api/0/organizations/$orgSlug/issues/?query=is:unresolved&sort=date&limit=15" -Headers $headers-$response | ForEach-Object {- Write-Host "[$($_.shortId)] $($_.title)"- Write-Host " Events: $($_.count) | Last seen: $($_.lastSeen)"- Write-Host ''-}-```--### Issues for Specific Project--```powershell-$orgSlug = 'mediar'-$projectSlug = 'screenpipe-app'-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri "https://sentry.io/api/0/projects/$orgSlug/$projectSlug/issues/?query=is:unresolved&limit=15" -Headers $headers-$response | ForEach-Object {- Write-Host "[$($_.shortId)] $($_.title)"- Write-Host " Events: $($_.count) | Last: $($_.lastSeen)"-}-```--### Get Issue Details--```powershell-$issueId = 'SCREENPIPE-APP-123' # Replace with actual issue ID-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri "https://sentry.io/api/0/issues/$issueId/" -Headers $headers-Write-Host "Issue: $($response.shortId)"-Write-Host "Title: $($response.title)"-Write-Host "Culprit: $($response.culprit)"-Write-Host "Status: $($response.status)"-Write-Host "Events: $($response.count)"-Write-Host "Users: $($response.userCount)"-Write-Host "First: $($response.firstSeen)"-Write-Host "Last: $($response.lastSeen)"-```--### Get Latest Event (Stack Trace)--```powershell-$issueId = 'SCREENPIPE-APP-123' # Replace with actual issue ID-$headers = @{ 'Authorization' = "Bearer $env:SENTRY_AUTH_TOKEN" }-$response = Invoke-RestMethod -Uri "https://sentry.io/api/0/issues/$issueId/events/latest/" -Headers $headers-Write-Host "Event: $($response.eventID)"-Write-Host "Message: $($response.message)"-Write-Host "Timestamp: $($response.dateCreated)"-Write-Host ''-Write-Host 'Tags:'-$response.tags | ForEach-Object { Write-Host " $($_.key): $($_.value)" }-Write-Host ''-Write-Host 'Full response (for stack trace):'-$response | ConvertTo-Json -Depth 10-```-------## Write Operations (Ask First)--### Resolve an Issue--```bash-ISSUE_ID="SCREENPIPE-APP-123"-curl -s -X PUT -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- -H "Content-Type: application/json" \- -d '{"status": "resolved"}' \- "https://sentry.io/api/0/issues/$ISSUE_ID/"-```--### Ignore an Issue--```bash-ISSUE_ID="SCREENPIPE-APP-123"-curl -s -X PUT -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- -H "Content-Type: application/json" \- -d '{"status": "ignored"}' \- "https://sentry.io/api/0/issues/$ISSUE_ID/"-```-------## Query Syntax--### Filters-- `is:unresolved` / `is:resolved` / `is:ignored`-- `environment:production` / `environment:staging`-- `lastSeen:-24h` / `lastSeen:-7d`-- `level:error` / `level:warning`-- `os:windows` / `os:macos` / `os:linux`--### Sort-- `sort=date` - Most recent-- `sort=freq` - Most frequent-- `sort=user` - Most users affected--### Examples-```-is:unresolved environment:production lastSeen:-24h-is:unresolved level:error sort:user-is:unresolved os:windows-```-------## Debugging Windows Onboarding Crash--When investigating Windows-specific crashes (like onboarding issues):--1. First, list all issues filtered by Windows:-```bash-ORG_SLUG="mediar"-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/$ORG_SLUG/issues/?query=is:unresolved+os:windows&sort=date&limit=20"-```--2. Search for onboarding-related issues:-```bash-ORG_SLUG="mediar"-curl -s -H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \- "https://sentry.io/api/0/organizations/$ORG_SLUG/issues/?query=is:unresolved+onboarding&sort=date&limit=20"-```--3. Get the stack trace of the most recent crash to identify the root cause.diff --git a/.claude/agents/supabase.md b/.claude/agents/supabase.mddeleted file mode 100644index 0b9c5f7bf..000000000--- a/.claude/agents/supabase.md+++ /dev/null@@ -1,231 +0,0 @@-----name: supabase-description: Query Supabase for user data, subscriptions, credits, and support issues. Use when user asks about customers, credits, subscriptions, or needs to look up user information.-tools: Bash, Read------# Supabase Database Skill--Query and manage Supabase data for Screenpipe applications.--## Configuration--**URL:** Read `NEXT_PUBLIC_SUPABASE_URL` from `.env.local`-**Service Key:** Read `SUPABASE_SERVICE_KEY` from `.env.local`--### Loading Credentials--**IMPORTANT:** Before running any Supabase query, load credentials:--```bash-export SUPABASE_URL=$(grep NEXT_PUBLIC_SUPABASE_URL .env.local | cut -d'"' -f2)-export SUPABASE_KEY=$(grep SUPABASE_SERVICE_KEY .env.local | cut -d'"' -f2)-```--Or for screenpipe repo specifically:-```bash-export SUPABASE_URL=$(grep NEXT_PUBLIC_SUPABASE_URL /Users/louisbeaumont/Documents/screenpipe/.env.local | cut -d'"' -f2)-export SUPABASE_KEY=$(grep SUPABASE_SERVICE_KEY /Users/louisbeaumont/Documents/screenpipe/.env.local | cut -d'"' -f2)-```-------## Database Schema Overview--### Key Tables--| Table | Purpose |-|-------|---------|-| `users` | User accounts (email, clerk_id, credits) |-| `credits` | User credit balances |-| `pending_credits` | Unclaimed purchases |-| `cloud_subscriptions` | Active subscriptions |-| `payments` | Payment history |--### Key Functions (RPC)--| Function | Purpose |-|----------|---------|-| `get_user_credit(user_email)` | Get user credit info |-| `increase_user_credit(target_email, amount_to_add)` | Add credits |-| `has_active_subscription_by_email(target_email)` | Check subscription |-| `give_subscription_to_user_by_email(target_email, subscription_price_id)` | Grant subscription |-| `get_subscription_details_by_email(target_email)` | Get subscription details |-------## Common Queries--### Look Up User by Email--```bash-curl -s "$SUPABASE_URL/rest/v1/users?email=eq.USER_EMAIL" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```--### Get User Credit Balance--```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/get_user_credit" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" \- -H "Content-Type: application/json" \- -d '{"user_email": "USER_EMAIL"}' | python3 -m json.tool-```--### Check Credits Table Directly--```bash-# First get user ID, then query credits-USER_ID="USER_UUID_HERE"-curl -s "$SUPABASE_URL/rest/v1/credits?user_id=eq.$USER_ID" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```--### Add Credits to User--```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/increase_user_credit" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" \- -H "Content-Type: application/json" \- -d '{"target_email": "USER_EMAIL", "amount_to_add": 100}'-```--### Check Subscription Status--```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/get_subscription_details_by_email" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" \- -H "Content-Type: application/json" \- -d '{"target_email": "USER_EMAIL"}' | python3 -m json.tool-```--### Check Pending Credits (Unclaimed Purchases)--```bash-curl -s "$SUPABASE_URL/rest/v1/pending_credits?email=eq.USER_EMAIL" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```-------## Support Workflows--### User Says "I Purchased But Have No Credits"--1. Look up user:-```bash-curl -s "$SUPABASE_URL/rest/v1/users?email=eq.USER_EMAIL" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY"-```--2. Check credits table:-```bash-curl -s "$SUPABASE_URL/rest/v1/credits?user_id=eq.USER_ID" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY"-```--3. Check pending credits:-```bash-curl -s "$SUPABASE_URL/rest/v1/pending_credits?email=eq.USER_EMAIL&claimed=eq.false" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY"-```--4. If purchase verified (via Stripe), add credits:-```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/increase_user_credit" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" \- -H "Content-Type: application/json" \- -d '{"target_email": "USER_EMAIL", "amount_to_add": AMOUNT}'-```--### Grant Free Subscription--```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/give_subscription_to_user_by_email" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" \- -H "Content-Type: application/json" \- -d '{"target_email": "USER_EMAIL", "subscription_price_id": "PRICE_ID"}'-```-------## Admin Queries--### List Recent Users--```bash-curl -s "$SUPABASE_URL/rest/v1/users?order=created_at.desc&limit=20" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | \- python3 -c "import sys,json; [print(f'{u[\"email\"]} - {u[\"created_at\"]}') for u in json.load(sys.stdin)]"-```--### List Users with Credits--```bash-curl -s "$SUPABASE_URL/rest/v1/credits?amount=gt.0&order=amount.desc&limit=20" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```--### List Active Subscriptions--```bash-curl -s "$SUPABASE_URL/rest/v1/cloud_subscriptions?status=eq.active" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```--### Get Sales Stats--```bash-curl -s -X POST "$SUPABASE_URL/rest/v1/rpc/get_sales_stats" \- -H "apikey: $SUPABASE_KEY" \- -H "Authorization: Bearer $SUPABASE_KEY" | python3 -m json.tool-```-------## Query Syntax--### Filters-- `eq.VALUE` - Equals-- `neq.VALUE` - Not equals-- `gt.VALUE` - Greater than-- `lt.VALUE` - Less than-- `gte.VALUE` - Greater than or equal-- `lte.VALUE` - Less than or equal-- `like.*pattern*` - Pattern match-- `ilike.*pattern*` - Case-insensitive pattern-- `is.null` / `is.true` / `is.false`--### Ordering-- `order=column.asc`-- `order=column.desc`--### Pagination-- `limit=N`-- `offset=N`--### Select Specific Columns-- `select=col1,col2,col3`-------## Important Notes--1. **Service Key Required:** Use `SUPABASE_SERVICE_KEY` (not anon key) for admin operations-2. **Never expose keys:** Always load from environment variables-3. **User privacy:** Only query specific users when needed for support-4. **Verify payments:** Cross-reference with Stripe before adding credits manually