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
feat: attribution funnel tracking + structured onboarding analytics
Louis Beaumont2677c0b6f29c
diff --git a/apps/screenpipe-app-tauri/app/onboarding/page.tsx b/apps/screenpipe-app-tauri/app/onboarding/page.tsxindex a3cb2c568..73f47ad1a 100644--- a/apps/screenpipe-app-tauri/app/onboarding/page.tsx+++ b/apps/screenpipe-app-tauri/app/onboarding/page.tsx@@ -86,6 +86,10 @@ export default function OnboardingPage() {setIsTransitioning(true);posthog.capture(`onboarding_${currentSlide}_completed`);+ posthog.capture("onboarding_step_reached", {+ step_name: `${currentSlide}_completed`,+ step_index: currentSlide === "setup" ? 4 : 5,+ });try {await commands.setOnboardingStep("shortcut");diff --git a/apps/screenpipe-app-tauri/components/onboarding/status.tsx b/apps/screenpipe-app-tauri/components/onboarding/status.tsxindex 2e99c73f1..ac09bbc9b 100644--- a/apps/screenpipe-app-tauri/components/onboarding/status.tsx+++ b/apps/screenpipe-app-tauri/components/onboarding/status.tsx@@ -125,6 +125,11 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({if (setupState === "recording" && !hasAdvancedRef.current) {hasAdvancedRef.current = true;const elapsed = Date.now() - mountTimeRef.current;+ posthog.capture("onboarding_step_reached", {+ step_name: "recording_started",+ step_index: 3,+ time_spent_ms: elapsed,+ });const minDisplay = 1500;const delay = Math.max(0, minDisplay - elapsed);setTimeout(() => handleNextSlide(), delay);@@ -240,8 +245,23 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({const accessibilityOk = perms.accessibility === "granted" || perms.accessibility === "notNeeded";if (screenOk && audioOk && accessibilityOk && !hasStartedRef.current) {setProgress((prev) => ({ ...prev, permissions: true }));+ posthog.capture("onboarding_step_reached", {+ step_name: "permissions_granted",+ step_index: 1,+ time_spent_ms: Date.now() - mountTimeRef.current,+ screen: perms.screenRecording,+ mic: perms.microphone,+ accessibility: perms.accessibility,+ });setSetupState("ready");} else if (!hasStartedRef.current) {+ posthog.capture("onboarding_step_reached", {+ step_name: "permissions_needed",+ step_index: 0,+ screen: perms.screenRecording,+ mic: perms.microphone,+ accessibility: perms.accessibility,+ });setSetupState("needs-permissions");}} catch (error) {@@ -311,7 +331,17 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({}if (setupState === "ready" || setupState === "starting") {setIsStuck(false);- stuckTimeoutRef.current = setTimeout(() => setIsStuck(true), STUCK_TIMEOUT_MS);+ stuckTimeoutRef.current = setTimeout(() => {+ setIsStuck(true);+ posthog.capture("onboarding_stuck", {+ setup_state: setupState,+ time_spent_ms: Date.now() - mountTimeRef.current,+ progress_permissions: progress.permissions,+ progress_server: progress.serverStarted,+ progress_audio: progress.audioReady,+ progress_vision: progress.visionReady,+ });+ }, STUCK_TIMEOUT_MS);} else {setIsStuck(false);}@@ -333,7 +363,13 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({const handleStartRecording = async () => {if (isStartingRef.current) return;isStartingRef.current = true;+ const timeToStart = Date.now() - mountTimeRef.current;posthog.capture("screenpipe_setup_start");+ posthog.capture("onboarding_step_reached", {+ step_name: "recording_start",+ step_index: 2,+ time_spent_ms: timeToStart,+ });setSetupState("starting");try {const healthCheck = await fetch("http://localhost:3030/health", {diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsxindex b101416c2..28b99b8ef 100644--- a/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/app-context-popover.tsx@@ -1,8 +1,10 @@import { useMemo, useState } from "react";import { createPortal } from "react-dom";import { StreamTimeSeriesResponse } from "@/components/rewind/timeline";-import { Copy, Search, X, Globe, AppWindow, Mic, Clock } from "lucide-react";+import { Copy, Search, X, Globe, AppWindow, Mic, Clock, ExternalLink } from "lucide-react";import { format } from "date-fns";+import { open } from "@tauri-apps/plugin-shell";+import { commands } from "@/lib/utils/tauri";interface AppContextData {frameCount: number;@@ -206,7 +208,7 @@ export function AppContextPopover({</div>)}- {/* Top URLs */}+ {/* Top URLs — clickable */}{data.topUrls.length > 0 && (<div className="space-y-1"><div className="flex items-center gap-1.5 text-muted-foreground">@@ -215,13 +217,18 @@ export function AppContextPopover({</div><div className="pl-4 space-y-0.5">{data.topUrls.map((u, i) => (- <div+ <buttonkey={i}- className="text-popover-foreground truncate"+ className="flex items-center gap-1 text-blue-400 hover:text-blue-300 truncate w-full text-left transition-colors"title={u.url}+ onClick={() => {+ open(u.url).catch(() => {});+ commands.closeWindow("Main").catch(() => {});+ }}>- {extractDomain(u.url)}- </div>+ <ExternalLink className="w-2.5 h-2.5 flex-shrink-0" />+ <span className="truncate">{extractDomain(u.url)}</span>+ </button>))}</div></div>diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex ca057e6e8..7b86e3d8d 100644--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -527,11 +527,22 @@ export const SettingsProvider: React.FC<{ children: React.ReactNode }> = ({ chiltoken} as User;- // if user was not logged in, send posthog event app_login with email+ // if user was not logged in, send posthog event and bridge identityif (!settings.user?.id) {posthog.capture("app_login", {email: userData.email,});+ // Bridge app identity → website identity via email alias+ // This merges the anonymous app profile with any website profile+ // that used the same email during checkout+ if (userData.email) {+ posthog.alias(userData.email);+ posthog.people?.set({+ email: userData.email,+ app_user_id: userData.id,+ login_source: "app",+ });+ }}// cache the resultdiff --git a/crates/screenpipe-server/src/analytics.rs b/crates/screenpipe-server/src/analytics.rsindex 074c241f3..3eb7487ff 100644--- a/crates/screenpipe-server/src/analytics.rs+++ b/crates/screenpipe-server/src/analytics.rs@@ -182,3 +182,14 @@ pub fn check_macos_version() {pub fn check_macos_version() {// Only relevant on macOS}++/// Track API usage (called periodically from the server router).+/// Fires a PostHog event with the number of API requests in the last interval.+pub fn track_api_usage(request_count: usize) {+ capture_event_nonblocking(+ "api_usage_5min",+ json!({+ "request_count": request_count,+ }),+ );+}diff --git a/crates/screenpipe-server/src/server.rs b/crates/screenpipe-server/src/server.rsindex e6c9e221e..0406d74eb 100644--- a/crates/screenpipe-server/src/server.rs+++ b/crates/screenpipe-server/src/server.rs@@ -121,6 +121,10 @@ pub struct AppState {pub sync_handle: Option<Arc<SyncServiceHandle>>,/// Runtime sync state (initialized via /sync/init endpoint)pub sync_state: SyncState,+ /// Video quality preset for frame extraction (JPEG quality).+ pub video_quality: String,+ /// API request counter for usage analytics+ pub api_request_count: Arc<AtomicUsize>,}// Update the SearchQuery struct@@ -1315,6 +1319,7 @@ pub struct SCServer {enable_pipe: bool,use_pii_removal: bool,sync_handle: Option<Arc<SyncServiceHandle>>,+ video_quality: String,}impl SCServer {@@ -1329,6 +1334,7 @@ impl SCServer {audio_manager: Arc<AudioManager>,enable_pipe: bool,use_pii_removal: bool,+ video_quality: String,) -> Self {SCServer {db,@@ -1341,6 +1347,7 @@ impl SCServer {enable_pipe,use_pii_removal,sync_handle: None,+ video_quality,}}@@ -1376,6 +1383,23 @@ impl SCServer {}pub async fn create_router(&self, enable_frame_cache: bool) -> Router {+ let api_request_count = Arc::new(AtomicUsize::new(0));++ // Spawn periodic API usage reporter (every 5 minutes)+ let counter_clone = api_request_count.clone();+ tokio::spawn(async move {+ let mut interval = tokio::time::interval(Duration::from_secs(300));+ loop {+ interval.tick().await;+ let count = counter_clone.swap(0, Ordering::Relaxed);+ if count > 0 {+ info!("api_usage_5min: {} requests", count);+ // Fire analytics event for API usage tracking+ analytics::track_api_usage(count);+ }+ }+ });+let app_state = Arc::new(AppState {db: self.db.clone(),audio_manager: self.audio_manager.clone(),@@ -1421,6 +1445,8 @@ impl SCServer {sync_handle: self.sync_handle.clone(),// Runtime sync state (initialized via /sync/init)sync_state: sync_api::new_sync_state(),+ video_quality: self.video_quality.clone(),+ api_request_count: api_request_count.clone(),});let cors = CorsLayer::new()@@ -1497,7 +1523,14 @@ impl SCServer {.route("/ws/events", get(ws_events_handler)).route("/ws/health", get(ws_health_handler)).route("/frames/export", get(handle_video_export_ws))- .with_state(app_state)+ .with_state(app_state.clone())+ .layer(axum::middleware::from_fn(move |req: axum::extract::Request, next: axum::middleware::Next| {+ let counter = app_state.api_request_count.clone();+ async move {+ counter.fetch_add(1, Ordering::Relaxed);+ next.run(req).await+ }+ })).layer(cors).layer(TraceLayer::new_for_http().make_span_with(DefaultMakeSpan::default()))}@@ -3210,7 +3243,8 @@ pub async fn get_frame_data(// If not in cache or cache disabled, get from databasematch state.db.get_frame(frame_id).await {Ok(Some((file_path, offset_index))) => {- match extract_frame_from_video(&file_path, offset_index).await {+ let jpeg_q = crate::video::video_quality_to_jpeg_q(&state.video_quality);+ match extract_frame_from_video(&file_path, offset_index, jpeg_q).await {Ok(frame_path) => {// Apply PII redaction if requestedif query.redact_pii {