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): widen the view recordings date filter (#76412)

posthog[bot]8a43faecf38e
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
index c18abd51cb7b..c5ff401294bf 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/ErrorTrackingIssueScene.tsx
@@ -51,6 +51,7 @@ import { IssueStatusButton } from '../../components/IssueStatusButton'
import { ErrorTrackingSetupPrompt } from '../../components/SetupPrompt/SetupPrompt'
import { StyleVariables } from '../../components/StyleVariables'
import { useErrorTagRenderer } from '../../hooks/use-error-tag-renderer'
+import { getIssueReplayDateRange } from '../../utils'
import {
ErrorTrackingIssueSceneCategory,
errorTrackingIssueSceneConfigurationLogic,
@@ -124,8 +125,7 @@ export function ErrorTrackingIssueScene(): JSX.Element {
<SceneMenuBarItem
onClick={() => {
const url = urls.replay(ReplayTabs.Home, {
- date_from: issue.first_seen ?? '-30d',
- date_to: lastSeen ? lastSeen.toISOString() : null,
+ ...getIssueReplayDateRange(issue.first_seen, lastSeen),
filter_group: {
type: FilterLogicalOperator.And,
values: [
@@ -176,8 +176,7 @@ export function ErrorTrackingIssueScene(): JSX.Element {
/>
<ViewRecordingsPlaylistButton
filters={{
- date_from: issue.first_seen ?? '-30d',
- date_to: lastSeen ? lastSeen.toISOString() : null,
+ ...getIssueReplayDateRange(issue.first_seen, lastSeen),
filter_group: {
type: FilterLogicalOperator.And,
values: [
diff --git a/products/error_tracking/frontend/utils.test.ts b/products/error_tracking/frontend/utils.test.ts
index 34e6814104e9..b6b76dc75cd0 100644
--- a/products/error_tracking/frontend/utils.test.ts
+++ b/products/error_tracking/frontend/utils.test.ts
@@ -2,7 +2,7 @@ import { Dayjs, dayjs } from 'lib/dayjs'
import { ErrorTrackingIssue, ErrorTrackingIssueAggregations } from '~/queries/schema/schema-general'
-import { generateDateRangeLabel, mergeIssues, sourceDisplay } from './utils'
+import { generateDateRangeLabel, getIssueReplayDateRange, mergeIssues, sourceDisplay } from './utils'
function wrapVolumeBuckets(
initialDate: Dayjs,
@@ -176,6 +176,31 @@ describe('date range label generation', () => {
})
})
+describe('getIssueReplayDateRange', () => {
+ it('pads a single-occurrence issue so the window is not zero width', () => {
+ const seenAt = '2024-01-01T12:00:00.000Z'
+ const range = getIssueReplayDateRange(seenAt, dayjs(seenAt))
+ expect(range.date_from).toEqual('2024-01-01T11:00:00.000Z')
+ expect(range.date_to).toEqual('2024-01-01T13:00:00.000Z')
+ })
+
+ it('extends date_from before first_seen to catch sessions that started earlier', () => {
+ const firstSeen = '2024-01-01T12:00:00.000Z'
+ const lastSeen = dayjs('2024-01-02T12:00:00.000Z')
+ const range = getIssueReplayDateRange(firstSeen, lastSeen)
+ expect(range.date_from).toEqual('2024-01-01T11:00:00.000Z')
+ expect(range.date_to).toEqual('2024-01-02T13:00:00.000Z')
+ })
+
+ it('falls back to first_seen when last_seen is missing or predates it', () => {
+ const firstSeen = '2024-01-01T12:00:00.000Z'
+ expect(getIssueReplayDateRange(firstSeen, null).date_to).toEqual('2024-01-01T13:00:00.000Z')
+ expect(getIssueReplayDateRange(firstSeen, dayjs('2023-12-31T00:00:00.000Z')).date_to).toEqual(
+ '2024-01-01T13:00:00.000Z'
+ )
+ })
+})
+
describe('sourceDisplay', () => {
it('nicely formats paths', async () => {
expect(sourceDisplay('')).toEqual('')
diff --git a/products/error_tracking/frontend/utils.ts b/products/error_tracking/frontend/utils.ts
index 2d3d5680ca42..11185686842c 100644
--- a/products/error_tracking/frontend/utils.ts
+++ b/products/error_tracking/frontend/utils.ts
@@ -104,6 +104,17 @@ export function isThirdPartyScriptError(value: ErrorTrackingException['value']):
return value === THIRD_PARTY_SCRIPT_ERROR
}
+// Recordings match on session start time, so pad past first_seen to catch a session that began
+// before the exception fired, and past last_seen so a single-occurrence issue isn't a zero-width window.
+export function getIssueReplayDateRange(firstSeen: string, lastSeen: Dayjs | null): DateRange {
+ const from = dayjs(firstSeen)
+ const to = lastSeen && lastSeen.isAfter(from) ? lastSeen : from
+ return {
+ date_from: from.subtract(1, 'hour').toISOString(),
+ date_to: to.add(1, 'hour').toISOString(),
+ }
+}
+
const customOptions: Record<string, string> = {
dStart: 'Today', // today
mStart: 'Month',