Skip to content

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

chore: track errors better

Louis Beaumontd944a3e90e02
diff --git a/screenpipe-app-tauri/components/onboarding/status.tsx b/screenpipe-app-tauri/components/onboarding/status.tsx
index 4e3cbf74b..e2737c333 100644
--- a/screenpipe-app-tauri/components/onboarding/status.tsx
+++ b/screenpipe-app-tauri/components/onboarding/status.tsx
@@ -17,6 +17,7 @@ import {
} from "../ui/tooltip";
import { useSettings } from "@/lib/hooks/use-settings";
import { Label } from "../ui/label";
+import { trackError } from "@/lib/opentelemetry";
interface OnboardingStatusProps {
className?: string;
@@ -136,6 +137,12 @@ const OnboardingStatus: React.FC<OnboardingStatusProps> = ({
console.error("error checking status:", error);
setStatus("error");
setIsLoading(false);
+ trackError(error, {
+ operation: "screenpipe-setup-failure",
+ additionalAttributes: {
+ useChineseMirror: String(useChineseMirror),
+ },
+ });
}
};
diff --git a/screenpipe-app-tauri/lib/opentelemetry.ts b/screenpipe-app-tauri/lib/opentelemetry.ts
index 91e3ecb56..b437aa040 100644
--- a/screenpipe-app-tauri/lib/opentelemetry.ts
+++ b/screenpipe-app-tauri/lib/opentelemetry.ts
@@ -45,3 +45,42 @@ export function initOpenTelemetry(projectId: string, sessionId: string) {
span.end();
});
}
+
+let tracerProvider: WebTracerProvider | null = null;
+
+export function getTracerProvider() {
+ if (!tracerProvider) {
+ tracerProvider = new WebTracerProvider();
+ }
+ return tracerProvider;
+}
+
+export function trackError(
+ error: unknown,
+ context: {
+ operation: string;
+ additionalAttributes?: Record<string, string>;
+ }
+) {
+ const isDebug = process.env.TAURI_ENV_DEBUG === "true";
+ if (isDebug || window.location.origin.includes("localhost")) return;
+
+ const provider = getTracerProvider();
+ const tracer = provider.getTracer("screenpipe-error-tracker");
+ const span = tracer.startSpan(context.operation);
+
+ span.setStatus({ code: 2 }); // OpenTelemetry error status code
+ span.setAttribute("error.type", context.operation);
+ span.setAttribute(
+ "error.message",
+ error instanceof Error ? error.message : String(error)
+ );
+
+ if (context.additionalAttributes) {
+ Object.entries(context.additionalAttributes).forEach(([key, value]) => {
+ span.setAttribute(key, value);
+ });
+ }
+
+ span.end();
+}
diff --git a/screenpipe-app-tauri/package.json b/screenpipe-app-tauri/package.json
index 5911873e0..6f78b6e25 100644
--- a/screenpipe-app-tauri/package.json
+++ b/screenpipe-app-tauri/package.json
@@ -6,6 +6,7 @@
"start": "next start",
"lint": "next lint",
"build": "next build",
+ "prebuild": "bun scripts/pre_build.js",
"tauri": "echo '\u001b[33mWarning: did you run bun scripts/pre_build.js and ALL other instructions carefully listed in https://docs.screenpi.pe/docs/getting-started ?\u001b[0m' && tauri",
"clean": "rm -rf out && cargo clean && rm -rf src-tauri/{screenpipe-*,tesseract-*,ffmpeg} node_modules"
},