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.

chore(error-tracking): extract linked reports logic (#86618)

posthog[bot]ea0b6f747f46
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
index 2a8b279d9e25..6911026ba3bd 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.test.ts
@@ -7,6 +7,7 @@ import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { errorTrackingIssueSceneLogic, toErrorTrackingIssueSummary } from './errorTrackingIssueSceneLogic'
+import { linkedReportsLogic } from './linkedReportsLogic'
const makeFingerprints = (fingerprint: string = 'fp-1'): ErrorTrackingFingerprint[] => [
{ fingerprint, issue_id: 'issue-1', created_at: '2026-01-01T00:00:00Z' },
@@ -47,7 +48,10 @@ describe('errorTrackingIssueSceneLogic', () => {
it('leaves linked reports empty and does not fail when the signals lookup errors', async () => {
// Letting the loader reject would toast an error on every issue page during a signals outage.
- await expectLogic(logic).toDispatchActions(['loadLinkedReportsSuccess']).toMatchValues({ linkedReports: [] })
+ const reportsLogic = linkedReportsLogic({ issueId: 'issue-1' })
+ await expectLogic(reportsLogic).toDispatchActions(['loadLinkedReportsSuccess']).toMatchValues({
+ linkedReports: [],
+ })
})
it('changes the events query key when the search query changes', () => {
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
index cda50ee6e327..9d7a0baef97a 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/errorTrackingIssueSceneLogic.ts
@@ -26,7 +26,6 @@ import {
} from 'lib/components/Errors/types'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
import { Dayjs, dayjs } from 'lib/dayjs'
-import { getCurrentTeamId } from 'lib/utils/getAppContext'
import { objectsEqual } from 'lib/utils/objects'
import { MaxContextInput, createMaxContextHelpers } from 'scenes/max/maxTypes'
import { Scene } from 'scenes/sceneTypes'
@@ -42,9 +41,7 @@ import {
} from '~/queries/schema/schema-general'
import { ActivityScope, Breadcrumb, IntegrationType, UniversalFiltersGroup } from '~/types'
-import { signalsReportsList } from 'products/signals/frontend/generated/api'
import type { SignalReportApi } from 'products/signals/frontend/generated/api.schemas'
-import { SignalSourceProductApi } from 'products/signals/frontend/generated/api.schemas'
import type {
ErrorTrackingExternalReference,
@@ -64,6 +61,7 @@ import {
import { errorTrackingIssueEventsQuery, errorTrackingIssueQuery } from '../../queries'
import { syncSearchParams } from '../../utils'
import { ERROR_TRACKING_DETAILS_RESOLUTION, dateRangeToIsoBounds } from '../../utils'
+import { linkedReportsLogic } from './linkedReportsLogic'
export interface ErrorTrackingIssueSceneLogicProps {
id: ErrorTrackingIssue['id']
@@ -73,15 +71,14 @@ export interface ErrorTrackingIssueSceneLogicProps {
export type ErrorTrackingIssueStatus = ErrorTrackingIssue['status']
-/** An issue realistically groups into one or two reports. This only stops the endpoint's 100-report
- * default page from serializing far more than the panel will ever show. */
-const LINKED_REPORTS_LIMIT = 10
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface errorTrackingIssueSceneLogicValues {
dateRange: DateRange // issueFiltersLogic
filterGroup: UniversalFiltersGroup // issueFiltersLogic
filterTestAccounts: boolean // issueFiltersLogic
searchQuery: string // issueFiltersLogic
+ linkedReports: SignalReportApi[] // linkedReportsLogic
+ linkedReportsLoading: boolean // linkedReportsLogic
aggregations: ErrorTrackingIssueAggregations | undefined
breadcrumbs: Breadcrumb[]
eventsQuery: EventsQuery
@@ -96,8 +93,6 @@ export interface errorTrackingIssueSceneLogicValues {
issueId: string
issueLoading: boolean
lastSeen: Dayjs | null
- linkedReports: SignalReportApi[]
- linkedReportsLoading: boolean
listDateRange: DateRange | null
maxContext: MaxContextInput[]
mobileDetailOpen: boolean
@@ -160,6 +155,7 @@ export interface errorTrackingIssueSceneLogicActions {
setSearchQuery: (searchQuery: string) => {
searchQuery: string
} // issueFiltersLogic
+ loadLinkedReports: () => any // linkedReportsLogic
createExternalReference: (
integrationId: IntegrationType['id'],
config: Record<string, string>
@@ -264,21 +260,6 @@ export interface errorTrackingIssueSceneLogicActions {
value: true
}
}
- loadLinkedReports: () => any
- loadLinkedReportsFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadLinkedReportsSuccess: (
- linkedReports: SignalReportApi[],
- payload?: any
- ) => {
- linkedReports: SignalReportApi[]
- payload?: any
- }
loadSpikeEvents: () => any
loadSpikeEventsFailure: (
error: string,
@@ -563,16 +544,20 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
props({} as ErrorTrackingIssueSceneLogicProps),
key((props) => props.id),
- connect(() => ({
+ connect((props: ErrorTrackingIssueSceneLogicProps) => ({
values: [
issueFiltersLogic({ logicKey: ERROR_TRACKING_ISSUE_SCENE_LOGIC_KEY }),
['dateRange', 'filterTestAccounts', 'filterGroup', 'searchQuery'],
+ linkedReportsLogic({ issueId: props.id }),
+ ['linkedReports', 'linkedReportsLoading'],
],
actions: [
issueFiltersLogic({ logicKey: ERROR_TRACKING_ISSUE_SCENE_LOGIC_KEY }),
['setDateRange', 'setFilterTestAccounts', 'setFilterGroup', 'setSearchQuery'],
issueActionsLogic,
['updateIssueAssignee', 'updateIssueStatus', 'updateIssueName', 'updateIssueDescription'],
+ linkedReportsLogic({ issueId: props.id }),
+ ['loadLinkedReports'],
],
})),
@@ -754,31 +739,6 @@ export const errorTrackingIssueSceneLogic = kea<errorTrackingIssueSceneLogicType
loadIssueFingerprints: async () => await api.errorTracking.fingerprints.list(props.id),
},
],
- linkedReports: [
- [] as SignalReportApi[],
- {
- // Error tracking tags its signals with the issue id as `source_id`, so this filter
- // walks the link from the issue back to the reports its signals fed.
- loadLinkedReports: async (): Promise<SignalReportApi[]> => {
- try {
- const response = await signalsReportsList(getCurrentTeamId().toString(), {
- source_id: props.id,
- source_product: SignalSourceProductApi.ErrorTracking,
- // The endpoint's default ordering leads with the viewer's own review
- // queue, which is an inbox concern rather than this pane's.
- ordering: '-updated_at',
- limit: LINKED_REPORTS_LIMIT,
- })
- return response.results
- } catch (error) {
- // Supplementary context, so it degrades quietly: kea-loaders toasts a failed
- // `load*` action, and a signals outage must not do that on every issue page.
- console.error('Failed to load linked reports:', error)
- return []
- }
- },
- },
- ],
spikeEvents: [
[] as ErrorTrackingSpikeEvent[],
{
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/linkedReportsLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/linkedReportsLogic.ts
new file mode 100644
index 000000000000..59c00e9abd1f
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingIssueScene/linkedReportsLogic.ts
@@ -0,0 +1,84 @@
+import { MakeLogicType, kea, key, path, props } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { getCurrentTeamId } from 'lib/utils/getAppContext'
+
+import { signalsReportsList } from 'products/signals/frontend/generated/api'
+import type { SignalReportApi } from 'products/signals/frontend/generated/api.schemas'
+import { SignalSourceProductApi } from 'products/signals/frontend/generated/api.schemas'
+
+export interface LinkedReportsLogicProps {
+ issueId: string
+}
+
+const LINKED_REPORTS_LIMIT = 10
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface linkedReportsLogicValues {
+ linkedReports: SignalReportApi[]
+ linkedReportsLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface linkedReportsLogicActions {
+ loadLinkedReports: () => any
+ loadLinkedReportsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadLinkedReportsSuccess: (
+ linkedReports: SignalReportApi[],
+ payload?: any
+ ) => {
+ linkedReports: SignalReportApi[]
+ payload?: any
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface linkedReportsLogicMeta {
+ key: string
+}
+
+export type linkedReportsLogicType = MakeLogicType<
+ linkedReportsLogicValues,
+ linkedReportsLogicActions,
+ LinkedReportsLogicProps,
+ linkedReportsLogicMeta
+>
+
+export const linkedReportsLogic = kea<linkedReportsLogicType>([
+ props({} as LinkedReportsLogicProps),
+ key((props) => props.issueId),
+ path((key) => ['products', 'error_tracking', 'scenes', 'ErrorTrackingIssueScene', 'linkedReportsLogic', key]),
+ loaders(({ props }) => ({
+ linkedReports: [
+ [] as SignalReportApi[],
+ {
+ // Error tracking tags its signals with the issue id as `source_id`, so this filter
+ // walks the link from the issue back to the reports its signals fed.
+ loadLinkedReports: async (): Promise<SignalReportApi[]> => {
+ try {
+ const response = await signalsReportsList(getCurrentTeamId().toString(), {
+ source_id: props.issueId,
+ source_product: SignalSourceProductApi.ErrorTracking,
+ // The endpoint's default ordering leads with the viewer's own review
+ // queue, which is an inbox concern rather than this pane's.
+ ordering: '-updated_at',
+ limit: LINKED_REPORTS_LIMIT,
+ })
+ return response.results
+ } catch (error) {
+ // Supplementary context, so it degrades quietly: kea-loaders toasts a failed
+ // `load*` action, and a signals outage must not do that on every issue page.
+ console.error('Failed to load linked reports:', error)
+ return []
+ }
+ },
+ },
+ ],
+ })),
+])