index.tsx 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. import type React from 'react';
  2. import {
  3. Fragment,
  4. useCallback,
  5. useEffect,
  6. useLayoutEffect,
  7. useMemo,
  8. useReducer,
  9. useRef,
  10. useState,
  11. } from 'react';
  12. import {flushSync} from 'react-dom';
  13. import styled from '@emotion/styled';
  14. import * as Sentry from '@sentry/react';
  15. import * as qs from 'query-string';
  16. import {addSuccessMessage} from 'sentry/actionCreators/indicator';
  17. import {Button} from 'sentry/components/button';
  18. import useFeedbackWidget from 'sentry/components/feedback/widget/useFeedbackWidget';
  19. import LoadingIndicator from 'sentry/components/loadingIndicator';
  20. import NoProjectMessage from 'sentry/components/noProjectMessage';
  21. import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
  22. import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
  23. import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
  24. import {t, tct} from 'sentry/locale';
  25. import {space} from 'sentry/styles/space';
  26. import type {EventTransaction} from 'sentry/types/event';
  27. import type {Organization} from 'sentry/types/organization';
  28. import type {Project} from 'sentry/types/project';
  29. import {trackAnalytics} from 'sentry/utils/analytics';
  30. import {browserHistory} from 'sentry/utils/browserHistory';
  31. import EventView from 'sentry/utils/discover/eventView';
  32. import type {TraceSplitResults} from 'sentry/utils/performance/quickTrace/types';
  33. import {
  34. cancelAnimationTimeout,
  35. requestAnimationTimeout,
  36. } from 'sentry/utils/profiling/hooks/useVirtualizedTree/virtualizedTreeUtils';
  37. import type {UseApiQueryResult} from 'sentry/utils/queryClient';
  38. import {decodeScalar} from 'sentry/utils/queryString';
  39. import type RequestError from 'sentry/utils/requestError/requestError';
  40. import {capitalize} from 'sentry/utils/string/capitalize';
  41. import useApi from 'sentry/utils/useApi';
  42. import type {DispatchingReducerMiddleware} from 'sentry/utils/useDispatchingReducer';
  43. import useOrganization from 'sentry/utils/useOrganization';
  44. import usePageFilters from 'sentry/utils/usePageFilters';
  45. import {useParams} from 'sentry/utils/useParams';
  46. import useProjects from 'sentry/utils/useProjects';
  47. import type {ReplayTrace} from 'sentry/views/replays/detail/trace/useReplayTraces';
  48. import type {ReplayRecord} from 'sentry/views/replays/types';
  49. import {useTrace} from './traceApi/useTrace';
  50. import {type TraceMetaQueryResults, useTraceMeta} from './traceApi/useTraceMeta';
  51. import {useTraceRootEvent} from './traceApi/useTraceRootEvent';
  52. import {useTraceTree} from './traceApi/useTraceTree';
  53. import {TraceDrawer} from './traceDrawer/traceDrawer';
  54. import {TraceShape, TraceTree} from './traceModels/traceTree';
  55. import type {TraceTreeNode} from './traceModels/traceTreeNode';
  56. import {
  57. TraceEventPriority,
  58. type TraceEvents,
  59. TraceScheduler,
  60. } from './traceRenderers/traceScheduler';
  61. import {TraceView as TraceViewModel} from './traceRenderers/traceView';
  62. import {
  63. type ViewManagerScrollAnchor,
  64. VirtualizedViewManager,
  65. } from './traceRenderers/virtualizedViewManager';
  66. import {
  67. searchInTraceTreeText,
  68. searchInTraceTreeTokens,
  69. } from './traceSearch/traceSearchEvaluator';
  70. import {TraceSearchInput} from './traceSearch/traceSearchInput';
  71. import {parseTraceSearch} from './traceSearch/traceTokenConverter';
  72. import {
  73. DEFAULT_TRACE_VIEW_PREFERENCES,
  74. loadTraceViewPreferences,
  75. } from './traceState/tracePreferences';
  76. import {
  77. TraceStateProvider,
  78. useTraceState,
  79. useTraceStateDispatch,
  80. useTraceStateEmitter,
  81. } from './traceState/traceStateProvider';
  82. import {Trace} from './trace';
  83. import {traceAnalytics} from './traceAnalytics';
  84. import {
  85. isAutogroupedNode,
  86. isParentAutogroupedNode,
  87. isSiblingAutogroupedNode,
  88. isTraceNode,
  89. } from './traceGuards';
  90. import {TraceMetaDataHeader} from './traceHeader';
  91. import {TracePreferencesDropdown} from './tracePreferencesDropdown';
  92. import {TraceShortcuts} from './traceShortcutsModal';
  93. import type {TraceReducer, TraceReducerState} from './traceState';
  94. import {
  95. traceNodeAdjacentAnalyticsProperties,
  96. traceNodeAnalyticsName,
  97. } from './traceTreeAnalytics';
  98. import TraceTypeWarnings from './traceTypeWarnings';
  99. import {useTraceOnLoad} from './useTraceOnLoad';
  100. import {useTraceQueryParamStateSync} from './useTraceQueryParamStateSync';
  101. import {useTraceScrollToPath} from './useTraceScrollToPath';
  102. function logTraceMetadata(
  103. tree: TraceTree,
  104. projects: Project[],
  105. organization: Organization
  106. ) {
  107. switch (tree.shape) {
  108. case TraceShape.BROKEN_SUBTRACES:
  109. case TraceShape.EMPTY_TRACE:
  110. case TraceShape.MULTIPLE_ROOTS:
  111. case TraceShape.ONE_ROOT:
  112. case TraceShape.NO_ROOT:
  113. case TraceShape.ONLY_ERRORS:
  114. case TraceShape.BROWSER_MULTIPLE_ROOTS:
  115. traceAnalytics.trackTraceMetadata(tree, projects, organization);
  116. break;
  117. default: {
  118. Sentry.captureMessage('Unknown trace type');
  119. }
  120. }
  121. }
  122. export function TraceView() {
  123. const params = useParams<{traceSlug?: string}>();
  124. const organization = useOrganization();
  125. const traceSlug = useMemo(() => {
  126. const slug = params.traceSlug?.trim() ?? '';
  127. // null and undefined are not valid trace slugs, but they can be passed
  128. // in the URL and need to check for their string coerced values.
  129. if (!slug || slug === 'null' || slug === 'undefined') {
  130. Sentry.withScope(scope => {
  131. scope.setFingerprint(['trace-null-slug']);
  132. Sentry.captureMessage(`Trace slug is empty`);
  133. });
  134. }
  135. return slug;
  136. }, [params.traceSlug]);
  137. const queryParams = useMemo(() => {
  138. const normalizedParams = normalizeDateTimeParams(qs.parse(location.search), {
  139. allowAbsolutePageDatetime: true,
  140. });
  141. const start = decodeScalar(normalizedParams.start);
  142. const timestamp: string | undefined = decodeScalar(normalizedParams.timestamp);
  143. const end = decodeScalar(normalizedParams.end);
  144. const statsPeriod = decodeScalar(normalizedParams.statsPeriod);
  145. const numberTimestamp = timestamp ? Number(timestamp) : undefined;
  146. return {start, end, statsPeriod, timestamp: numberTimestamp, useSpans: 1};
  147. }, []);
  148. const traceEventView = useMemo(() => {
  149. const {start, end, statsPeriod, timestamp} = queryParams;
  150. let startTimeStamp = start;
  151. let endTimeStamp = end;
  152. // If timestamp exists in the query params, we want to use it to set the start and end time
  153. // with a buffer of 1.5 days, for retrieving events belonging to the trace.
  154. if (typeof timestamp === 'number') {
  155. const buffer = 36 * 60 * 60 * 1000; // 1.5 days in milliseconds
  156. const dateFromTimestamp = new Date(timestamp * 1000);
  157. startTimeStamp = new Date(dateFromTimestamp.getTime() - buffer).toISOString();
  158. endTimeStamp = new Date(dateFromTimestamp.getTime() + buffer).toISOString();
  159. }
  160. return EventView.fromSavedQuery({
  161. id: undefined,
  162. name: `Events with Trace ID ${traceSlug}`,
  163. fields: ['title', 'event.type', 'project', 'timestamp'],
  164. orderby: '-timestamp',
  165. query: `trace:${traceSlug}`,
  166. projects: [ALL_ACCESS_PROJECTS],
  167. version: 2,
  168. start: startTimeStamp,
  169. end: endTimeStamp,
  170. range: !(startTimeStamp || endTimeStamp) ? statsPeriod : undefined,
  171. });
  172. }, [queryParams, traceSlug]);
  173. const preferences = useMemo(
  174. () =>
  175. loadTraceViewPreferences('trace-view-preferences') ||
  176. DEFAULT_TRACE_VIEW_PREFERENCES,
  177. []
  178. );
  179. const meta = useTraceMeta([{traceSlug, timestamp: queryParams.timestamp}]);
  180. const trace = useTrace({traceSlug, timestamp: queryParams.timestamp});
  181. const rootEvent = useTraceRootEvent(trace.data ?? null);
  182. const tree = useTraceTree({traceSlug, trace, meta, replay: null});
  183. const title = useMemo(() => {
  184. return `${t('Trace Details')} - ${traceSlug}`;
  185. }, [traceSlug]);
  186. return (
  187. <SentryDocumentTitle title={title} orgSlug={organization.slug}>
  188. <TraceStateProvider
  189. initialPreferences={preferences}
  190. preferencesStorageKey="trace-view-preferences"
  191. >
  192. <NoProjectMessage organization={organization}>
  193. <TraceExternalLayout>
  194. <TraceMetaDataHeader
  195. rootEventResults={rootEvent}
  196. tree={tree}
  197. metaResults={meta}
  198. organization={organization}
  199. traceSlug={traceSlug}
  200. traceEventView={traceEventView}
  201. />
  202. <TraceInnerLayout>
  203. <TraceViewWaterfall
  204. tree={tree}
  205. trace={trace}
  206. meta={meta}
  207. replay={null}
  208. rootEvent={rootEvent}
  209. traceSlug={traceSlug}
  210. traceEventView={traceEventView}
  211. organization={organization}
  212. source="performance"
  213. isEmbedded={false}
  214. />
  215. </TraceInnerLayout>
  216. </TraceExternalLayout>
  217. </NoProjectMessage>
  218. </TraceStateProvider>
  219. </SentryDocumentTitle>
  220. );
  221. }
  222. const TRACE_TAB: TraceReducerState['tabs']['tabs'][0] = {
  223. node: 'trace',
  224. label: t('Trace'),
  225. };
  226. const VITALS_TAB: TraceReducerState['tabs']['tabs'][0] = {
  227. node: 'vitals',
  228. label: t('Vitals'),
  229. };
  230. type TraceViewWaterfallProps = {
  231. isEmbedded: boolean;
  232. meta: TraceMetaQueryResults;
  233. organization: Organization;
  234. replay: ReplayRecord | null;
  235. rootEvent: UseApiQueryResult<EventTransaction, RequestError>;
  236. source: string;
  237. trace: UseApiQueryResult<TraceSplitResults<TraceTree.Transaction>, RequestError>;
  238. traceEventView: EventView;
  239. traceSlug: string | undefined;
  240. tree: TraceTree;
  241. replayTraces?: ReplayTrace[];
  242. /**
  243. * Ignore eventId or path query parameters and use the provided node.
  244. * Must be set at component mount, no reactivity
  245. */
  246. scrollToNode?: {eventId?: string; path?: TraceTree.NodePath[]};
  247. };
  248. export function TraceViewWaterfall(props: TraceViewWaterfallProps) {
  249. const api = useApi();
  250. const filters = usePageFilters();
  251. const {projects} = useProjects();
  252. const organization = useOrganization();
  253. const traceState = useTraceState();
  254. const traceDispatch = useTraceStateDispatch();
  255. const traceStateEmitter = useTraceStateEmitter();
  256. const [forceRender, rerender] = useReducer(x => (x + 1) % Number.MAX_SAFE_INTEGER, 0);
  257. const traceView = useMemo(() => new TraceViewModel(), []);
  258. const traceScheduler = useMemo(() => new TraceScheduler(), []);
  259. const projectsRef = useRef<Project[]>(projects);
  260. projectsRef.current = projects;
  261. const scrollQueueRef = useTraceScrollToPath(props.scrollToNode);
  262. const forceRerender = useCallback(() => {
  263. flushSync(rerender);
  264. }, []);
  265. useEffect(() => {
  266. trackAnalytics('performance_views.trace_view_v1_page_load', {
  267. organization: props.organization,
  268. source: props.source,
  269. });
  270. }, [props.organization, props.source]);
  271. const previouslyFocusedNodeRef = useRef<TraceTreeNode<TraceTree.NodeValue> | null>(
  272. null
  273. );
  274. const previouslyScrolledToNodeRef = useRef<TraceTreeNode<TraceTree.NodeValue> | null>(
  275. null
  276. );
  277. useEffect(() => {
  278. if (!props.replayTraces?.length || props.tree?.type !== 'trace') {
  279. return undefined;
  280. }
  281. const cleanup = props.tree.fetchAdditionalTraces({
  282. api,
  283. filters,
  284. replayTraces: props.replayTraces,
  285. organization: props.organization,
  286. urlParams: qs.parse(location.search),
  287. rerender: forceRerender,
  288. meta: props.meta,
  289. });
  290. return () => cleanup();
  291. // eslint-disable-next-line react-hooks/exhaustive-deps
  292. }, [props.tree, props.replayTraces]);
  293. // Assign the trace state to a ref so we can access it without re-rendering
  294. const traceStateRef = useRef<TraceReducerState>(traceState);
  295. traceStateRef.current = traceState;
  296. const traceStatePreferencesRef = useRef<
  297. Pick<TraceReducerState['preferences'], 'autogroup' | 'missing_instrumentation'>
  298. >(traceState.preferences);
  299. traceStatePreferencesRef.current = traceState.preferences;
  300. // Initialize the view manager right after the state reducer
  301. const viewManager = useMemo(() => {
  302. return new VirtualizedViewManager(
  303. {
  304. list: {width: traceState.preferences.list.width},
  305. span_list: {width: 1 - traceState.preferences.list.width},
  306. },
  307. traceScheduler,
  308. traceView
  309. );
  310. // We only care about initial state when we initialize the view manager
  311. // eslint-disable-next-line react-hooks/exhaustive-deps
  312. }, []);
  313. useLayoutEffect(() => {
  314. const onTraceViewChange: TraceEvents['set trace view'] = view => {
  315. traceView.setTraceView(view);
  316. viewManager.enqueueFOVQueryParamSync(traceView);
  317. };
  318. const onPhysicalSpaceChange: TraceEvents['set container physical space'] =
  319. container => {
  320. traceView.setTracePhysicalSpace(container, [
  321. 0,
  322. 0,
  323. container[2] * viewManager.columns.span_list.width,
  324. container[3],
  325. ]);
  326. };
  327. const onTraceSpaceChange: TraceEvents['initialize trace space'] = view => {
  328. traceView.setTraceSpace(view);
  329. };
  330. // These handlers have high priority because they are responsible for
  331. // updating the view coordinates. If we update them first, then any components downstream
  332. // that rely on the view coordinates will be in sync with the view.
  333. traceScheduler.on('set trace view', onTraceViewChange, TraceEventPriority.HIGH);
  334. traceScheduler.on('set trace space', onTraceSpaceChange, TraceEventPriority.HIGH);
  335. traceScheduler.on(
  336. 'set container physical space',
  337. onPhysicalSpaceChange,
  338. TraceEventPriority.HIGH
  339. );
  340. traceScheduler.on(
  341. 'initialize trace space',
  342. onTraceSpaceChange,
  343. TraceEventPriority.HIGH
  344. );
  345. return () => {
  346. traceScheduler.off('set trace view', onTraceViewChange);
  347. traceScheduler.off('set trace space', onTraceSpaceChange);
  348. traceScheduler.off('set container physical space', onPhysicalSpaceChange);
  349. traceScheduler.off('initialize trace space', onTraceSpaceChange);
  350. };
  351. }, [traceScheduler, traceView, viewManager]);
  352. // Initialize the tabs reducer when the tree initializes
  353. useLayoutEffect(() => {
  354. return traceDispatch({
  355. type: 'set roving count',
  356. items: props.tree.list.length - 1,
  357. });
  358. }, [props.tree.list.length, traceDispatch]);
  359. // Initialize the tabs reducer when the tree initializes
  360. useLayoutEffect(() => {
  361. if (props.tree.type !== 'trace') {
  362. return;
  363. }
  364. const newTabs = [TRACE_TAB];
  365. if (props.tree.vitals.size > 0) {
  366. const types = Array.from(props.tree.vital_types.values());
  367. const label = types.length > 1 ? t('Vitals') : capitalize(types[0]) + ' Vitals';
  368. newTabs.push({
  369. ...VITALS_TAB,
  370. label,
  371. });
  372. }
  373. if (props.tree.profiled_events.size > 0) {
  374. newTabs.push({
  375. node: 'profiles',
  376. label: 'Profiles',
  377. });
  378. }
  379. traceDispatch({
  380. type: 'initialize tabs reducer',
  381. payload: {
  382. current_tab: traceStateRef?.current?.tabs?.tabs?.[0],
  383. tabs: newTabs,
  384. last_clicked_tab: null,
  385. },
  386. });
  387. // We only want to update the tabs when the tree changes
  388. // eslint-disable-next-line react-hooks/exhaustive-deps
  389. }, [props.tree]);
  390. const searchingRaf = useRef<{id: number | null} | null>(null);
  391. const onTraceSearch = useCallback(
  392. (
  393. query: string,
  394. activeNode: TraceTreeNode<TraceTree.NodeValue> | null,
  395. behavior: 'track result' | 'persist'
  396. ) => {
  397. if (searchingRaf.current?.id) {
  398. window.cancelAnimationFrame(searchingRaf.current.id);
  399. searchingRaf.current = null;
  400. }
  401. function done([matches, lookup, activeNodeSearchResult]) {
  402. // If the previous node is still in the results set, we want to keep it
  403. if (activeNodeSearchResult) {
  404. traceDispatch({
  405. type: 'set results',
  406. results: matches,
  407. resultsLookup: lookup,
  408. resultIteratorIndex: activeNodeSearchResult?.resultIteratorIndex,
  409. resultIndex: activeNodeSearchResult?.resultIndex,
  410. previousNode: activeNodeSearchResult,
  411. node: activeNode,
  412. });
  413. return;
  414. }
  415. if (activeNode && behavior === 'persist') {
  416. traceDispatch({
  417. type: 'set results',
  418. results: matches,
  419. resultsLookup: lookup,
  420. resultIteratorIndex: undefined,
  421. resultIndex: undefined,
  422. previousNode: null,
  423. node: activeNode,
  424. });
  425. return;
  426. }
  427. const resultIndex: number | undefined = matches?.[0]?.index;
  428. const resultIteratorIndex: number | undefined = matches?.[0] ? 0 : undefined;
  429. const node: TraceTreeNode<TraceTree.NodeValue> | null = matches?.[0]?.value;
  430. traceDispatch({
  431. type: 'set results',
  432. results: matches,
  433. resultsLookup: lookup,
  434. resultIteratorIndex: resultIteratorIndex,
  435. resultIndex: resultIndex,
  436. previousNode: activeNodeSearchResult,
  437. node,
  438. });
  439. }
  440. const tokens = parseTraceSearch(query);
  441. if (tokens) {
  442. searchingRaf.current = searchInTraceTreeTokens(
  443. props.tree,
  444. tokens,
  445. activeNode,
  446. done
  447. );
  448. } else {
  449. searchingRaf.current = searchInTraceTreeText(props.tree, query, activeNode, done);
  450. }
  451. },
  452. [traceDispatch, props.tree]
  453. );
  454. // We need to heavily debounce query string updates because the rest of the app is so slow
  455. // to rerender that it causes the search to drop frames on every keystroke...
  456. const QUERY_STRING_STATE_DEBOUNCE = 300;
  457. const queryStringAnimationTimeoutRef = useRef<{id: number} | null>(null);
  458. const setRowAsFocused = useCallback(
  459. (
  460. node: TraceTreeNode<TraceTree.NodeValue> | null,
  461. event: React.MouseEvent<HTMLElement> | null,
  462. resultsLookup: Map<TraceTreeNode<TraceTree.NodeValue>, number>,
  463. index: number | null,
  464. debounce: number = QUERY_STRING_STATE_DEBOUNCE
  465. ) => {
  466. // sync query string with the clicked node
  467. if (node) {
  468. if (queryStringAnimationTimeoutRef.current) {
  469. cancelAnimationTimeout(queryStringAnimationTimeoutRef.current);
  470. }
  471. queryStringAnimationTimeoutRef.current = requestAnimationTimeout(() => {
  472. const currentQueryStringPath = qs.parse(location.search).node;
  473. const nextNodePath = TraceTree.PathToNode(node);
  474. // Updating the query string with the same path is problematic because it causes
  475. // the entire sentry app to rerender, which is enough to cause jank and drop frames
  476. if (JSON.stringify(currentQueryStringPath) === JSON.stringify(nextNodePath)) {
  477. return;
  478. }
  479. const {eventId: _eventId, ...query} = qs.parse(location.search);
  480. browserHistory.replace({
  481. pathname: location.pathname,
  482. query: {
  483. ...query,
  484. node: nextNodePath,
  485. },
  486. });
  487. queryStringAnimationTimeoutRef.current = null;
  488. }, debounce);
  489. if (resultsLookup.has(node) && typeof index === 'number') {
  490. traceDispatch({
  491. type: 'set search iterator index',
  492. resultIndex: index,
  493. resultIteratorIndex: resultsLookup.get(node)!,
  494. });
  495. }
  496. if (isTraceNode(node)) {
  497. traceDispatch({type: 'activate tab', payload: TRACE_TAB.node});
  498. return;
  499. }
  500. traceDispatch({
  501. type: 'activate tab',
  502. payload: node,
  503. pin_previous: event?.metaKey,
  504. });
  505. }
  506. },
  507. [traceDispatch]
  508. );
  509. const onRowClick = useCallback(
  510. (
  511. node: TraceTreeNode<TraceTree.NodeValue>,
  512. event: React.MouseEvent<HTMLElement>,
  513. index: number
  514. ) => {
  515. trackAnalytics('trace.trace_layout.span_row_click', {
  516. organization,
  517. num_children: node.children.length,
  518. type: traceNodeAnalyticsName(node),
  519. project_platform:
  520. projects.find(p => p.slug === node.metadata.project_slug)?.platform || 'other',
  521. ...traceNodeAdjacentAnalyticsProperties(node),
  522. });
  523. if (traceStateRef.current.preferences.drawer.minimized) {
  524. traceDispatch({type: 'minimize drawer', payload: false});
  525. }
  526. setRowAsFocused(node, event, traceStateRef.current.search.resultsLookup, null, 0);
  527. if (traceStateRef.current.search.resultsLookup.has(node)) {
  528. const idx = traceStateRef.current.search.resultsLookup.get(node)!;
  529. traceDispatch({
  530. type: 'set search iterator index',
  531. resultIndex: index,
  532. resultIteratorIndex: idx,
  533. });
  534. } else if (traceStateRef.current.search.resultIteratorIndex !== null) {
  535. traceDispatch({type: 'clear search iterator index'});
  536. }
  537. traceDispatch({
  538. type: 'set roving index',
  539. action_source: 'click',
  540. index,
  541. node,
  542. });
  543. },
  544. [setRowAsFocused, traceDispatch, organization, projects]
  545. );
  546. const scrollRowIntoView = useCallback(
  547. (
  548. node: TraceTreeNode<TraceTree.NodeValue>,
  549. index: number,
  550. anchor?: ViewManagerScrollAnchor,
  551. force?: boolean
  552. ) => {
  553. // Last node we scrolled to is the same as the node we want to scroll to
  554. if (previouslyScrolledToNodeRef.current === node && !force) {
  555. return;
  556. }
  557. // Always scroll to the row vertically
  558. viewManager.scrollToRow(index, anchor);
  559. if (viewManager.isOutsideOfView(node)) {
  560. viewManager.scrollRowIntoViewHorizontally(node, 0, 48, 'measured');
  561. }
  562. previouslyScrolledToNodeRef.current = node;
  563. },
  564. [viewManager]
  565. );
  566. const onScrollToNode = useCallback(
  567. (
  568. node: TraceTreeNode<TraceTree.NodeValue>
  569. ): Promise<TraceTreeNode<TraceTree.NodeValue> | null> => {
  570. return TraceTree.ExpandToPath(props.tree, TraceTree.PathToNode(node), {
  571. api,
  572. organization: props.organization,
  573. preferences: traceStatePreferencesRef.current,
  574. }).then(() => {
  575. const maybeNode = TraceTree.Find(props.tree.root, n => n === node);
  576. if (!maybeNode) {
  577. return null;
  578. }
  579. const index = TraceTree.EnforceVisibility(props.tree, maybeNode);
  580. if (index === -1) {
  581. return null;
  582. }
  583. scrollRowIntoView(maybeNode, index, 'center if outside', true);
  584. traceDispatch({
  585. type: 'set roving index',
  586. node: maybeNode,
  587. index: index,
  588. action_source: 'click',
  589. });
  590. if (traceStateRef.current.search.resultsLookup.has(maybeNode)) {
  591. traceDispatch({
  592. type: 'set search iterator index',
  593. resultIndex: index,
  594. resultIteratorIndex:
  595. traceStateRef.current.search.resultsLookup.get(maybeNode)!,
  596. });
  597. } else if (traceStateRef.current.search.resultIteratorIndex !== null) {
  598. traceDispatch({type: 'clear search iterator index'});
  599. }
  600. return maybeNode;
  601. });
  602. },
  603. [api, props.organization, scrollRowIntoView, props.tree, traceDispatch]
  604. );
  605. const onTabScrollToNode = useCallback(
  606. (
  607. node: TraceTreeNode<TraceTree.NodeValue>
  608. ): Promise<TraceTreeNode<TraceTree.NodeValue> | null> => {
  609. return onScrollToNode(node).then(maybeNode => {
  610. if (maybeNode) {
  611. setRowAsFocused(
  612. maybeNode,
  613. null,
  614. traceStateRef.current.search.resultsLookup,
  615. null,
  616. 0
  617. );
  618. }
  619. return maybeNode;
  620. });
  621. },
  622. [onScrollToNode, setRowAsFocused]
  623. );
  624. // Callback that is invoked when the trace loads and reaches its initialied state,
  625. // that is when the trace tree data and any data that the trace depends on is loaded,
  626. // but the trace is not yet rendered in the view.
  627. const onTraceLoad = useCallback(() => {
  628. logTraceMetadata(props.tree, projectsRef.current, props.organization);
  629. // The tree has the data fetched, but does not yet respect the user preferences.
  630. // We will autogroup and inject missing instrumentation if the preferences are set.
  631. // and then we will perform a search to find the node the user is interested in.
  632. const query = qs.parse(location.search);
  633. if (query.fov && typeof query.fov === 'string') {
  634. viewManager.maybeInitializeTraceViewFromQS(query.fov);
  635. }
  636. if (traceStateRef.current.preferences.missing_instrumentation) {
  637. TraceTree.DetectMissingInstrumentation(props.tree.root);
  638. }
  639. if (traceStateRef.current.preferences.autogroup.sibling) {
  640. TraceTree.AutogroupSiblingSpanNodes(props.tree.root);
  641. }
  642. if (traceStateRef.current.preferences.autogroup.parent) {
  643. TraceTree.AutogroupDirectChildrenSpanNodes(props.tree.root);
  644. }
  645. // Construct the visual representation of the tree
  646. props.tree.build();
  647. const eventId = scrollQueueRef.current?.eventId;
  648. const [type, path] = scrollQueueRef.current?.path?.[0]?.split('-') ?? [];
  649. scrollQueueRef.current = null;
  650. let node =
  651. (path === 'root' && props.tree.root.children[0]) ||
  652. (path && TraceTree.FindByID(props.tree.root, path)) ||
  653. (eventId && TraceTree.FindByID(props.tree.root, eventId)) ||
  654. null;
  655. // If the node points to a span, but we found an autogrouped node, then
  656. // perform another search inside the autogrouped node to find the more detailed
  657. // location of the span. This is necessary because the id of the autogrouped node
  658. // is in some cases inferred from the spans it contains and searching by the span id
  659. // just gives us the first match which may not be the one the user is looking for.
  660. if (node) {
  661. if (isAutogroupedNode(node) && type !== 'ag') {
  662. if (isParentAutogroupedNode(node)) {
  663. node = TraceTree.FindByID(node.head, eventId ?? path) ?? node;
  664. } else if (isSiblingAutogroupedNode(node)) {
  665. node = node.children.find(n => TraceTree.FindByID(n, eventId ?? path)) ?? node;
  666. }
  667. }
  668. }
  669. const index = node ? TraceTree.EnforceVisibility(props.tree, node) : -1;
  670. if (traceStateRef.current.search.query) {
  671. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  672. }
  673. if (index === -1 || !node) {
  674. const hasScrollComponent = !!(path || eventId);
  675. if (hasScrollComponent) {
  676. Sentry.withScope(scope => {
  677. scope.setFingerprint(['trace-view-scroll-to-node-error']);
  678. scope.captureMessage('Failed to scroll to node in trace tree');
  679. });
  680. }
  681. return;
  682. }
  683. // At load time, we want to scroll the row into view, but we need to wait for the view
  684. // to initialize before we can do that. We listen for the 'initialize virtualized list' and scroll
  685. // to the row in the view if it is not in view yet. If its in the view, then scroll to it immediately.
  686. traceScheduler.once('initialize virtualized list', () => {
  687. function onTargetRowMeasure() {
  688. if (!node || !viewManager.row_measurer.cache.has(node)) {
  689. return;
  690. }
  691. viewManager.row_measurer.off('row measure end', onTargetRowMeasure);
  692. if (viewManager.isOutsideOfView(node)) {
  693. viewManager.scrollRowIntoViewHorizontally(node!, 0, 48, 'measured');
  694. }
  695. }
  696. viewManager.scrollToRow(index, 'center');
  697. viewManager.row_measurer.on('row measure end', onTargetRowMeasure);
  698. previouslyScrolledToNodeRef.current = node;
  699. setRowAsFocused(node, null, traceStateRef.current.search.resultsLookup, index);
  700. traceDispatch({
  701. type: 'set roving index',
  702. node: node,
  703. index: index,
  704. action_source: 'load',
  705. });
  706. });
  707. }, [
  708. setRowAsFocused,
  709. traceDispatch,
  710. onTraceSearch,
  711. viewManager,
  712. traceScheduler,
  713. scrollQueueRef,
  714. props.tree,
  715. props.organization,
  716. ]);
  717. // Setup the middleware for the trace reducer
  718. useLayoutEffect(() => {
  719. const beforeTraceNextStateDispatch: DispatchingReducerMiddleware<
  720. typeof TraceReducer
  721. >['before next state'] = (prevState, nextState, action) => {
  722. // This effect is responsible fo syncing the keyboard interactions with the search results,
  723. // we observe the changes to the roving tab index and search results and react by syncing the state.
  724. const {node: nextRovingNode, index: nextRovingTabIndex} = nextState.rovingTabIndex;
  725. const {resultIndex: nextSearchResultIndex} = nextState.search;
  726. if (
  727. nextRovingNode &&
  728. action.type === 'set roving index' &&
  729. action.action_source !== 'click' &&
  730. typeof nextRovingTabIndex === 'number' &&
  731. prevState.rovingTabIndex.node !== nextRovingNode
  732. ) {
  733. // When the roving tabIndex updates mark the node as focused and sync search results
  734. setRowAsFocused(
  735. nextRovingNode,
  736. null,
  737. nextState.search.resultsLookup,
  738. nextRovingTabIndex
  739. );
  740. if (action.type === 'set roving index' && action.action_source === 'keyboard') {
  741. scrollRowIntoView(nextRovingNode, nextRovingTabIndex, undefined);
  742. }
  743. if (nextState.search.resultsLookup.has(nextRovingNode)) {
  744. const idx = nextState.search.resultsLookup.get(nextRovingNode)!;
  745. traceDispatch({
  746. type: 'set search iterator index',
  747. resultIndex: nextRovingTabIndex,
  748. resultIteratorIndex: idx,
  749. });
  750. } else if (nextState.search.resultIteratorIndex !== null) {
  751. traceDispatch({type: 'clear search iterator index'});
  752. }
  753. } else if (
  754. typeof nextSearchResultIndex === 'number' &&
  755. prevState.search.resultIndex !== nextSearchResultIndex &&
  756. action.type !== 'set search iterator index'
  757. ) {
  758. // If the search result index changes, mark the node as focused and scroll it into view
  759. const nextNode = props.tree.list[nextSearchResultIndex];
  760. setRowAsFocused(
  761. nextNode,
  762. null,
  763. nextState.search.resultsLookup,
  764. nextSearchResultIndex
  765. );
  766. scrollRowIntoView(nextNode, nextSearchResultIndex, 'center if outside');
  767. }
  768. };
  769. traceStateEmitter.on('before next state', beforeTraceNextStateDispatch);
  770. return () => {
  771. traceStateEmitter.off('before next state', beforeTraceNextStateDispatch);
  772. };
  773. }, [
  774. props.tree,
  775. onTraceSearch,
  776. traceStateEmitter,
  777. traceDispatch,
  778. setRowAsFocused,
  779. scrollRowIntoView,
  780. ]);
  781. // Setup the middleware for the view manager and store the list width as a preference
  782. useLayoutEffect(() => {
  783. function onDividerResizeEnd(list_width: number) {
  784. traceDispatch({
  785. type: 'set list width',
  786. payload: list_width,
  787. });
  788. }
  789. traceScheduler.on('divider resize end', onDividerResizeEnd);
  790. return () => {
  791. traceScheduler.off('divider resize end', onDividerResizeEnd);
  792. };
  793. }, [traceScheduler, traceDispatch]);
  794. const [traceGridRef, setTraceGridRef] = useState<HTMLElement | null>(null);
  795. // Memoized because it requires tree traversal
  796. const shape = useMemo(() => props.tree.shape, [props.tree]);
  797. useLayoutEffect(() => {
  798. if (props.tree.type !== 'trace') {
  799. return undefined;
  800. }
  801. traceScheduler.dispatch('initialize trace space', [
  802. props.tree.root.space[0],
  803. 0,
  804. props.tree.root.space[1],
  805. 1,
  806. ]);
  807. // Whenever the timeline changes, update the trace space and trigger a redraw
  808. const onTraceTimelineChange = (s: [number, number]) => {
  809. traceScheduler.dispatch('set trace space', [s[0], 0, s[1], 1]);
  810. };
  811. props.tree.on('trace timeline change', onTraceTimelineChange);
  812. return () => {
  813. props.tree.off('trace timeline change', onTraceTimelineChange);
  814. };
  815. }, [viewManager, traceScheduler, props.tree]);
  816. const onLoadScrollStatus = useTraceOnLoad({
  817. onTraceLoad,
  818. pathToNodeOrEventId: scrollQueueRef.current,
  819. tree: props.tree,
  820. });
  821. // Sync part of the state with the URL
  822. const traceQueryStateSync = useMemo(() => {
  823. return {search: traceState.search.query};
  824. }, [traceState.search.query]);
  825. useTraceQueryParamStateSync(traceQueryStateSync);
  826. const onAutogroupChange = useCallback(() => {
  827. const value = !traceState.preferences.autogroup.parent;
  828. if (!value) {
  829. let removeCount = 0;
  830. removeCount += TraceTree.RemoveSiblingAutogroupNodes(props.tree.root);
  831. removeCount += TraceTree.RemoveDirectChildrenAutogroupNodes(props.tree.root);
  832. addSuccessMessage(
  833. removeCount > 0
  834. ? tct('Autogrouping disabled, removed [count] autogroup spans', {
  835. count: removeCount,
  836. })
  837. : t('Autogrouping disabled')
  838. );
  839. } else {
  840. let autogroupCount = 0;
  841. autogroupCount += TraceTree.AutogroupSiblingSpanNodes(props.tree.root);
  842. autogroupCount += TraceTree.AutogroupDirectChildrenSpanNodes(props.tree.root);
  843. addSuccessMessage(
  844. autogroupCount > 0
  845. ? tct('Autogrouping enabled, detected [count] autogrouping spans', {
  846. count: autogroupCount,
  847. })
  848. : t('Autogrouping enabled')
  849. );
  850. }
  851. traceAnalytics.trackAutogroupingPreferenceChange(props.organization, value);
  852. props.tree.rebuild();
  853. traceDispatch({
  854. type: 'set autogrouping',
  855. payload: value,
  856. });
  857. }, [traceDispatch, traceState.preferences.autogroup, props.tree, props.organization]);
  858. const onMissingInstrumentationChange = useCallback(() => {
  859. const value = !traceState.preferences.missing_instrumentation;
  860. if (!value) {
  861. const removeCount = TraceTree.RemoveMissingInstrumentationNodes(props.tree.root);
  862. addSuccessMessage(
  863. removeCount > 0
  864. ? tct(
  865. 'Missing instrumentation disabled, removed [count] missing instrumentation spans',
  866. {
  867. count: removeCount,
  868. }
  869. )
  870. : t('Missing instrumentation disabled')
  871. );
  872. } else {
  873. const missingInstrumentationCount = TraceTree.DetectMissingInstrumentation(
  874. props.tree.root
  875. );
  876. addSuccessMessage(
  877. missingInstrumentationCount > 0
  878. ? tct(
  879. 'Missing instrumentation enabled, found [count] missing instrumentation spans',
  880. {
  881. count: missingInstrumentationCount,
  882. }
  883. )
  884. : t('Missing instrumentation enabled')
  885. );
  886. }
  887. traceAnalytics.trackMissingInstrumentationPreferenceChange(props.organization, value);
  888. props.tree.rebuild();
  889. traceDispatch({
  890. type: 'set missing instrumentation',
  891. payload: value,
  892. });
  893. }, [
  894. traceDispatch,
  895. traceState.preferences.missing_instrumentation,
  896. props.tree,
  897. props.organization,
  898. ]);
  899. return (
  900. <Fragment>
  901. <TraceTypeWarnings
  902. tree={props.tree}
  903. traceSlug={props.traceSlug}
  904. organization={organization}
  905. />
  906. <TraceToolbar>
  907. <TraceSearchInput onTraceSearch={onTraceSearch} organization={organization} />
  908. <TraceResetZoomButton
  909. viewManager={viewManager}
  910. organization={props.organization}
  911. />
  912. <TraceShortcuts />
  913. <TracePreferencesDropdown
  914. autogroup={
  915. traceState.preferences.autogroup.parent &&
  916. traceState.preferences.autogroup.sibling
  917. }
  918. missingInstrumentation={traceState.preferences.missing_instrumentation}
  919. onAutogroupChange={onAutogroupChange}
  920. onMissingInstrumentationChange={onMissingInstrumentationChange}
  921. />
  922. </TraceToolbar>
  923. <TraceGrid layout={traceState.preferences.layout} ref={setTraceGridRef}>
  924. <Trace
  925. trace={props.tree}
  926. rerender={rerender}
  927. trace_id={props.traceSlug}
  928. onRowClick={onRowClick}
  929. onTraceSearch={onTraceSearch}
  930. previouslyFocusedNodeRef={previouslyFocusedNodeRef}
  931. manager={viewManager}
  932. scheduler={traceScheduler}
  933. forceRerender={forceRender}
  934. isEmbedded={props.isEmbedded}
  935. isLoading={props.tree.type === 'loading' || onLoadScrollStatus === 'pending'}
  936. />
  937. {props.tree.type === 'loading' || onLoadScrollStatus === 'pending' ? (
  938. <TraceLoading />
  939. ) : props.tree.type === 'error' ? (
  940. <TraceError />
  941. ) : props.tree.type === 'empty' ? (
  942. <TraceEmpty />
  943. ) : null}
  944. <TraceDrawer
  945. replay={props.replay}
  946. meta={props.meta}
  947. traceType={shape}
  948. trace={props.tree}
  949. traceGridRef={traceGridRef}
  950. manager={viewManager}
  951. scheduler={traceScheduler}
  952. onTabScrollToNode={onTabScrollToNode}
  953. onScrollToNode={onScrollToNode}
  954. rootEventResults={props.rootEvent}
  955. traceEventView={props.traceEventView}
  956. />
  957. </TraceGrid>
  958. </Fragment>
  959. );
  960. }
  961. function TraceResetZoomButton(props: {
  962. organization: Organization;
  963. viewManager: VirtualizedViewManager;
  964. }) {
  965. const onResetZoom = useCallback(() => {
  966. traceAnalytics.trackResetZoom(props.organization);
  967. props.viewManager.resetZoom();
  968. }, [props.viewManager, props.organization]);
  969. return (
  970. <ResetZoomButton
  971. size="xs"
  972. onClick={onResetZoom}
  973. ref={props.viewManager.registerResetZoomRef}
  974. >
  975. {t('Reset Zoom')}
  976. </ResetZoomButton>
  977. );
  978. }
  979. const ResetZoomButton = styled(Button)`
  980. transition: opacity 0.2s 0.5s ease-in-out;
  981. &[disabled] {
  982. cursor: not-allowed;
  983. opacity: 0.65;
  984. }
  985. `;
  986. const TraceExternalLayout = styled('div')`
  987. display: flex;
  988. flex-direction: column;
  989. flex: 1 1 100%;
  990. ~ footer {
  991. display: none;
  992. }
  993. `;
  994. const TraceInnerLayout = styled('div')`
  995. display: flex;
  996. flex-direction: column;
  997. flex: 1 1 100%;
  998. padding: ${space(2)};
  999. background-color: ${p => p.theme.background};
  1000. `;
  1001. const TraceToolbar = styled('div')`
  1002. flex-grow: 0;
  1003. display: grid;
  1004. grid-template-columns: 1fr min-content min-content min-content;
  1005. gap: ${space(1)};
  1006. `;
  1007. const TraceGrid = styled('div')<{
  1008. layout: 'drawer bottom' | 'drawer left' | 'drawer right';
  1009. }>`
  1010. border: 1px solid ${p => p.theme.border};
  1011. flex: 1 1 100%;
  1012. display: grid;
  1013. border-radius: ${p => p.theme.borderRadius};
  1014. overflow: hidden;
  1015. position: relative;
  1016. /* false positive for grid layout */
  1017. /* stylelint-disable */
  1018. grid-template-areas: ${p =>
  1019. p.layout === 'drawer bottom'
  1020. ? `
  1021. 'trace'
  1022. 'drawer'
  1023. `
  1024. : p.layout === 'drawer left'
  1025. ? `'drawer trace'`
  1026. : `'trace drawer'`};
  1027. grid-template-columns: ${p =>
  1028. p.layout === 'drawer bottom'
  1029. ? '1fr'
  1030. : p.layout === 'drawer left'
  1031. ? 'min-content 1fr'
  1032. : '1fr min-content'};
  1033. grid-template-rows: 1fr auto;
  1034. `;
  1035. const LoadingContainer = styled('div')<{animate: boolean; error?: boolean}>`
  1036. display: flex;
  1037. justify-content: center;
  1038. align-items: center;
  1039. flex-direction: column;
  1040. left: 50%;
  1041. top: 50%;
  1042. position: absolute;
  1043. height: auto;
  1044. font-size: ${p => p.theme.fontSizeMedium};
  1045. color: ${p => p.theme.gray300};
  1046. z-index: 30;
  1047. padding: 24px;
  1048. background-color: ${p => p.theme.background};
  1049. border-radius: ${p => p.theme.borderRadius};
  1050. border: 1px solid ${p => p.theme.border};
  1051. transform-origin: 50% 50%;
  1052. transform: translate(-50%, -50%);
  1053. animation: ${p =>
  1054. p.animate
  1055. ? `${p.error ? 'showLoadingContainerShake' : 'showLoadingContainer'} 300ms cubic-bezier(0.61, 1, 0.88, 1) forwards`
  1056. : 'none'};
  1057. @keyframes showLoadingContainer {
  1058. from {
  1059. opacity: 0.6;
  1060. transform: scale(0.99) translate(-50%, -50%);
  1061. }
  1062. to {
  1063. opacity: 1;
  1064. transform: scale(1) translate(-50%, -50%);
  1065. }
  1066. }
  1067. @keyframes showLoadingContainerShake {
  1068. 0% {
  1069. transform: translate(-50%, -50%);
  1070. }
  1071. 25% {
  1072. transform: translate(-51%, -50%);
  1073. }
  1074. 75% {
  1075. transform: translate(-49%, -50%);
  1076. }
  1077. 100% {
  1078. transform: translate(-50%, -50%);
  1079. }
  1080. }
  1081. `;
  1082. function TraceLoading() {
  1083. return (
  1084. // Dont flash the animation on load because it's annoying
  1085. <LoadingContainer animate={false}>
  1086. <NoMarginIndicator size={24}>
  1087. <div>{t('Assembling the trace')}</div>
  1088. </NoMarginIndicator>
  1089. </LoadingContainer>
  1090. );
  1091. }
  1092. function TraceError() {
  1093. const linkref = useRef<HTMLAnchorElement>(null);
  1094. const feedback = useFeedbackWidget({buttonRef: linkref});
  1095. useEffect(() => {
  1096. traceAnalytics.trackFailedToFetchTraceState();
  1097. }, []);
  1098. return (
  1099. <LoadingContainer animate error>
  1100. <div>{t('Ughhhhh, we failed to load your trace...')}</div>
  1101. <div>
  1102. {t('Seeing this often? Send us ')}
  1103. {feedback ? (
  1104. <a href="#" ref={linkref}>
  1105. {t('feedback')}
  1106. </a>
  1107. ) : (
  1108. <a href="mailto:support@sentry.io?subject=Trace%20fails%20to%20load">
  1109. {t('feedback')}
  1110. </a>
  1111. )}
  1112. </div>
  1113. </LoadingContainer>
  1114. );
  1115. }
  1116. function TraceEmpty() {
  1117. const linkref = useRef<HTMLAnchorElement>(null);
  1118. const feedback = useFeedbackWidget({buttonRef: linkref});
  1119. useEffect(() => {
  1120. traceAnalytics.trackEmptyTraceState();
  1121. }, []);
  1122. return (
  1123. <LoadingContainer animate>
  1124. <div>{t('This trace does not contain any data?!')}</div>
  1125. <div>
  1126. {t('Seeing this often? Send us ')}
  1127. {feedback ? (
  1128. <a href="#" ref={linkref}>
  1129. {t('feedback')}
  1130. </a>
  1131. ) : (
  1132. <a href="mailto:support@sentry.io?subject=Trace%20does%20not%20contain%20data">
  1133. {t('feedback')}
  1134. </a>
  1135. )}
  1136. </div>
  1137. </LoadingContainer>
  1138. );
  1139. }
  1140. const NoMarginIndicator = styled(LoadingIndicator)`
  1141. margin: 0;
  1142. `;