fix: exclude posthog's own errors from posthog

This commit is contained in:
2026-04-22 16:46:22 +07:00 Unverified
parent f56344f06a
commit 26dbc93ee7
+9 -2
View File
@@ -11,8 +11,15 @@ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN!, {
if (event?.event === "$exception") {
const exceptionList = event.properties.$exception_list || [];
const exception = exceptionList[0];
if (exception?.value === "NEXT_REDIRECT") {
return null; // Drop it entirely
if (exception) {
if (
exception.$exception_source?.includes("posthog") ||
exception.value?.includes("posthog") ||
exception.value?.includes("__ph_opt_in_out") ||
exception.value === "NEXT_REDIRECT"
) {
return null;
}
}
}
return event;