: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(logs): align session error badge with related errors tab (#97736)
Jimmy Zhu6fbffa188e85
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e02dd13a5b43..66c0614b05cf 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9747,7 +9747,7 @@ snapshots:scenes-other-onboarding-legacy--ai-observability-sdk-install--dark:hash: v1.k794b7964.0c82a4b8b276a3f51b42dd3a20aed7672fbfb5f096e4bd9da51221b6eb52bbdc.iXUjftr_vTAULjZ_soSDjZ9o_RG2YPlJBCG4ZSuNTS0scenes-other-onboarding-legacy--ai-observability-sdk-install--light:- hash: v1.k794b7964.c6c5baa13b6d17723b6022b01f3a235df0e49a93c92993eca8d498c2c4dfe9e5.a09diijoUqSgzkc5MHr912Pij2owQlUx5mrdebH4fsU+ hash: v1.k794b7964.678b8b0432e3d3e1dfc8853d4df36ca419c8cfb230a30c49cd80c3fa69a09efc.BDQs-dcVcwMzRljfmwl7bvbYMugh7SfERy2mZPRBkR0scenes-other-onboarding-legacy--ai-observability-sdk-install-with-cloud-run-flag--dark:hash: v1.k794b7964.0c82a4b8b276a3f51b42dd3a20aed7672fbfb5f096e4bd9da51221b6eb52bbdc.mNBXA38xho8_capLIbeLCS22SJlBdDCCYmsl30jy3bIscenes-other-onboarding-legacy--ai-observability-sdk-install-with-cloud-run-flag--light:diff --git a/products/logs/frontend/components/LogsViewer/LogDetailsModal/Tabs/RelatedErrors/RelatedErrorsTab.tsx b/products/logs/frontend/components/LogsViewer/LogDetailsModal/Tabs/RelatedErrors/RelatedErrorsTab.tsxindex 0f8008f6a4a3..12238b8636e2 100644--- a/products/logs/frontend/components/LogsViewer/LogDetailsModal/Tabs/RelatedErrors/RelatedErrorsTab.tsx+++ b/products/logs/frontend/components/LogsViewer/LogDetailsModal/Tabs/RelatedErrors/RelatedErrorsTab.tsx@@ -3,6 +3,7 @@ import { BindLogic, useActions, useValues } from 'kea'import { LemonBanner, LemonSkeleton } from '@posthog/lemon-ui'import { EmptyMessage } from 'lib/components/EmptyMessage/EmptyMessage'+import { pluralize } from 'lib/utils/strings'import { MaxErrorTrackingIssuePreview } from '~/queries/schema/schema-assistant-error-tracking'@@ -88,10 +89,11 @@ interface RelatedIssuesListProps {}function RelatedIssuesList({ issues }: RelatedIssuesListProps): JSX.Element {+ const totalOccurrences = issues.reduce((sum, issue) => sum + issue.occurrences, 0)return (<div className="flex flex-col"><p className="text-muted text-sm mb-2">- {issues.length} error{issues.length !== 1 ? 's' : ''} found in this session+ {pluralize(issues.length, 'issue')} with {pluralize(totalOccurrences, 'occurrence')} in this session</p>{issues.map((issue) => (<ErrorTrackingIssueCard key={issue.id} issue={issue} showUserCount={false} />diff --git a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.test.ts b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.test.tsindex 9ed02da8d7f7..474baf038362 100644--- a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.test.ts+++ b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.test.ts@@ -101,6 +101,12 @@ describe('logsSessionErrorsLogic', () => {expect(queryBodies[0].query.query.match(/'session-a'/g)).toHaveLength(1)})+ it('asks only about exceptions that error tracking linked to an issue', async () => {+ await loadPage([makeLog('log-1', 'session-a')])++ expect(queryBodies[0].query.query).toContain('isNotNull(properties.$exception_issue_id)')+ })+it('still builds a window when timestamps arrive as epoch numbers', async () => {await loadPage([{ ...BASE_LOG, uuid: 'log-1', attributes: { sessionId: 'session-a' }, timestamp: '1788474031592' },diff --git a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.tsindex 14c647fcf5fd..6b4c4ce3bf6d 100644--- a/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts+++ b/products/logs/frontend/components/LogsViewer/logsSessionErrorsLogic.ts@@ -151,9 +151,10 @@ export type logsSessionErrorsLogicType = MakeLogicType<// errors" without the user opening the row's Related errors tab first. The count answers the// session, not the log line: an exception in the same session is co-occurring evidence, not a cause.//-// The count comes from raw `$exception` events, while the tab it opens resolves them into Error-// Tracking issues. So the badge counts events the tab may group, suppress, or filter out, and the-// two can disagree on the number.+// Only exceptions error tracking linked to an issue count: an event with no issue id failed+// ingestion parsing, so the tab this badge opens can never list it. The two still disagree at the+// edges, because the tab anchors its window to one row rather than the whole page, caps at 100+// issues, and resolves issues through fingerprint state this query cannot see.export const logsSessionErrorsLogic = kea<logsSessionErrorsLogicType>([props({} as LogsSessionErrorsLogicProps),key((props) => props.id),@@ -197,6 +198,7 @@ export const logsSessionErrorsLogic = kea<logsSessionErrorsLogicType>([SELECT properties.$session_id AS session_id, count() AS exceptionsFROM eventsWHERE event = '$exception'+ AND isNotNull(properties.$exception_issue_id)AND timestamp >= ${range.from}AND timestamp <= ${range.to}AND properties.$session_id IN ${sessionIds}diff --git a/products/logs/frontend/components/VirtualizedLogsList/cells/SessionErrorsBadge.tsx b/products/logs/frontend/components/VirtualizedLogsList/cells/SessionErrorsBadge.tsxindex 30ca8df9444e..7ef633acebc9 100644--- a/products/logs/frontend/components/VirtualizedLogsList/cells/SessionErrorsBadge.tsx+++ b/products/logs/frontend/components/VirtualizedLogsList/cells/SessionErrorsBadge.tsx@@ -12,7 +12,7 @@ export interface SessionErrorsBadgeProps {// rather than implying the log caused the errors.export function SessionErrorsBadge({ errorCount, onClick }: SessionErrorsBadgeProps): JSX.Element {return (- <Tooltip title={`${pluralize(errorCount, 'error')} in this session. Click to see them.`}>+ <Tooltip title={`${pluralize(errorCount, 'error occurrence')} in this session. Click to see them.`}><LemonButtonsize="xsmall"icon={<IconWarning className="text-danger" />}