1
- import React from 'react' ;
1
+ import React , { Fragment , useEffect } from 'react' ;
2
2
import keyBy from 'lodash/keyBy' ;
3
3
4
4
import FeatureBadge from 'sentry/components/badge/featureBadge' ;
5
5
import { Breadcrumbs } from 'sentry/components/breadcrumbs' ;
6
6
import ButtonBar from 'sentry/components/buttonBar' ;
7
7
import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton' ;
8
8
import * as Layout from 'sentry/components/layouts/thirds' ;
9
+ import ExternalLink from 'sentry/components/links/externalLink' ;
9
10
import { DatePageFilter } from 'sentry/components/organizations/datePageFilter' ;
10
11
import { EnvironmentPageFilter } from 'sentry/components/organizations/environmentPageFilter' ;
11
12
import PageFilterBar from 'sentry/components/organizations/pageFilterBar' ;
12
13
import { ProjectPageFilter } from 'sentry/components/organizations/projectPageFilter' ;
13
14
import { PageHeadingQuestionTooltip } from 'sentry/components/pageHeadingQuestionTooltip' ;
15
+ import { t } from 'sentry/locale' ;
14
16
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' ;
15
23
import { decodeScalar , decodeSorts } from 'sentry/utils/queryString' ;
16
24
import { MutableSearch } from 'sentry/utils/tokenizeSearch' ;
17
25
import { useLocation } from 'sentry/utils/useLocation' ;
26
+ import { useOnboardingProject } from 'sentry/views/performance/browser/webVitals/utils/useOnboardingProject' ;
18
27
import { CacheHitMissChart } from 'sentry/views/performance/cache/charts/hitMissChart' ;
19
28
import { ThroughputChart } from 'sentry/views/performance/cache/charts/throughputChart' ;
20
29
import { Referrer } from 'sentry/views/performance/cache/referrers' ;
@@ -35,6 +44,7 @@ import * as ModuleLayout from 'sentry/views/performance/moduleLayout';
35
44
import { ModulePageProviders } from 'sentry/views/performance/modulePageProviders' ;
36
45
import { ModulesOnboarding } from 'sentry/views/performance/onboarding/modulesOnboarding' ;
37
46
import { OnboardingContent } from 'sentry/views/performance/onboarding/onboardingContent' ;
47
+ import { useHasData } from 'sentry/views/performance/onboarding/useHasData' ;
38
48
import { useModuleBreadcrumbs } from 'sentry/views/performance/utils/useModuleBreadcrumbs' ;
39
49
import { useMetrics , useSpanMetrics } from 'sentry/views/starfish/queries/useDiscover' ;
40
50
import { useSpanMetricsSeries } from 'sentry/views/starfish/queries/useDiscoverSeries' ;
@@ -45,8 +55,22 @@ import {DataTitles} from 'sentry/views/starfish/views/spans/types';
45
55
const { CACHE_MISS_RATE } = SpanFunction ;
46
56
const { CACHE_ITEM_SIZE } = SpanMetricsField ;
47
57
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
+
48
71
export function CacheLandingPage ( ) {
49
72
const location = useLocation ( ) ;
73
+ const { setPageInfo, pageAlert} = usePageAlert ( ) ;
50
74
51
75
const sortField = decodeScalar ( location . query ?. [ QueryParameterNames . TRANSACTIONS_SORT ] ) ;
52
76
@@ -117,6 +141,36 @@ export function CacheLandingPage() {
117
141
Referrer . LANDING_CACHE_TRANSACTION_DURATION
118
142
) ;
119
143
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
+
120
174
const transactionDurationsMap = keyBy ( transactionDurationData , 'transaction' ) ;
121
175
122
176
const transactionsListWithDuration =
@@ -156,6 +210,7 @@ export function CacheLandingPage() {
156
210
157
211
< Layout . Body >
158
212
< Layout . Main fullWidth >
213
+ < PageAlert />
159
214
< ModuleLayout . Layout >
160
215
< ModuleLayout . Full >
161
216
< PageFilterBar condensed >
@@ -211,7 +266,9 @@ function PageWithProviders() {
211
266
moduleName = "cache"
212
267
features = { [ 'insights-addon-modules' , 'performance-cache-view' ] }
213
268
>
214
- < CacheLandingPage />
269
+ < PageAlertProvider >
270
+ < CacheLandingPage />
271
+ </ PageAlertProvider >
215
272
</ ModulePageProviders >
216
273
) ;
217
274
}
0 commit comments