1
1
import { Fragment } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
- import type { Location } from 'history' ;
3
+ import type { Location , LocationDescriptor } from 'history' ;
4
4
5
5
import GuideAnchor from 'sentry/components/assistant/guideAnchor' ;
6
6
import { SectionHeading } from 'sentry/components/charts/styles' ;
@@ -17,6 +17,8 @@ import {WebVital} from 'sentry/utils/fields';
17
17
import { useMetricsCardinalityContext } from 'sentry/utils/performance/contexts/metricsCardinality' ;
18
18
import { useMEPSettingContext } from 'sentry/utils/performance/contexts/metricsEnhancedSetting' ;
19
19
import { decodeScalar } from 'sentry/utils/queryString' ;
20
+ import { useModuleURL } from 'sentry/views/insights/common/utils/useModuleURL' ;
21
+ import { ModuleName } from 'sentry/views/insights/types' ;
20
22
import { getTermHelp , PerformanceTerm } from 'sentry/views/performance/data' ;
21
23
import { getTransactionMEPParamsIfApplicable } from 'sentry/views/performance/transactionSummary/transactionOverview/utils' ;
22
24
import { vitalsRouteWithQuery } from 'sentry/views/performance/transactionSummary/transactionVitals/utils' ;
@@ -47,6 +49,10 @@ function UserStats({
47
49
const hasTransactionSummaryCleanupFlag = organization . features . includes (
48
50
'performance-transaction-summary-cleanup'
49
51
) ;
52
+ const webVitalsUrl = useModuleURL ( ModuleName . VITAL , false , 'frontend' ) ;
53
+
54
+ const hasWebVitalsFlag = organization . features . includes ( 'insights-initial-modules' ) ;
55
+ const hasDomainViewFlag = organization . features . includes ( 'insights-domain-view' ) ;
50
56
51
57
let userMisery = error !== null ? < div > { '\u2014' } </ div > : < Placeholder height = "34px" /> ;
52
58
@@ -71,13 +77,24 @@ function UserStats({
71
77
72
78
const orgSlug = organization . slug ;
73
79
74
- const webVitalsTarget = vitalsRouteWithQuery ( {
80
+ let webVitalsTarget : LocationDescriptor = vitalsRouteWithQuery ( {
75
81
orgSlug,
76
82
transaction : transactionName ,
77
83
projectID : decodeScalar ( location . query . project ) ,
78
84
query : location . query ,
79
85
} ) ;
80
86
87
+ if ( hasWebVitalsFlag && hasDomainViewFlag ) {
88
+ webVitalsTarget = {
89
+ pathname : `${ webVitalsUrl } /overview/` ,
90
+ query : {
91
+ transaction : transactionName ,
92
+ } ,
93
+ } ;
94
+ }
95
+
96
+ const showLink = ! hasDomainViewFlag || ( hasDomainViewFlag && hasWebVitalsFlag ) ;
97
+
81
98
const mepSetting = useMEPSettingContext ( ) ;
82
99
const mepCardinalityContext = useMetricsCardinalityContext ( ) ;
83
100
const queryExtras = getTransactionMEPParamsIfApplicable (
@@ -101,9 +118,11 @@ function UserStats({
101
118
size = "sm"
102
119
/>
103
120
</ SectionHeading >
104
- < Link to = { webVitalsTarget } >
105
- < IconOpen />
106
- </ Link >
121
+ { showLink && (
122
+ < Link to = { webVitalsTarget } >
123
+ < IconOpen />
124
+ </ Link >
125
+ ) }
107
126
</ VitalsHeading >
108
127
< VitalInfo
109
128
location = { location }
0 commit comments