Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(phai): make debug logs opt-in instead of on by default (#73181)

Georgiy Tarasov6890958c85ab
diff --git a/products/posthog_ai/frontend/logics/debugLogsLogic.test.ts b/products/posthog_ai/frontend/logics/debugLogsLogic.test.ts
index ebd92a7fb900..fe54d985284e 100644
--- a/products/posthog_ai/frontend/logics/debugLogsLogic.test.ts
+++ b/products/posthog_ai/frontend/logics/debugLogsLogic.test.ts
@@ -34,10 +34,10 @@ describe('debugLogsLogic', () => {
logic?.unmount()
})
- it('defaults to showing debug logs for staff with no stored preference', () => {
+ it('hides debug logs for staff with no stored preference until explicitly enabled', () => {
setup({ user: { is_staff: true }, isDev: false })
- expect(logic.values.debugLogsEnabled).toBe(true)
- expect(logic.values.showDebugLogs).toBe(true)
+ expect(logic.values.debugLogsEnabled).toBe(false)
+ expect(logic.values.showDebugLogs).toBe(false)
})
it('offers no toggle to a staff user who is also impersonating, but still forces logs on', () => {
diff --git a/products/posthog_ai/frontend/logics/debugLogsLogic.ts b/products/posthog_ai/frontend/logics/debugLogsLogic.ts
index b7fa29d5b3c8..3a2181d466b2 100644
--- a/products/posthog_ai/frontend/logics/debugLogsLogic.ts
+++ b/products/posthog_ai/frontend/logics/debugLogsLogic.ts
@@ -38,9 +38,10 @@ export type debugLogsLogicType = MakeLogicType<
/**
* Staff-only preference for whether `_posthog/console` debug rows surface in the run thread. Persisted
- * to localStorage and shared across every run surface (singleton, unkeyed), enabled by default. An
- * impersonated session always forces debug logs on, independent of the persisted toggle, so an engineer
- * debugging a customer's session never has them silently hidden.
+ * to localStorage and shared across every run surface (singleton, unkeyed), off by default — debug rows
+ * render only after the user explicitly opts in. An impersonated session always forces debug logs on,
+ * independent of the persisted toggle, so an engineer debugging a customer's session never has them
+ * silently hidden.
*/
export const debugLogsLogic = kea<debugLogsLogicType>([
path(['products', 'posthog_ai', 'frontend', 'logics', 'debugLogsLogic']),
@@ -52,7 +53,7 @@ export const debugLogsLogic = kea<debugLogsLogicType>([
}),
reducers({
debugLogsEnabled: [
- true,
+ false,
{ persist: true, storageKey: 'posthog_ai.debugLogsEnabled' },
{
setDebugLogsEnabled: (_, { enabled }) => enabled,
@@ -72,7 +73,7 @@ export const debugLogsLogic = kea<debugLogsLogicType>([
],
/**
* Whether debug rows should actually render. Impersonation always shows them; otherwise staff/dev
- * see them subject to the persisted toggle (on by default); everyone else never does.
+ * see them only after opting in via the persisted toggle (off by default); everyone else never does.
*/
showDebugLogs: [
(s) => [s.user, s.canControlDebugLogs, s.debugLogsEnabled],
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDebugLogsMenu.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDebugLogsMenu.tsx
index a78dd67b71cb..6c7e759a4fff 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDebugLogsMenu.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDebugLogsMenu.tsx
@@ -7,7 +7,7 @@ import { debugLogsLogic } from '../../../logics/debugLogsLogic'
/**
* Staff-only menu exposing the debug-logs toggle for the run thread. Renders nothing unless the current
* user may control debug logs (staff or local dev) — impersonated sessions force debug logs on and have
- * no toggle. The checkmark reflects the persisted (localStorage) preference, on by default.
+ * no toggle. The checkmark reflects the persisted (localStorage) preference, off by default.
*/
export function TaskDebugLogsMenu(): JSX.Element | null {
const { canControlDebugLogs, debugLogsEnabled } = useValues(debugLogsLogic)