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