Skip to content

The platform for continuously improving AI agents.

Upgrade posthog SDK, drop browser error noise, recover Clerk load failures (#313)

Freyam Mehta2ecb60672359
diff --git a/frontend/src/analytics-errors.test.ts b/frontend/src/analytics-errors.test.ts
new file mode 100644
index 00000000..34353de4
--- /dev/null
+++ b/frontend/src/analytics-errors.test.ts
@@ -0,0 +1,36 @@
+// @vitest-environment jsdom
+// covers: console-logic
+import { expect, it, vi } from "vitest";
+
+const captureException = vi.fn();
+
+vi.mock("posthog-js", () => ({
+ default: { captureException, init: vi.fn() },
+}));
+
+it("drops browser noise from window error capture and keeps app errors", async () => {
+ vi.stubEnv("VITE_SELF_HOSTED", "false");
+ vi.stubEnv("MODE", "production");
+ await import("./analytics");
+ const appError = new Error("boom");
+
+ window.dispatchEvent(new ErrorEvent("error", { message: "Script error." }));
+ window.dispatchEvent(
+ new ErrorEvent("error", {
+ message: "ResizeObserver loop completed with undelivered notifications.",
+ })
+ );
+ window.dispatchEvent(
+ new ErrorEvent("error", {
+ error: new TypeError(
+ "undefined is not an object (evaluating 'window.ethereum.selectedAddress')"
+ ),
+ message: "",
+ })
+ );
+ window.dispatchEvent(new ErrorEvent("error", { error: appError, message: "boom" }));
+ await vi.dynamicImportSettled();
+
+ expect(captureException).toHaveBeenCalledOnce();
+ expect(captureException).toHaveBeenCalledWith(appError);
+});
diff --git a/frontend/src/analytics.ts b/frontend/src/analytics.ts
index 98bce5f0..00ad5cbd 100644
--- a/frontend/src/analytics.ts
+++ b/frontend/src/analytics.ts
@@ -19,8 +19,14 @@ const client = enabled
.catch(() => undefined)
: undefined;
+// Browsers mask cross-origin errors as "Script error.", ResizeObserver loop notices are benign,
+// and wallet extensions inject scripts that throw on window.ethereum. None has an actionable frame.
+const IGNORED_WINDOW_ERRORS = [/^Script error\.?$/, /ResizeObserver loop/, /window\.ethereum/];
+
if (enabled && typeof window !== "undefined") {
window.addEventListener("error", (event) => {
+ const text = `${event.message} ${event.error instanceof Error ? event.error.message : ""}`;
+ if (IGNORED_WINDOW_ERRORS.some((pattern) => pattern.test(text.trim()))) return;
void client?.then((posthog) =>
posthog?.captureException(event.error ?? new Error(String(event.message)))
);
diff --git a/frontend/src/components/route-error.tsx b/frontend/src/components/route-error.tsx
index 72e7463d..af4c0008 100644
--- a/frontend/src/components/route-error.tsx
+++ b/frontend/src/components/route-error.tsx
@@ -12,6 +12,7 @@ import { Icon } from "@/components/ui/icons";
import { PageHeader } from "@/components/ui/page-header";
import { LoadingState } from "@/components/ui/spinner";
import { ApiError } from "@/lib/api-error";
+import { retryAuthLoad } from "@/lib/auth-load-recovery";
import { isChunkLoadError } from "@/lib/chunk-error";
import { errorMessage } from "@/lib/notify";
@@ -172,6 +173,10 @@ export function RouteNotFound() {
}
export function AuthenticationLoadError() {
+ useEffect(() => {
+ retryAuthLoad("script");
+ }, []);
+
return (
<ConnectionScene>
<PageHeader className={connectionHeading} title="Sign in unavailable" />
diff --git a/frontend/src/lib/auth-load-recovery.test.ts b/frontend/src/lib/auth-load-recovery.test.ts
new file mode 100644
index 00000000..667686d1
--- /dev/null
+++ b/frontend/src/lib/auth-load-recovery.test.ts
@@ -0,0 +1,59 @@
+// @vitest-environment jsdom
+// covers: console-logic
+import { beforeEach, expect, it, vi } from "vitest";
+
+const capture = vi.fn();
+
+vi.mock("posthog-js", () => ({
+ default: { capture, captureException: vi.fn(), init: vi.fn() },
+}));
+
+const reload = vi.fn();
+
+beforeEach(() => {
+ vi.stubEnv("VITE_SELF_HOSTED", "false");
+ vi.stubEnv("MODE", "production");
+ vi.resetModules();
+ window.sessionStorage.clear();
+ reload.mockClear();
+ capture.mockClear();
+ Object.defineProperty(window, "location", {
+ configurable: true,
+ value: { ...window.location, reload },
+ });
+});
+
+it("reloads once after an auth load failure and records the recovery after the reload", async () => {
+ const before = await import("./auth-load-recovery");
+ expect(before.retryAuthLoad("script")).toBe(true);
+
+ vi.resetModules();
+ const after = await import("./auth-load-recovery");
+ after.markAuthLoaded();
+ after.markAuthLoaded();
+ expect(after.retryAuthLoad("script")).toBe(false);
+ await vi.dynamicImportSettled();
+
+ expect(reload).toHaveBeenCalledOnce();
+ expect(capture).toHaveBeenCalledOnce();
+ expect(capture).toHaveBeenCalledWith("auth_load_recovered", { failure: "script" });
+});
+
+it("reloads once on a Clerk chunk failure but not on an app chunk failure", async () => {
+ const { installClerkChunkRecovery } = await import("./auth-load-recovery");
+ installClerkChunkRecovery();
+ const clerkChunkError = new Error(
+ "Loading chunk 9573 failed. (error: https://clerk.example.com/npm/@clerk/clerk-js@5/dist/ui-common.js)"
+ );
+
+ window.dispatchEvent(
+ new ErrorEvent("error", {
+ error: new Error("Loading chunk 344 failed. (error: https://example.com/assets/app.js)"),
+ })
+ );
+ expect(reload).not.toHaveBeenCalled();
+
+ window.dispatchEvent(Object.assign(new Event("unhandledrejection"), { reason: clerkChunkError }));
+ window.dispatchEvent(new ErrorEvent("error", { error: clerkChunkError }));
+ expect(reload).toHaveBeenCalledOnce();
+});
diff --git a/frontend/src/lib/auth-load-recovery.ts b/frontend/src/lib/auth-load-recovery.ts
new file mode 100644
index 00000000..2e87722d
--- /dev/null
+++ b/frontend/src/lib/auth-load-recovery.ts
@@ -0,0 +1,50 @@
+import { trackEvent } from "@/analytics";
+import { isChunkLoadError } from "@/lib/chunk-error";
+
+export type AuthLoadFailure = "script" | "chunk";
+
+// One automatic reload per tab: "done" stays set after recovery, so a repeat failure cannot loop.
+const RETRY_KEY = "overmind.auth-load-retry";
+
+function readRetry(): string | null | undefined {
+ try {
+ return window.sessionStorage.getItem(RETRY_KEY);
+ } catch {
+ return undefined;
+ }
+}
+
+function writeRetry(value: string): boolean {
+ try {
+ window.sessionStorage.setItem(RETRY_KEY, value);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+/** Reloads once per tab and returns true; returns false when the fallback must show instead. */
+export function retryAuthLoad(failure: AuthLoadFailure): boolean {
+ if (readRetry() !== null) return false;
+ if (!writeRetry(failure)) return false;
+ window.location.reload();
+ return true;
+}
+
+export function markAuthLoaded() {
+ const failure = readRetry();
+ if (failure !== "script" && failure !== "chunk") return;
+ if (!writeRetry("done")) return;
+ trackEvent("auth_load_recovered", { failure });
+}
+
+function retryClerkChunk(err: unknown) {
+ const message = String((err as { message?: unknown })?.message ?? err);
+ if (isChunkLoadError(err) && /clerk/i.test(message)) retryAuthLoad("chunk");
+}
+
+// Clerk's hosted script fetches its own chunks, outside the app's lazy-route recovery.
+export function installClerkChunkRecovery() {
+ window.addEventListener("error", (event) => retryClerkChunk(event.error ?? event.message));
+ window.addEventListener("unhandledrejection", (event) => retryClerkChunk(event.reason));
+}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 960f9a09..e54fdb92 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -1,4 +1,4 @@
-import { StrictMode } from "react";
+import { StrictMode, useEffect } from "react";
import ReactDOM from "react-dom/client";
import { ClerkFailed, ClerkLoaded, ClerkLoading, ClerkProvider } from "@clerk/clerk-react";
@@ -21,10 +21,12 @@ import "./analytics";
import { config } from "./config";
import { AuthProvider } from "./contexts/auth-context";
import { getContext } from "./integrations/tanstack-query";
+import { installClerkChunkRecovery, markAuthLoaded } from "./lib/auth-load-recovery";
import { installAutohideScrollbars } from "./lib/autohide-scrollbars";
import { routeTree } from "./routeTree.gen";
installAutohideScrollbars();
+if (config.clerkReady) installClerkChunkRecovery();
export function getRouter() {
const router = createTanStackRouter({
@@ -47,6 +49,11 @@ declare module "@tanstack/react-router" {
const router = getRouter();
+function ClerkReady() {
+ useEffect(markAuthLoaded, []);
+ return null;
+}
+
function App() {
return (
<AuthProvider>
@@ -61,6 +68,7 @@ function App() {
<AuthenticationLoadError />
</ClerkFailed>
<ClerkLoaded>
+ <ClerkReady />
<AuthRouter router={router} />
</ClerkLoaded>
</>
diff --git a/overmind/overmind/__init__.py b/overmind/overmind/__init__.py
index dc610d84..5332daaa 100644
--- a/overmind/overmind/__init__.py
+++ b/overmind/overmind/__init__.py
@@ -10,7 +10,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any
-__version__ = "0.1.118"
+__version__ = "0.1.119"
from .client import Client, ModelDeleted, OvermindInferenceError
diff --git a/overmind/pyproject.toml b/overmind/pyproject.toml
index 030d20bd..2c9b3dd6 100644
--- a/overmind/pyproject.toml
+++ b/overmind/pyproject.toml
@@ -46,7 +46,7 @@ license = { text = "MIT" }
name = "overmind"
readme = "README.md"
requires-python = ">=3.10,<4" # todo; remove the upper bound
-version = "0.1.118"
+version = "0.1.119"
[project.urls]
"Agent setup" = "https://console.overmindlab.ai/setup.md"
@@ -60,7 +60,7 @@ version = "0.1.118"
[project.optional-dependencies]
- analytics = ["posthog>=7.53.0"]
+ analytics = ["posthog>=7.84.2"]
tracing = [
"openinference-instrumentation-langchain>=0.1.72",
"opentelemetry-api>=1.35.0",
diff --git a/overmind/uv.lock b/overmind/uv.lock
index 78cb7bee..392c80cb 100644
--- a/overmind/uv.lock
+++ b/overmind/uv.lock
@@ -300,7 +300,7 @@ name = "exceptiongroup"
version = "1.3.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "typing-extensions", marker = "python_full_version < '3.11'" },
+ { name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" }
wheels = [
@@ -351,8 +351,8 @@ name = "httpcore2"
version = "2.13.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
- { name = "h11", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" },
- { name = "truststore", marker = "python_full_version < '3.12' or sys_platform != 'emscripten'" },
+ { name = "h11" },
+ { name = "truststore" },
]
sdist = { url = "https://files.pythonhosted.org/packages/cb/f3/1db7aa2bc2524062192bb0e0323969492d1883152a232fe36eea65f4e35c/httpcore2-2.13.1.tar.gz", hash = "sha256:e0aa977abe17e69a3b820a24542a6fa88702676d83880b8d194dcd18408e5103", size = 68071, upload-time = "2026-09-23T07:47:22.372Z" }
wheels = [
@@ -923,7 +923,7 @@ wheels = [
[[package]]
name = "overmind"
-version = "0.1.118"
+version = "0.1.119"
source = { editable = "." }
dependencies = [
{ name = "packaging" },
@@ -989,7 +989,7 @@ requires-dist = [
{ name = "opentelemetry-semantic-conventions", marker = "extra == 'tracing'", specifier = ">=0.60b1" },
{ name = "opentelemetry-semantic-conventions-ai", marker = "extra == 'tracing'", specifier = ">=0.4.13" },
{ name = "packaging", specifier = ">=24.0" },
- { name = "posthog", marker = "extra == 'analytics'", specifier = ">=7.53.0" },
+ { name = "posthog", marker = "extra == 'analytics'", specifier = ">=7.84.2" },
{ name = "requests", specifier = ">=2.31.0" },
{ name = "rich", specifier = ">=14.0.0" },
{ name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0.0" },
@@ -1040,7 +1040,7 @@ wheels = [
[[package]]
name = "posthog"
-version = "7.53.0"
+version = "7.84.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "backoff" },
@@ -1048,9 +1048,9 @@ dependencies = [
{ name = "requests" },
{ name = "typing-extensions" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/f2/c4/17a2a764a63e061f768a56d50c245e3012da536b5a15ed2521616b8869b7/posthog-7.53.0.tar.gz", hash = "sha256:38223a8769b9db7ab906d32f5b87c4cde534cc91b30f1dcfa4443577819e068c", size = 565313, upload-time = "2026-09-11T17:51:16.199Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/29/bc/cfe9298758f358e30940ca6c353f1073b384f322c6bda50493d910093628/posthog-7.84.2.tar.gz", hash = "sha256:48080116094c12423c50b2d916d15a000b584b0bd2595649d7caacdfbe41db51", size = 904946, upload-time = "2026-11-06T08:17:58.573Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/03/9d/4af58450b986666c810dc1fbae04e41cdec62ab31ae1e0e51bb5a4b75f71/posthog-7.53.0-py3-none-any.whl", hash = "sha256:ca9176334cf0c7799fe5518f7b9dc02d3f2f709a859da4332f14b3586b9d4554", size = 662783, upload-time = "2026-09-11T17:51:14.275Z" },
+ { url = "https://files.pythonhosted.org/packages/34/bb/36d1a6180a2ca8b09a6a0b654ab8b1cc54c489fa374b5c2fb162c1899059/posthog-7.84.2-py3-none-any.whl", hash = "sha256:a3765d4f3078bb3e1eba755885bb7b284353c8d02599cf906f4072c22a5759cc", size = 1047790, upload-time = "2026-11-06T08:17:56.326Z" },
]
[[package]]
diff --git a/pyproject.toml b/pyproject.toml
index dc30e006..1f83a2d0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -51,7 +51,7 @@ dependencies = [
"gunicorn>=26.2.0",
"uvicorn-worker>=0.4.0",
"jsonschema>=4.26.0",
- "posthog>=7.56.0",
+ "posthog>=7.84.2",
"rapidfuzz>=3.14.6",
"langdetect>=1.0.9",
"datasketch>=2.0.0",
diff --git a/uv.lock b/uv.lock
index 0a841e7e..3646541a 100644
--- a/uv.lock
+++ b/uv.lock
@@ -368,7 +368,7 @@ requires-dist = [
{ name = "overmind", specifier = ">=0.1.97" },
{ name = "pandas", specifier = ">=2.2.0" },
{ name = "pgvector", specifier = ">=0.4.2" },
- { name = "posthog", specifier = ">=7.56.0" },
+ { name = "posthog", specifier = ">=7.84.2" },
{ name = "protobuf", specifier = ">=6.33.5,<7" },
{ name = "psycopg2-binary", specifier = ">=2.9.10" },
{ name = "pyarrow", specifier = ">=17" },
@@ -2919,7 +2919,7 @@ wheels = [
[[package]]
name = "posthog"
-version = "7.56.0"
+version = "7.84.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "backoff" },
@@ -2927,9 +2927,9 @@ dependencies = [
{ name = "requests" },
{ name = "typing-extensions" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/ba/c8/f4b196681c306527c1caf32806a75cb992035ede9728b0c920e8699b9ded/posthog-7.56.0.tar.gz", hash = "sha256:719749951faa2f034479aa5b43aa195d2e204bb3e666d2d0f660b06c9abb1883", size = 591272, upload-time = "2026-09-17T20:31:14.769Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/29/bc/cfe9298758f358e30940ca6c353f1073b384f322c6bda50493d910093628/posthog-7.84.2.tar.gz", hash = "sha256:48080116094c12423c50b2d916d15a000b584b0bd2595649d7caacdfbe41db51", size = 904946, upload-time = "2026-11-06T08:17:58.573Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/a8/a5/6cae46f168efc86cc181ead915f426d7e1ba1497ca037659c04565804581/posthog-7.56.0-py3-none-any.whl", hash = "sha256:6f6e2be095e2952fec5691afcc0a92dd70b55dea0ea8212a67eafde20edbbfdd", size = 690954, upload-time = "2026-09-17T20:31:12.853Z" },
+ { url = "https://files.pythonhosted.org/packages/34/bb/36d1a6180a2ca8b09a6a0b654ab8b1cc54c489fa374b5c2fb162c1899059/posthog-7.84.2-py3-none-any.whl", hash = "sha256:a3765d4f3078bb3e1eba755885bb7b284353c8d02599cf906f4072c22a5759cc", size = 1047790, upload-time = "2026-11-06T08:17:56.326Z" },
]
[[package]]