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(error-tracking): hide empty code variables banner (#114512)

Aleksander Błaszkiewicz61a8655e6f7e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a52975447c29..a449da77be41 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -844,6 +844,10 @@ snapshots:
hash: v1.k794b7964.2014d85e0e0f2eaee80d7ac27bbed9b816151836e22ddb54b3144552a5ba4f2d.66aPnDPxPzkxxC9x7SVRcTe0ZfnWvct1oJoIxASu8RM
components-errors-collapsibleframe--no-context--light:
hash: v1.k794b7964.196237a32d3041a831f2c8f9c654eb07c54d88ab95f0923d01eb2f266785f28a.bBMfmO_AzY90MhlKlfRUtfPYirEtPu8RMHNXdJtM-oE
+ components-errors-collapsibleframe--python-frame-without-variables--dark:
+ hash: v1.k794b7964.aa85472f353f780f7d19630f6faeb8dd2e12f704b3ceef2adf36e6946207f347.psPGOeBCvmEwngbSHp4GfOmV9RD8qxoK7vfzWiIFDas
+ components-errors-collapsibleframe--python-frame-without-variables--light:
+ hash: v1.k794b7964.c5dadb314ff273b6b20d779702c78ea836b577df3f4aeae84d6616a979ca4739.IvDhZGLYMJpZU5YcAaEs_AbdvkjX3-TRkpXMScgkzUk
components-errors-collapsibleframe--rust-frame-with-context--dark:
hash: v1.k794b7964.399f38c3d856602ed1fc9440e3eb6b8f67a2ec8ef1ad3effbdb0a197c8c54810.SRlaE7DNBAQIzbakDZISA2lFWTrvrVa6mZepiVStVm0
components-errors-collapsibleframe--rust-frame-with-context--light:
diff --git a/frontend/src/lib/components/Errors/Frame/CodeVariablesInlineBanner.tsx b/frontend/src/lib/components/Errors/Frame/CodeVariablesInlineBanner.tsx
deleted file mode 100644
index dbcf617ed0b3..000000000000
--- a/frontend/src/lib/components/Errors/Frame/CodeVariablesInlineBanner.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { useActions, useValues } from 'kea'
-
-import { IconX } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { errorPropertiesLogic } from 'lib/components/Errors/errorPropertiesLogic'
-import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'
-import { Link } from 'lib/lemon-ui/Link'
-
-const SUPPORTED_RUNTIMES = ['python']
-
-export function CodeVariablesInlineBanner(): JSX.Element | null {
- const { exceptionAttributes } = useValues(errorPropertiesLogic)
-
- const dismissLogic = lemonBannerLogic({
- dismissKey: `code-variables-inline-banner-${exceptionAttributes?.runtime}`,
- })
- const { isDismissed } = useValues(dismissLogic)
- const { dismiss } = useActions(dismissLogic)
-
- const isSupportedRuntime = exceptionAttributes?.runtime && SUPPORTED_RUNTIMES.includes(exceptionAttributes.runtime)
-
- if (!isSupportedRuntime || isDismissed) {
- return null
- }
-
- return (
- <div className="border-t border-[color:var(--frame-border,var(--color-border-primary))] bg-fill-expanded px-3 py-2 text-xs text-muted-foreground">
- <div className="flex items-center justify-between gap-2">
- <div className="flex-1">
- <span className="italic">Code variables would appear here. </span>
- <Link
- className="font-medium"
- to={`https://posthog.com/docs/error-tracking/code-variables/${exceptionAttributes.runtime}`}
- target="_blank"
- >
- Learn how to enable them
- </Link>
- </div>
- <LemonButton
- size="xsmall"
- icon={<IconX />}
- onClick={dismiss}
- tooltip="Dismiss"
- className="text-muted-foreground hover:text-[var(--foreground)]"
- />
- </div>
- </div>
- )
-}
diff --git a/frontend/src/lib/components/Errors/Frame/CollapsibleFrame.stories.tsx b/frontend/src/lib/components/Errors/Frame/CollapsibleFrame.stories.tsx
index 487b0c13e1a1..6d5848d8d816 100644
--- a/frontend/src/lib/components/Errors/Frame/CollapsibleFrame.stories.tsx
+++ b/frontend/src/lib/components/Errors/Frame/CollapsibleFrame.stories.tsx
@@ -5,7 +5,12 @@ import { useState } from 'react'
import { mswDecorator } from '~/mocks/browser'
import { errorPropertiesLogic } from '../errorPropertiesLogic'
-import { ErrorTrackingStackFrame, ErrorTrackingStackFrameContext, ErrorTrackingStackFrameRecord } from '../types'
+import {
+ ErrorEventProperties,
+ ErrorTrackingStackFrame,
+ ErrorTrackingStackFrameContext,
+ ErrorTrackingStackFrameRecord,
+} from '../types'
import { CollapsibleFrame, CollapsibleFrameProps } from './CollapsibleFrame'
const frameContext: ErrorTrackingStackFrameContext = {
@@ -86,15 +91,17 @@ function Wrapper({
record,
recordLoading = false,
initialExpanded = false,
+ properties = eventProperties,
}: {
frame: ErrorTrackingStackFrame
record?: ErrorTrackingStackFrameRecord
recordLoading?: boolean
initialExpanded?: boolean
+ properties?: ErrorEventProperties
}): JSX.Element {
const [expanded, setExpanded] = useState(initialExpanded)
return (
- <BindLogic logic={errorPropertiesLogic} props={{ properties: eventProperties, id: 'story' }}>
+ <BindLogic logic={errorPropertiesLogic} props={{ properties, id: 'story' }}>
<div className="max-w-2xl border rounded">
<CollapsibleFrame
frame={frame}
@@ -213,6 +220,37 @@ export function RustFrameWithContext(): JSX.Element {
return <Wrapper frame={rustFrame} record={rustRecord} initialExpanded />
}
+export function PythonFrameWithoutVariables(): JSX.Element {
+ const frame: ErrorTrackingStackFrame = {
+ ...baseFrame,
+ raw_id: 'python-1',
+ mangled_name: 'load_frame_contexts',
+ resolved_name: 'load_frame_contexts',
+ source: 'app/frame_loader.py',
+ lang: 'python',
+ }
+
+ const record: ErrorTrackingStackFrameRecord = {
+ ...baseRecord,
+ raw_id: frame.raw_id,
+ contents: frame,
+ context: {
+ before: [{ number: 10, line: 'def load_frame_contexts(policy):' }],
+ line: { number: 11, line: ' return load_frames(policy)' },
+ after: [{ number: 12, line: '' }],
+ },
+ }
+
+ return (
+ <Wrapper
+ frame={frame}
+ record={record}
+ initialExpanded
+ properties={{ ...eventProperties, $lib: 'posthog-python' }}
+ />
+ )
+}
+
export function NoContext(): JSX.Element {
return <Wrapper frame={baseFrame} record={{ ...baseRecord, context: null }} />
}
diff --git a/frontend/src/lib/components/Errors/Frame/CollapsibleFrameContent.tsx b/frontend/src/lib/components/Errors/Frame/CollapsibleFrameContent.tsx
index b77fc55387d9..a66b759c93a3 100644
--- a/frontend/src/lib/components/Errors/Frame/CollapsibleFrameContent.tsx
+++ b/frontend/src/lib/components/Errors/Frame/CollapsibleFrameContent.tsx
@@ -1,7 +1,6 @@
import { Collapsible } from 'lib/ui/Collapsible/Collapsible'
import { ErrorTrackingStackFrame, ErrorTrackingStackFrameContext, ErrorTrackingStackFrameRecord } from '../types'
-import { CodeVariablesInlineBanner } from './CodeVariablesInlineBanner'
import { FrameContext } from './FrameContext'
import { getFrameLanguage } from './frameLanguage'
import { FrameVariables } from './FrameVariables'
@@ -19,7 +18,6 @@ export function CollapsibleFrameContent({
onFrameContextClick,
}: CollapsibleFrameContentProps): JSX.Element | null {
const { code_variables } = frame
- const hasCodeVariables = code_variables && Object.keys(code_variables).length > 0
if (!record || !record.context) {
return null
}
@@ -27,7 +25,9 @@ export function CollapsibleFrameContent({
<Collapsible.Panel className="border-t-[color:var(--frame-border,var(--color-border-primary))]">
<div onClick={(e) => onFrameContextClick?.(record.context!, e)}>
<FrameContext context={record.context} language={getFrameLanguage(frame)} />
- {hasCodeVariables ? <FrameVariables variables={code_variables!} /> : <CodeVariablesInlineBanner />}
+ {code_variables && Object.keys(code_variables).length > 0 && (
+ <FrameVariables variables={code_variables} />
+ )}
</div>
</Collapsible.Panel>
)