Skip to content

Commit 1c615f8

Browse files
authored
ref(module-onboarding): Remove todo content and fix types (#103154)
The types enforce that onboarding content objects are added, even if it never used in the product. This PR fixed the typing and allows excluding modules from the onboarding component.
1 parent d73f52b commit 1c615f8

File tree

1 file changed

+31
-69
lines changed

1 file changed

+31
-69
lines changed

static/app/views/insights/common/components/modulesOnboarding.tsx

Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import type {PlatformKey} from 'sentry/types/project';
2525
import useOrganization from 'sentry/utils/useOrganization';
2626
import useProjects from 'sentry/utils/useProjects';
2727
import * as ModuleLayout from 'sentry/views/insights/common/components/moduleLayout';
28-
import type {TitleableModuleNames} from 'sentry/views/insights/common/components/modulePageProviders';
2928
import {useHasFirstSpan} from 'sentry/views/insights/common/queries/useHasFirstSpan';
3029
import {useOnboardingProject} from 'sentry/views/insights/common/queries/useOnboardingProject';
3130
import {useDomainViewFilters} from 'sentry/views/insights/pages/useFilters';
@@ -38,9 +37,21 @@ import {
3837
import {ModuleName} from 'sentry/views/insights/types';
3938
import {LegacyOnboarding} from 'sentry/views/performance/onboarding';
4039

40+
type ModulesWithOnboarding = Exclude<
41+
ModuleName,
42+
| ModuleName.AGENT_MODELS
43+
| ModuleName.AGENT_TOOLS
44+
| ModuleName.MCP_TOOLS
45+
| ModuleName.MCP_RESOURCES
46+
| ModuleName.MCP_PROMPTS
47+
| ModuleName.AI_GENERATIONS
48+
| ModuleName.MOBILE_UI
49+
| ModuleName.OTHER
50+
>;
51+
4152
type ModuleOnboardingProps = {
4253
children: React.ReactNode;
43-
moduleName: ModuleName;
54+
moduleName: ModulesWithOnboarding;
4455
};
4556

4657
export function ModulesOnboarding({children, moduleName}: ModuleOnboardingProps) {
@@ -78,15 +89,18 @@ export function ModulesOnboarding({children, moduleName}: ModuleOnboardingProps)
7889
return children;
7990
}
8091

81-
export function ModulesOnboardingPanel({moduleName}: {moduleName: ModuleName}) {
92+
export function ModulesOnboardingPanel({
93+
moduleName,
94+
}: {
95+
moduleName: ModulesWithOnboarding;
96+
}) {
8297
const {view} = useDomainViewFilters();
8398
const docLink =
8499
typeof MODULE_PRODUCT_DOC_LINKS[moduleName] === 'string'
85100
? MODULE_PRODUCT_DOC_LINKS[moduleName]
86101
: view && MODULE_PRODUCT_DOC_LINKS[moduleName][view]
87102
? MODULE_PRODUCT_DOC_LINKS[moduleName][view]
88103
: '';
89-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
90104
const emptyStateContent = EMPTY_STATE_CONTENT[moduleName];
91105
return (
92106
<Panel>
@@ -121,15 +135,14 @@ export function ModulesOnboardingPanel({moduleName}: {moduleName: ModuleName}) {
121135
);
122136
}
123137

124-
type ModulePreviewProps = {moduleName: ModuleName};
138+
type ModulePreviewProps = {moduleName: ModulesWithOnboarding};
125139

126140
function getSDKName(sdk: PlatformKey) {
127141
const currentPlatform = platforms.find(p => p.id === sdk);
128142
return currentPlatform?.name;
129143
}
130144

131145
function ModulePreview({moduleName}: ModulePreviewProps) {
132-
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
133146
const emptyStateContent = EMPTY_STATE_CONTENT[moduleName];
134147
const [hoveredIcon, setHoveredIcon] = useState<PlatformKey | null>(null);
135148

@@ -259,8 +272,8 @@ type EmptyStateContent = {
259272
supportedSdks?: PlatformKey[];
260273
};
261274

262-
const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
263-
app_start: {
275+
const EMPTY_STATE_CONTENT: Record<ModulesWithOnboarding, EmptyStateContent> = {
276+
[ModuleName.APP_START]: {
264277
heading: t(`Don't lose your user's attention before your app loads`),
265278
description: tct(
266279
'Monitor cold and warm [dataTypePlural] and track down the operations and releases contributing to regressions.',
@@ -280,58 +293,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
280293
imageSrc: appStartPreviewImg,
281294
supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
282295
},
283-
'agent-models': {
284-
heading: t('TODO'),
285-
description: t('TODO'),
286-
valuePropDescription: t('TODO'),
287-
valuePropPoints: [],
288-
imageSrc: screenLoadsPreviewImg,
289-
},
290-
'agent-tools': {
291-
heading: t('TODO'),
292-
description: t('TODO'),
293-
valuePropDescription: t('TODO'),
294-
valuePropPoints: [],
295-
imageSrc: screenLoadsPreviewImg,
296-
},
297-
'mcp-tools': {
298-
heading: t('TODO'),
299-
description: t('TODO'),
300-
valuePropDescription: t('TODO'),
301-
valuePropPoints: [],
302-
imageSrc: screenLoadsPreviewImg,
303-
},
304-
'mcp-resources': {
305-
heading: t('TODO'),
306-
description: t('TODO'),
307-
valuePropDescription: t('TODO'),
308-
valuePropPoints: [],
309-
imageSrc: screenLoadsPreviewImg,
310-
},
311-
'mcp-prompts': {
312-
heading: t('TODO'),
313-
description: t('TODO'),
314-
valuePropDescription: t('TODO'),
315-
valuePropPoints: [],
316-
imageSrc: screenLoadsPreviewImg,
317-
},
318-
'ai-generations': {
319-
heading: t('AI Generations'),
320-
description: t(
321-
'Monitor your AI generations to ensure your AI applications are performing as expected.'
322-
),
323-
valuePropDescription: t('AI generations insights include:'),
324-
valuePropPoints: [],
325-
imageSrc: screenLoadsPreviewImg,
326-
},
327-
'mobile-ui': {
328-
heading: t('TODO'),
329-
description: t('TODO'),
330-
valuePropDescription: t('Mobile UI load insights include:'),
331-
valuePropPoints: [],
332-
imageSrc: screenLoadsPreviewImg,
333-
},
334-
'mobile-vitals': {
296+
[ModuleName.MOBILE_VITALS]: {
335297
heading: t('Mobile Vitals'),
336298
description: t(
337299
'Key metrics for for mobile development that help you ensure a great mobile user experience.'
@@ -345,7 +307,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
345307
imageSrc: screenLoadsPreviewImg,
346308
supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
347309
},
348-
cache: {
310+
[ModuleName.CACHE]: {
349311
heading: t('Bringing you one less hard problem in computer science'),
350312
description: t(
351313
'We’ll tell you if the parts of your application that interact with caches are hitting cache as often as intended, and whether caching is providing the performance improvements expected.'
@@ -363,7 +325,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
363325
imageSrc: cachesPreviewImg,
364326
supportedSdks: ['python', 'javascript', 'php', 'java', 'ruby', 'dotnet'],
365327
},
366-
db: {
328+
[ModuleName.DB]: {
367329
heading: tct(
368330
'Fix the slow [dataTypePlural] you honestly intended to get back to later',
369331
{dataTypePlural: MODULE_DATA_TYPES_PLURAL[ModuleName.DB].toLocaleLowerCase()}
@@ -386,7 +348,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
386348
],
387349
imageSrc: queriesPreviewImg,
388350
},
389-
http: {
351+
[ModuleName.HTTP]: {
390352
heading: t(
391353
'Are your API dependencies working as well as their landing page promised? '
392354
),
@@ -403,7 +365,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
403365
],
404366
imageSrc: requestPreviewImg,
405367
},
406-
resource: {
368+
[ModuleName.RESOURCE]: {
407369
heading: t('Is your favorite animated gif worth the time it takes to load?'),
408370
description: tct(
409371
'Find large and slow-to-load [dataTypePlurl] used by your application and understand their impact on page performance.',
@@ -440,7 +402,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
440402
'javascript-vue',
441403
],
442404
},
443-
vital: {
405+
[ModuleName.VITAL]: {
444406
heading: t('Finally answer, is this page slow for everyone or just me?'),
445407
description: t(
446408
'Get industry standard metrics telling you the quality of user experience on a web page and see what needs improving.'
@@ -455,7 +417,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
455417
],
456418
imageSrc: webVitalsPreviewImg,
457419
},
458-
queue: {
420+
[ModuleName.QUEUE]: {
459421
heading: t('Ensure your background jobs aren’t being sent to /dev/null'),
460422
description: tct(
461423
'Understand the health and performance impact that [dataTypePlural] have on your application and diagnose errors tied to jobs.',
@@ -474,7 +436,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
474436
imageSrc: queuesPreviewImg,
475437
supportedSdks: ['python', 'javascript', 'php', 'java', 'ruby', 'dotnet'],
476438
},
477-
screen_load: {
439+
[ModuleName.SCREEN_LOAD]: {
478440
heading: t(`Don’t lose your user's attention once your app loads`),
479441
description: tct(
480442
'View the most active [dataTypePlural] in your mobile application and monitor your releases for screen load performance.',
@@ -494,7 +456,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
494456
imageSrc: screenLoadsPreviewImg,
495457
supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
496458
},
497-
'screen-rendering': {
459+
[ModuleName.SCREEN_RENDERING]: {
498460
description: t(
499461
'Screen Rendering identifies slow and frozen interactions, helping you find and fix problems that might cause users to complain, or uninstall.'
500462
),
@@ -514,7 +476,7 @@ const EMPTY_STATE_CONTENT: Record<TitleableModuleNames, EmptyStateContent> = {
514476
],
515477
supportedSdks: ['android', 'flutter', 'apple-ios', 'react-native'],
516478
},
517-
sessions: {
479+
[ModuleName.SESSIONS]: {
518480
heading: t(`Get insights about your application's session health`),
519481
description: tct(
520482
'Understand the frequency of handled errors and crashes compared to healthy sessions.',

0 commit comments

Comments
 (0)