Skip to content

Commit 0abe65b

Browse files
authored
feat(insights): show update SDK banner cache module (#72015)
1 parent 918b59a commit 0abe65b

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

Diff for: static/app/utils/performance/contexts/pageAlert.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type PageAlertType = keyof Theme['alert'];
1010

1111
export enum DismissId {
1212
RESOURCE_SIZE_ALERT = 0,
13+
CACHE_SDK_UPDATE_ALERT = 1,
1314
}
1415

1516
export type PageAlertOptions = {
@@ -81,7 +82,7 @@ export function PageAlertProvider({children}: {children: React.ReactNode}) {
8182

8283
export function PageAlert() {
8384
const {pageAlert} = useContext(pageErrorContext);
84-
const [dismissedAlerts, setDismissedAlerts] = useLocalStorageState<string[]>(
85+
const [dismissedAlerts, setDismissedAlerts] = useLocalStorageState<number[]>(
8586
localStorageKey,
8687
[]
8788
);

Diff for: static/app/views/performance/cache/cacheLandingPage.tsx

+59-2
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
import React from 'react';
1+
import React, {Fragment, useEffect} from 'react';
22
import keyBy from 'lodash/keyBy';
33

44
import FeatureBadge from 'sentry/components/badge/featureBadge';
55
import {Breadcrumbs} from 'sentry/components/breadcrumbs';
66
import ButtonBar from 'sentry/components/buttonBar';
77
import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
88
import * as Layout from 'sentry/components/layouts/thirds';
9+
import ExternalLink from 'sentry/components/links/externalLink';
910
import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
1011
import {EnvironmentPageFilter} from 'sentry/components/organizations/environmentPageFilter';
1112
import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
1213
import {ProjectPageFilter} from 'sentry/components/organizations/projectPageFilter';
1314
import {PageHeadingQuestionTooltip} from 'sentry/components/pageHeadingQuestionTooltip';
15+
import {t} from 'sentry/locale';
1416
import type {EventsMetaType} from 'sentry/utils/discover/eventView';
17+
import {
18+
DismissId,
19+
PageAlert,
20+
PageAlertProvider,
21+
usePageAlert,
22+
} from 'sentry/utils/performance/contexts/pageAlert';
1523
import {decodeScalar, decodeSorts} from 'sentry/utils/queryString';
1624
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
1725
import {useLocation} from 'sentry/utils/useLocation';
26+
import {useOnboardingProject} from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject';
1827
import {CacheHitMissChart} from 'sentry/views/performance/cache/charts/hitMissChart';
1928
import {ThroughputChart} from 'sentry/views/performance/cache/charts/throughputChart';
2029
import {Referrer} from 'sentry/views/performance/cache/referrers';
@@ -35,6 +44,7 @@ import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
3544
import {ModulePageProviders} from 'sentry/views/performance/modulePageProviders';
3645
import {ModulesOnboarding} from 'sentry/views/performance/onboarding/modulesOnboarding';
3746
import {OnboardingContent} from 'sentry/views/performance/onboarding/onboardingContent';
47+
import {useHasData} from 'sentry/views/performance/onboarding/useHasData';
3848
import {useModuleBreadcrumbs} from 'sentry/views/performance/utils/useModuleBreadcrumbs';
3949
import {useMetrics, useSpanMetrics} from 'sentry/views/starfish/queries/useDiscover';
4050
import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useDiscoverSeries';
@@ -45,8 +55,22 @@ import {DataTitles} from 'sentry/views/starfish/views/spans/types';
4555
const {CACHE_MISS_RATE} = SpanFunction;
4656
const {CACHE_ITEM_SIZE} = SpanMetricsField;
4757

58+
const SDK_UPDATE_ALERT = (
59+
<Fragment>
60+
{t(
61+
`If you're noticing missing cache data, try updating to the latest SDK or ensure spans are manually instrumented with the right attributes. `
62+
)}
63+
<ExternalLink href={`${MODULE_DOC_LINK}#instrumentation`}>
64+
{t('Read the Docs')}
65+
</ExternalLink>
66+
</Fragment>
67+
);
68+
69+
const CACHE_ERROR_MESSAGE = 'Column cache.hit was not found in metrics indexer';
70+
4871
export function CacheLandingPage() {
4972
const location = useLocation();
73+
const {setPageInfo, pageAlert} = usePageAlert();
5074

5175
const sortField = decodeScalar(location.query?.[QueryParameterNames.TRANSACTIONS_SORT]);
5276

@@ -117,6 +141,36 @@ export function CacheLandingPage() {
117141
Referrer.LANDING_CACHE_TRANSACTION_DURATION
118142
);
119143

144+
const onboardingProject = useOnboardingProject();
145+
const {hasData, isLoading: isHasDataLoading} = useHasData(
146+
MutableSearch.fromQueryObject(BASE_FILTERS),
147+
Referrer.LANDING_CACHE_ONBOARDING
148+
);
149+
150+
useEffect(() => {
151+
const hasMissingDataError =
152+
cacheHitRateError?.message === CACHE_ERROR_MESSAGE ||
153+
transactionsListError?.message === CACHE_ERROR_MESSAGE;
154+
155+
if (onboardingProject || isHasDataLoading || !hasData) {
156+
setPageInfo(undefined);
157+
return;
158+
}
159+
if (pageAlert?.message !== SDK_UPDATE_ALERT) {
160+
if (hasMissingDataError && hasData && !isHasDataLoading) {
161+
setPageInfo(SDK_UPDATE_ALERT, {dismissId: DismissId.CACHE_SDK_UPDATE_ALERT});
162+
}
163+
}
164+
}, [
165+
cacheHitRateError?.message,
166+
transactionsListError?.message,
167+
setPageInfo,
168+
hasData,
169+
isHasDataLoading,
170+
pageAlert?.message,
171+
onboardingProject,
172+
]);
173+
120174
const transactionDurationsMap = keyBy(transactionDurationData, 'transaction');
121175

122176
const transactionsListWithDuration =
@@ -156,6 +210,7 @@ export function CacheLandingPage() {
156210

157211
<Layout.Body>
158212
<Layout.Main fullWidth>
213+
<PageAlert />
159214
<ModuleLayout.Layout>
160215
<ModuleLayout.Full>
161216
<PageFilterBar condensed>
@@ -211,7 +266,9 @@ function PageWithProviders() {
211266
moduleName="cache"
212267
features={['insights-addon-modules', 'performance-cache-view']}
213268
>
214-
<CacheLandingPage />
269+
<PageAlertProvider>
270+
<CacheLandingPage />
271+
</PageAlertProvider>
215272
</ModulePageProviders>
216273
);
217274
}

0 commit comments

Comments
 (0)