1+ import { useMemo } from 'react' ;
12import styled from '@emotion/styled' ;
23import type { Location } from 'history' ;
34import omit from 'lodash/omit' ;
@@ -72,57 +73,84 @@ function EventsContent(props: Props) {
7273 projects,
7374 } = props ;
7475 const routes = useRoutes ( ) ;
75- const eventView = originalEventView . clone ( ) ;
76- const transactionsListTitles = TRANSACTIONS_LIST_TITLES . slice ( ) ;
77- const project = projects . find ( p => p . id === projectId ) ;
7876
79- const fields = [ ...eventView . fields ] ;
77+ const { eventView, titles} = useMemo ( ( ) => {
78+ const eventViewClone = originalEventView . clone ( ) ;
79+ const transactionsListTitles = TRANSACTIONS_LIST_TITLES . slice ( ) ;
80+ const project = projects . find ( p => p . id === projectId ) ;
8081
81- if ( webVital ) {
82- transactionsListTitles . splice ( 3 , 0 , webVital ) ;
83- }
82+ const fields = [ ...eventViewClone . fields ] ;
8483
85- const spanOperationBreakdownConditions = filterToSearchConditions (
86- spanOperationBreakdownFilter ,
87- location
88- ) ;
84+ if ( webVital ) {
85+ transactionsListTitles . splice ( 3 , 0 , webVital ) ;
86+ }
8987
90- if ( spanOperationBreakdownConditions ) {
91- eventView . query = ` ${ eventView . query } ${ spanOperationBreakdownConditions } ` . trim ( ) ;
92- transactionsListTitles . splice ( 2 , 1 , t ( '%s duration' , spanOperationBreakdownFilter ) ) ;
93- }
88+ const spanOperationBreakdownConditions = filterToSearchConditions (
89+ spanOperationBreakdownFilter ,
90+ location
91+ ) ;
9492
95- const platform = platformToPerformanceType ( projects , eventView . project ) ;
96- if ( platform === ProjectPerformanceType . BACKEND ) {
97- const userIndex = transactionsListTitles . indexOf ( 'user' ) ;
98- if ( userIndex > 0 ) {
99- transactionsListTitles . splice ( userIndex + 1 , 0 , 'http.method' ) ;
100- fields . splice ( userIndex + 1 , 0 , { field : 'http.method' } ) ;
93+ if ( spanOperationBreakdownConditions ) {
94+ eventViewClone . query =
95+ `${ eventViewClone . query } ${ spanOperationBreakdownConditions } ` . trim ( ) ;
96+ transactionsListTitles . splice ( 2 , 1 , t ( '%s duration' , spanOperationBreakdownFilter ) ) ;
10197 }
102- }
10398
104- if (
105- organization . features . includes ( 'profiling' ) &&
106- project &&
107- // only show for projects that already sent a profile
108- // once we have a more compact design we will show this for
109- // projects that support profiling as well
110- project . hasProfiles
111- ) {
112- transactionsListTitles . push ( t ( 'profile' ) ) ;
113- fields . push ( { field : 'profile.id' } ) ;
114- }
99+ const platform = platformToPerformanceType ( projects , eventViewClone . project ) ;
100+ if ( platform === ProjectPerformanceType . BACKEND ) {
101+ const userIndex = transactionsListTitles . indexOf ( 'user' ) ;
102+ if ( userIndex > 0 ) {
103+ transactionsListTitles . splice ( userIndex + 1 , 0 , 'http.method' ) ;
104+ fields . splice ( userIndex + 1 , 0 , { field : 'http.method' } ) ;
105+ }
106+ }
115107
116- if (
117- organization . features . includes ( 'session-replay' ) &&
118- project &&
119- projectSupportsReplay ( project )
120- ) {
121- transactionsListTitles . push ( t ( 'replay' ) ) ;
122- fields . push ( { field : 'replayId' } ) ;
123- }
108+ if (
109+ // only show for projects that already sent a profile
110+ // once we have a more compact design we will show this for
111+ // projects that support profiling as well
112+ project ?. hasProfiles &&
113+ ( organization . features . includes ( 'profiling' ) ||
114+ organization . features . includes ( 'continuous-profiling' ) )
115+ ) {
116+ transactionsListTitles . push ( t ( 'profile' ) ) ;
124117
125- eventView . fields = fields ;
118+ if ( organization . features . includes ( 'profiling' ) ) {
119+ fields . push ( { field : 'profile.id' } ) ;
120+ }
121+
122+ if ( organization . features . includes ( 'continuous-profiling' ) ) {
123+ fields . push ( { field : 'profiler.id' } ) ;
124+ fields . push ( { field : 'thread.id' } ) ;
125+ fields . push ( { field : 'precise.start_ts' } ) ;
126+ fields . push ( { field : 'precise.finish_ts' } ) ;
127+ }
128+ }
129+
130+ if (
131+ organization . features . includes ( 'session-replay' ) &&
132+ project &&
133+ projectSupportsReplay ( project )
134+ ) {
135+ transactionsListTitles . push ( t ( 'replay' ) ) ;
136+ fields . push ( { field : 'replayId' } ) ;
137+ }
138+
139+ eventViewClone . fields = fields ;
140+
141+ return {
142+ eventView : eventViewClone ,
143+ titles : transactionsListTitles ,
144+ } ;
145+ } , [
146+ originalEventView ,
147+ location ,
148+ organization ,
149+ projects ,
150+ projectId ,
151+ spanOperationBreakdownFilter ,
152+ webVital ,
153+ ] ) ;
126154
127155 return (
128156 < Layout . Main fullWidth >
@@ -133,7 +161,7 @@ function EventsContent(props: Props) {
133161 routes = { routes }
134162 location = { location }
135163 setError = { setError }
136- columnTitles = { transactionsListTitles }
164+ columnTitles = { titles }
137165 transactionName = { transactionName }
138166 />
139167 </ Layout . Main >
0 commit comments