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(web-analytics): align install CTA and stop health refresh 429 storm (#67643)

posthog[bot]ef9459fa86cb
diff --git a/frontend/src/scenes/health/components/HealthIssueList.tsx b/frontend/src/scenes/health/components/HealthIssueList.tsx
index 79835b4a2ce5..bcc2dde5e303 100644
--- a/frontend/src/scenes/health/components/HealthIssueList.tsx
+++ b/frontend/src/scenes/health/components/HealthIssueList.tsx
@@ -14,7 +14,7 @@ import { HealthIssueCard } from './HealthIssueCard'
export const HealthIssueList = (): JSX.Element => {
const { issues, healthIssuesLoading, healthIssues } = useValues(healthSceneLogic)
- const { dismissIssue, undismissIssue } = useActions(healthSceneLogic)
+ const { dismissIssue, undismissIssue, loadHealthIssues } = useActions(healthSceneLogic)
if (healthIssuesLoading && !healthIssues) {
return (
@@ -28,7 +28,9 @@ export const HealthIssueList = (): JSX.Element => {
if (!healthIssuesLoading && healthIssues === null) {
return (
- <LemonBanner type="warning">Error loading health information. Please try refreshing the page.</LemonBanner>
+ <LemonBanner type="warning" action={{ children: 'Retry', onClick: () => loadHealthIssues() }}>
+ We couldn't load your health information. This is usually temporary — retry to try again.
+ </LemonBanner>
)
}
diff --git a/frontend/src/scenes/health/healthSceneLogic.test.ts b/frontend/src/scenes/health/healthSceneLogic.test.ts
new file mode 100644
index 000000000000..110884983a5e
--- /dev/null
+++ b/frontend/src/scenes/health/healthSceneLogic.test.ts
@@ -0,0 +1,36 @@
+import { expectLogic } from 'kea-test-utils'
+
+import api from 'lib/api'
+
+import { initKeaTests } from '~/test/init'
+
+import { healthSceneLogic } from './healthSceneLogic'
+
+describe('healthSceneLogic', () => {
+ let logic: ReturnType<typeof healthSceneLogic.build>
+ let getSpy: jest.SpyInstance
+ let createSpy: jest.SpyInstance
+
+ beforeEach(() => {
+ initKeaTests()
+ getSpy = jest.spyOn(api, 'get').mockResolvedValue({ results: [], count: 0 })
+ createSpy = jest.spyOn(api, 'create').mockResolvedValue({ scheduled_kinds: [], kinds_failed: [], team_id: 1 })
+ })
+
+ afterEach(() => {
+ logic?.unmount()
+ jest.restoreAllMocks()
+ })
+
+ it('loads issues on mount without auto-firing the throttled refresh endpoint', async () => {
+ logic = healthSceneLogic()
+ logic.mount()
+
+ await expectLogic(logic).toDispatchActions(['loadHealthIssuesSuccess'])
+
+ expect(getSpy).toHaveBeenCalled()
+ // The refresh POST is throttled to one call per team every 5 minutes and checks re-run on a
+ // daily schedule, so mounting must not auto-fire it — that was the source of the 429 storm.
+ expect(createSpy).not.toHaveBeenCalled()
+ })
+})
diff --git a/frontend/src/scenes/health/healthSceneLogic.tsx b/frontend/src/scenes/health/healthSceneLogic.tsx
index ffac2ade89b1..697a13bb6d1b 100644
--- a/frontend/src/scenes/health/healthSceneLogic.tsx
+++ b/frontend/src/scenes/health/healthSceneLogic.tsx
@@ -299,13 +299,13 @@ export const healthSceneLogic = kea<healthSceneLogicType>([
},
})),
afterMount(({ actions, values }) => {
+ // Only load the latest results here. Health checks are re-evaluated on their own daily
+ // schedule, and the refresh endpoint is throttled to one call per team every 5 minutes —
+ // auto-firing it on every mount just produced 429 storms across a team's users without
+ // giving them fresher data. Users can still trigger a re-run via the manual refresh button.
actions.loadHealthIssues()
- const { nextRefreshAvailableAt } = values
- if (nextRefreshAvailableAt === null || nextRefreshAvailableAt <= Date.now()) {
- actions.refreshHealthData(false)
- }
-
+ // Restore the cooldown countdown for the manual refresh button if one is still active.
if (values.nextRefreshAvailableAt !== null) {
actions.setNextRefreshAvailableAt(values.nextRefreshAvailableAt)
}
diff --git a/frontend/src/scenes/web-analytics/health/components/HealthCheckItem.tsx b/frontend/src/scenes/web-analytics/health/components/HealthCheckItem.tsx
index 858c51aa7aab..1482108e4429 100644
--- a/frontend/src/scenes/web-analytics/health/components/HealthCheckItem.tsx
+++ b/frontend/src/scenes/web-analytics/health/components/HealthCheckItem.tsx
@@ -4,6 +4,7 @@ import { IconCheck, IconWarning, IconX } from '@posthog/icons'
import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
import { Link } from 'lib/lemon-ui/Link'
+import { isExternalLink } from 'lib/utils/url'
import { HealthCheck, HealthCheckStatus } from '../healthCheckTypes'
import { webAnalyticsHealthLogic } from '../webAnalyticsHealthLogic'
@@ -43,7 +44,15 @@ export function HealthCheckItem({ check }: HealthCheckItemProps): JSX.Element {
{check.action && (
<div className="flex-shrink-0">
{check.action.to ? (
- <LemonButton type="secondary" size="small" to={check.action.to} onClick={handleActionClick}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ to={check.action.to}
+ // External docs links must open in a new tab — navigating in place tears
+ // down the app (and ends any active session recording).
+ targetBlank={isExternalLink(check.action.to)}
+ onClick={handleActionClick}
+ >
{check.action.label}
</LemonButton>
) : check.action.onClick ? (
diff --git a/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts b/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts
index aceec8a5b803..63b7ff71000a 100644
--- a/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts
+++ b/frontend/src/scenes/web-analytics/health/webAnalyticsHealthLogic.ts
@@ -48,6 +48,13 @@ const INSTALL_GUIDE_ACTION: HealthCheckAction = {
to: 'https://posthog.com/docs/libraries/js',
}
+// The failing $pageview check reads like a "finish installing" call to action, so its button
+// should say the same thing rather than the generic "View installation guide".
+const COMPLETE_INSTALL_ACTION: HealthCheckAction = {
+ label: 'Complete installation',
+ to: 'https://posthog.com/docs/libraries/js',
+}
+
const WEB_HEALTH_CHECKS: WebHealthCheckConfig[] = [
{
id: HealthCheckId.PAGEVIEW_EVENTS,
@@ -57,7 +64,7 @@ const WEB_HEALTH_CHECKS: WebHealthCheckConfig[] = [
passingDescription:
'Events are flowing in as expected. Head over to the Web Analytics tab to start reviewing your analytics!',
failingDescription: 'Complete the PostHog installation to start seeing events in your dashboard.',
- failingAction: INSTALL_GUIDE_ACTION,
+ failingAction: COMPLETE_INSTALL_ACTION,
docsUrl: 'https://posthog.com/docs/product-analytics/capture-events',
urgent: true,
},
@@ -592,16 +599,11 @@ export const webAnalyticsHealthLogic = kea<webAnalyticsHealthLogicType>([
},
})),
- afterMount(({ actions, values }) => {
+ afterMount(({ actions }) => {
+ // Only load the latest results here. Health checks are re-evaluated on their own daily
+ // schedule, and the refresh endpoint is throttled to one call per team every 5 minutes —
+ // auto-firing it on every mount just produced 429 storms across a team's users without
+ // giving them fresher data. Users can still trigger a re-run via the manual refresh button.
actions.loadHealthIssues()
-
- const { nextRefreshAvailableAt } = values
- if (nextRefreshAvailableAt === null || nextRefreshAvailableAt <= Date.now()) {
- actions.refreshHealthChecks(false)
- } else {
- // A cooldown from a previous visit is still ticking down; keep the button's countdown live.
- actions.setNow(Date.now())
- actions.startCooldownCountdown()
- }
}),
])