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(sdk-health): make snoozing hide the SDK update warning (#104409)

posthog[bot]bdd4d6394e0f
diff --git a/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.test.tsx b/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.test.tsx
new file mode 100644
index 000000000000..0a3c1914f9cc
--- /dev/null
+++ b/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.test.tsx
@@ -0,0 +1,98 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+
+import { useMocks } from '~/mocks/jest'
+import { getAllByDataAttr } from '~/test/byDataAttr'
+import { initKeaTests } from '~/test/init'
+
+import { sdkHealthLogic } from './sdkHealthLogic'
+import { SdkHealthScene } from './SdkHealthScene'
+
+const OUTDATED_REPORT = {
+ health: 'warning',
+ overall_health: 'needs_attention',
+ needs_updating_count: 1,
+ sdks: [
+ {
+ lib: 'web',
+ is_outdated: true,
+ is_old: false,
+ needs_updating: true,
+ migration_required: false,
+ latest_version: '1.2.3',
+ severity: 'warning',
+ banners: ['posthog-js is 40 versions behind.'],
+ outdated_traffic_alerts: [],
+ releases: [],
+ },
+ ],
+}
+
+// LemonBanner renders its action twice, once per responsive breakpoint, so both copies carry the
+// same data-attr and only the visible one is worth clicking.
+function bannerAction(dataAttr: string): HTMLElement {
+ return getAllByDataAttr(document.body, dataAttr)[0]
+}
+
+function mountWithOutdatedReport(): ReturnType<typeof sdkHealthLogic.build> {
+ const logic = sdkHealthLogic()
+ logic.mount()
+ logic.actions.loadReportSuccess(OUTDATED_REPORT as any)
+ return logic
+}
+
+describe('<SdkHealthScene />', () => {
+ beforeEach(() => {
+ // snoozedUntil is a `persist: true` reducer, so a previous test's snooze would otherwise
+ // still be in localStorage when the next one mounts the logic.
+ localStorage.clear()
+ jest.useFakeTimers({ doNotFake: ['performance'] })
+ jest.setSystemTime(new Date('2026-09-22'))
+ useMocks({
+ get: {
+ '/api/projects/:team_id/sdk_health/report/': OUTDATED_REPORT,
+ },
+ })
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ jest.useRealTimers()
+ })
+
+ it('replaces the update warning with the snoozed-until notice once snoozed', () => {
+ mountWithOutdatedReport()
+ render(<SdkHealthScene />)
+
+ expect(screen.getByText('Time for an update!')).toBeInTheDocument()
+
+ fireEvent.click(bannerAction('sdk-health-snooze-warning'))
+
+ expect(screen.queryByText('Time for an update!')).toBeNull()
+ expect(screen.getByText('Update warning snoozed')).toBeInTheDocument()
+ expect(screen.getByText(/1 SDK still needs an update\. Snoozed until/)).toBeInTheDocument()
+ })
+
+ it('brings the update warning back when the snooze is lifted', () => {
+ mountWithOutdatedReport()
+ render(<SdkHealthScene />)
+
+ fireEvent.click(bannerAction('sdk-health-snooze-warning'))
+ fireEvent.click(bannerAction('sdk-health-unsnooze-warning'))
+
+ expect(screen.getByText('Time for an update!')).toBeInTheDocument()
+ expect(screen.queryByText('Update warning snoozed')).toBeNull()
+ })
+
+ it('ignores a snooze that has already expired', () => {
+ const logic = mountWithOutdatedReport()
+ logic.actions.snoozeSdkHealth()
+ jest.setSystemTime(new Date('2027-01-01'))
+
+ render(<SdkHealthScene />)
+
+ expect(screen.getByText('Time for an update!')).toBeInTheDocument()
+ })
+})
diff --git a/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.tsx b/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.tsx
index 50b26a76456f..2a6160e25fd3 100644
--- a/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.tsx
+++ b/frontend/src/scenes/onboarding/shared/sdkHealth/SdkHealthScene.tsx
@@ -4,8 +4,10 @@ import posthog from 'posthog-js'
import { IconBell, IconRefresh } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
+import { dayjs } from 'lib/dayjs'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+import { pluralize } from 'lib/utils/strings'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
@@ -28,11 +30,12 @@ export function SdkHealthScene(): JSX.Element {
reportLoading: loading,
needsUpdatingCount,
hasErrors,
+ isSnoozed,
snoozedUntil,
} = useValues(sdkHealthLogic)
const { isDev } = useValues(preflightLogic)
- const { loadReport, snoozeSdkHealth } = useActions(sdkHealthLogic)
+ const { loadReport, snoozeSdkHealth, unsnooze } = useActions(sdkHealthLogic)
useOnMountEffect(() => {
posthog.capture('sdk doctor loaded', { needsUpdatingCount })
@@ -48,6 +51,18 @@ export function SdkHealthScene(): JSX.Element {
snoozeSdkHealth()
}
+ const showWarningAgain = (): void => {
+ posthog.capture('sdk doctor unsnooze warning')
+ unsnooze()
+ }
+
+ const snoozeNotice = `${pluralize(needsUpdatingCount, 'SDK')} still ${pluralize(
+ needsUpdatingCount,
+ 'needs',
+ 'need',
+ false
+ )} an update. Snoozed until ${dayjs(snoozedUntil).format('MMM D, YYYY')}.`
+
return (
<SceneContent>
<SceneTitleSection
@@ -112,6 +127,21 @@ export function SdkHealthScene(): JSX.Element {
<p className="text-sm mt-1">Your SDKs are on the latest version or close behind it.</p>
</LemonBanner>
</section>
+ ) : isSnoozed ? (
+ <section className="mb-2">
+ <h3>Update warning snoozed</h3>
+ <LemonBanner
+ type="info"
+ hideIcon={false}
+ action={{
+ children: 'Show warning',
+ onClick: showWarningAgain,
+ 'data-attr': 'sdk-health-unsnooze-warning',
+ }}
+ >
+ <p className="text-sm">{snoozeNotice}</p>
+ </LemonBanner>
+ </section>
) : (
<section className="mb-2">
<h3>Time for an update!</h3>
@@ -120,8 +150,8 @@ export function SdkHealthScene(): JSX.Element {
hideIcon={false}
action={{
children: 'Snooze warning for 30 days',
- disabledReason: snoozedUntil ? 'Already snoozed' : undefined,
onClick: snoozeWarning,
+ 'data-attr': 'sdk-health-snooze-warning',
}}
>
{Object.entries(augmentedData).flatMap(([sdkType, sdk]) =>
diff --git a/frontend/src/scenes/onboarding/shared/sdkHealth/sdkHealthLogic.tsx b/frontend/src/scenes/onboarding/shared/sdkHealth/sdkHealthLogic.tsx
index dfe5b16167ce..464ba3108531 100644
--- a/frontend/src/scenes/onboarding/shared/sdkHealth/sdkHealthLogic.tsx
+++ b/frontend/src/scenes/onboarding/shared/sdkHealth/sdkHealthLogic.tsx
@@ -4,6 +4,7 @@ import { subscriptions } from 'kea-subscriptions'
import { lemonToast } from '@posthog/lemon-ui'
+import { dayjs } from 'lib/dayjs'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
@@ -68,7 +69,7 @@ export interface sdkHealthLogicValues {
currentTeamId: number | null // teamLogic
augmentedData: AugmentedTeamSdkVersionsInfo
hasErrors: boolean
- needsAttention: boolean
+ isSnoozed: boolean
needsUpdatingCount: number
report: SdkHealthReportApi | null
reportLoading: boolean
@@ -112,7 +113,7 @@ export interface sdkHealthLogicMeta {
__keaTypeGenInternalSelectorTypes: {
augmentedData: (report: SdkHealthReportApi | null) => AugmentedTeamSdkVersionsInfo
needsUpdatingCount: (report: SdkHealthReportApi | null) => number
- needsAttention: (report: SdkHealthReportApi | null, snoozedUntil: string | null) => boolean
+ isSnoozed: (snoozedUntil: string | null) => boolean
sdkHealth: (report: SdkHealthReportApi | null) => SdkHealthStatus
hasErrors: (report: SdkHealthReportApi | null, reportLoading: boolean) => boolean
}
@@ -150,6 +151,9 @@ export const sdkHealthLogic = kea<sdkHealthLogicType>([
}),
reducers(() => ({
+ // Browser-local, unlike the server-side snooze on the same `sdk_outdated` condition that
+ // the Health scene drives through posthog/api/health_issue.py. Snoozing here does not
+ // reach that one.
snoozedUntil: [
null as string | null,
{ persist: true },
@@ -238,14 +242,11 @@ export const sdkHealthLogic = kea<sdkHealthLogicType>([
(report: SdkHealthReportApi | null): number => report?.needs_updating_count ?? 0,
],
- needsAttention: [
- (s) => [s.report, s.snoozedUntil],
- (report: SdkHealthReportApi | null, snoozedUntil: string | null): boolean => {
- if (snoozedUntil !== null) {
- return false
- }
- return report?.overall_health === 'needs_attention'
- },
+ // An expired snooze must stop counting even before afterMount's unsnooze runs, so the
+ // date is compared here rather than treating any stored value as "still snoozed".
+ isSnoozed: [
+ (s) => [s.snoozedUntil],
+ (snoozedUntil: string | null): boolean => !!snoozedUntil && dayjs(snoozedUntil).isAfter(dayjs()),
],
sdkHealth: [