Skip to content

Commit d3dfb31

Browse files
feat: Unify SDK Doctor endpoints (#42178)
SDK doctor fired two separate API requests for the server, one of them extremely heavy (download all release dates for all versions from our API). That was very expensive on the network side of things, so let's move the load to the backend and return to the UI only what's strictly necessary.
1 parent cbb2771 commit d3dfb31

File tree

12 files changed

+194
-262
lines changed

12 files changed

+194
-262
lines changed
-24.9 KB
Loading
-25.8 KB
Loading

frontend/src/layout/navigation-3000/sidepanel/SidePanel.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const meta: Meta = {
2525
viewMode: 'story',
2626
mockDate: '2025-10-10', // To stabilize relative dates
2727
pageUrl: urls.dashboards(),
28-
featureFlags: [FEATURE_FLAGS.SDK_DOCTOR_BETA, FEATURE_FLAGS.INCIDENT_IO_STATUS_PAGE],
28+
featureFlags: [FEATURE_FLAGS.INCIDENT_IO_STATUS_PAGE],
2929
testOptions: {
3030
includeNavigationInSnapshot: true,
3131
},

frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelSdkDoctor.tsx

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { IconInfo, IconStethoscope } from '@posthog/icons'
55
import { LemonBanner, LemonButton, LemonTable, LemonTableColumns, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
66

77
import { TZLabel } from 'lib/components/TZLabel'
8-
import { FEATURE_FLAGS } from 'lib/constants'
98
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
109
import { IconWithBadge } from 'lib/lemon-ui/icons'
11-
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
1210
import { inStorybook, inStorybookTestRunner } from 'lib/utils'
1311
import { newInternalTab } from 'lib/utils/newInternalTab'
1412
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
@@ -149,54 +147,31 @@ const COLUMNS: LemonTableColumns<AugmentedTeamSdkVersionsInfoRelease> = [
149147
]
150148

151149
export function SidePanelSdkDoctor(): JSX.Element | null {
152-
const { sdkVersionsMap, sdkVersionsLoading, teamSdkVersionsLoading, needsUpdatingCount, hasErrors, snoozedUntil } =
153-
useValues(sidePanelSdkDoctorLogic)
150+
const {
151+
augmentedData,
152+
rawDataLoading: loading,
153+
needsUpdatingCount,
154+
hasErrors,
155+
snoozedUntil,
156+
} = useValues(sidePanelSdkDoctorLogic)
154157
const { isDev } = useValues(preflightLogic)
155158

156-
const { loadTeamSdkVersions, snoozeSdkDoctor } = useActions(sidePanelSdkDoctorLogic)
157-
158-
const loading = sdkVersionsLoading || teamSdkVersionsLoading
159-
160-
const { featureFlags } = useValues(featureFlagLogic)
159+
const { loadRawData, snoozeSdkDoctor } = useActions(sidePanelSdkDoctorLogic)
161160

162161
useOnMountEffect(() => {
163162
posthog.capture('sdk doctor loaded', { needsUpdatingCount })
164163
})
165164

166165
const scanEvents = (): void => {
167166
posthog.capture('sdk doctor scan events')
168-
loadTeamSdkVersions({ forceRefresh: true })
167+
loadRawData({ forceRefresh: true })
169168
}
170169

171170
const snoozeWarning = (): void => {
172171
posthog.capture('sdk doctor snooze warning')
173172
snoozeSdkDoctor()
174173
}
175174

176-
if (!featureFlags[FEATURE_FLAGS.SDK_DOCTOR_BETA]) {
177-
return (
178-
<div className="flex flex-col h-full">
179-
<SidePanelPaneHeader
180-
title={
181-
<span>
182-
SDK Doctor{' '}
183-
<LemonTag type="warning" className="ml-1">
184-
Beta
185-
</LemonTag>
186-
</span>
187-
}
188-
/>
189-
<div className="m-2">
190-
<LemonBanner type="info">
191-
<div>
192-
<strong>SDK Doctor is in beta!</strong> It's not enabled in your account yet.
193-
</div>
194-
</LemonBanner>
195-
</div>
196-
</div>
197-
)
198-
}
199-
200175
return (
201176
<div className="flex flex-col h-full">
202177
<SidePanelPaneHeader
@@ -243,7 +218,7 @@ export function SidePanelSdkDoctor(): JSX.Element | null {
243218
<div className="text-center text-muted p-4">
244219
Error loading SDK information. Please try again later.
245220
</div>
246-
) : Object.keys(sdkVersionsMap).length === 0 ? (
221+
) : Object.keys(augmentedData).length === 0 ? (
247222
<div className="text-center text-muted p-4">
248223
No SDK information found. Are you sure you have our SDK installed? You can scan events to get
249224
started.
@@ -277,7 +252,7 @@ export function SidePanelSdkDoctor(): JSX.Element | null {
277252
)}
278253
</div>
279254

280-
{Object.keys(sdkVersionsMap).map((sdkType) => (
255+
{Object.keys(augmentedData).map((sdkType) => (
281256
<SdkSection key={sdkType} sdkType={sdkType as SdkType} />
282257
))}
283258
</div>
@@ -305,9 +280,9 @@ export const SidePanelSdkDoctorIcon = (props: { className?: string }): JSX.Eleme
305280
}
306281

307282
function SdkSection({ sdkType }: { sdkType: SdkType }): JSX.Element {
308-
const { sdkVersionsMap, teamSdkVersionsLoading } = useValues(sidePanelSdkDoctorLogic)
283+
const { augmentedData, rawDataLoading: loading } = useValues(sidePanelSdkDoctorLogic)
309284

310-
const sdk = sdkVersionsMap[sdkType]!
285+
const sdk = augmentedData[sdkType]!
311286
const links = SDK_DOCS_LINKS[sdkType]
312287
const sdkName = SDK_TYPE_READABLE_NAME[sdkType]
313288

@@ -352,7 +327,7 @@ function SdkSection({ sdkType }: { sdkType: SdkType }): JSX.Element {
352327

353328
<LemonTable
354329
dataSource={sdk.allReleases}
355-
loading={teamSdkVersionsLoading}
330+
loading={loading}
356331
columns={COLUMNS}
357332
size="small"
358333
emptyState="No SDK information found. Try scanning recent events."

0 commit comments

Comments
 (0)