index.tsx 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  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. }
  400. function done([matches, lookup, activeNodeSearchResult]) {
  401. // If the previous node is still in the results set, we want to keep it
  402. if (activeNodeSearchResult) {
  403. traceDispatch({
  404. type: 'set results',
  405. results: matches,
  406. resultsLookup: lookup,
  407. resultIteratorIndex: activeNodeSearchResult?.resultIteratorIndex,
  408. resultIndex: activeNodeSearchResult?.resultIndex,
  409. previousNode: activeNodeSearchResult,
  410. node: activeNode,
  411. });
  412. return;
  413. }
  414. if (activeNode && behavior === 'persist') {
  415. traceDispatch({
  416. type: 'set results',
  417. results: matches,
  418. resultsLookup: lookup,
  419. resultIteratorIndex: undefined,
  420. resultIndex: undefined,
  421. previousNode: null,
  422. node: activeNode,
  423. });
  424. return;
  425. }
  426. const resultIndex: number | undefined = matches?.[0]?.index;
  427. const resultIteratorIndex: number | undefined = matches?.[0] ? 0 : undefined;
  428. const node: TraceTreeNode<TraceTree.NodeValue> | null = matches?.[0]?.value;
  429. traceDispatch({
  430. type: 'set results',
  431. results: matches,
  432. resultsLookup: lookup,
  433. resultIteratorIndex: resultIteratorIndex,
  434. resultIndex: resultIndex,
  435. previousNode: activeNodeSearchResult,
  436. node,
  437. });
  438. }
  439. const tokens = parseTraceSearch(query);
  440. if (tokens) {
  441. searchingRaf.current = searchInTraceTreeTokens(
  442. props.tree,
  443. tokens,
  444. activeNode,
  445. done
  446. );
  447. } else {
  448. searchingRaf.current = searchInTraceTreeText(props.tree, query, activeNode, done);
  449. }
  450. },
  451. [traceDispatch, props.tree]
  452. );
  453. // We need to heavily debounce query string updates because the rest of the app is so slow
  454. // to rerender that it causes the search to drop frames on every keystroke...
  455. const QUERY_STRING_STATE_DEBOUNCE = 300;
  456. const queryStringAnimationTimeoutRef = useRef<{id: number} | null>(null);
  457. const setRowAsFocused = useCallback(
  458. (
  459. node: TraceTreeNode<TraceTree.NodeValue> | null,
  460. event: React.MouseEvent<HTMLElement> | null,
  461. resultsLookup: Map<TraceTreeNode<TraceTree.NodeValue>, number>,
  462. index: number | null,
  463. debounce: number = QUERY_STRING_STATE_DEBOUNCE
  464. ) => {
  465. // sync query string with the clicked node
  466. if (node) {
  467. if (queryStringAnimationTimeoutRef.current) {
  468. cancelAnimationTimeout(queryStringAnimationTimeoutRef.current);
  469. }
  470. queryStringAnimationTimeoutRef.current = requestAnimationTimeout(() => {
  471. const currentQueryStringPath = qs.parse(location.search).node;
  472. const nextNodePath = TraceTree.PathToNode(node);
  473. // Updating the query string with the same path is problematic because it causes
  474. // the entire sentry app to rerender, which is enough to cause jank and drop frames
  475. if (JSON.stringify(currentQueryStringPath) === JSON.stringify(nextNodePath)) {
  476. return;
  477. }
  478. const {eventId: _eventId, ...query} = qs.parse(location.search);
  479. browserHistory.replace({
  480. pathname: location.pathname,
  481. query: {
  482. ...query,
  483. node: nextNodePath,
  484. },
  485. });
  486. queryStringAnimationTimeoutRef.current = null;
  487. }, debounce);
  488. if (resultsLookup.has(node) && typeof index === 'number') {
  489. traceDispatch({
  490. type: 'set search iterator index',
  491. resultIndex: index,
  492. resultIteratorIndex: resultsLookup.get(node)!,
  493. });
  494. }
  495. if (isTraceNode(node)) {
  496. traceDispatch({type: 'activate tab', payload: TRACE_TAB.node});
  497. return;
  498. }
  499. traceDispatch({
  500. type: 'activate tab',
  501. payload: node,
  502. pin_previous: event?.metaKey,
  503. });
  504. }
  505. },
  506. [traceDispatch]
  507. );
  508. const onRowClick = useCallback(
  509. (
  510. node: TraceTreeNode<TraceTree.NodeValue>,
  511. event: React.MouseEvent<HTMLElement>,
  512. index: number
  513. ) => {
  514. trackAnalytics('trace.trace_layout.span_row_click', {
  515. organization,
  516. num_children: node.children.length,
  517. type: traceNodeAnalyticsName(node),
  518. project_platform:
  519. projects.find(p => p.slug === node.metadata.project_slug)?.platform || 'other',
  520. ...traceNodeAdjacentAnalyticsProperties(node),
  521. });
  522. if (traceStateRef.current.preferences.drawer.minimized) {
  523. traceDispatch({type: 'minimize drawer', payload: false});
  524. }
  525. setRowAsFocused(node, event, traceStateRef.current.search.resultsLookup, null, 0);
  526. if (traceStateRef.current.search.resultsLookup.has(node)) {
  527. const idx = traceStateRef.current.search.resultsLookup.get(node)!;
  528. traceDispatch({
  529. type: 'set search iterator index',
  530. resultIndex: index,
  531. resultIteratorIndex: idx,
  532. });
  533. } else if (traceStateRef.current.search.resultIteratorIndex !== null) {
  534. traceDispatch({type: 'clear search iterator index'});
  535. }
  536. traceDispatch({
  537. type: 'set roving index',
  538. action_source: 'click',
  539. index,
  540. node,
  541. });
  542. },
  543. [setRowAsFocused, traceDispatch, organization, projects]
  544. );
  545. const scrollRowIntoView = useCallback(
  546. (
  547. node: TraceTreeNode<TraceTree.NodeValue>,
  548. index: number,
  549. anchor?: ViewManagerScrollAnchor,
  550. force?: boolean
  551. ) => {
  552. // Last node we scrolled to is the same as the node we want to scroll to
  553. if (previouslyScrolledToNodeRef.current === node && !force) {
  554. return;
  555. }
  556. // Always scroll to the row vertically
  557. viewManager.scrollToRow(index, anchor);
  558. if (viewManager.isOutsideOfView(node)) {
  559. viewManager.scrollRowIntoViewHorizontally(node, 0, 48, 'measured');
  560. }
  561. previouslyScrolledToNodeRef.current = node;
  562. },
  563. [viewManager]
  564. );
  565. const onScrollToNode = useCallback(
  566. (
  567. node: TraceTreeNode<TraceTree.NodeValue>
  568. ): Promise<TraceTreeNode<TraceTree.NodeValue> | null> => {
  569. return TraceTree.ExpandToPath(props.tree, TraceTree.PathToNode(node), {
  570. api,
  571. organization: props.organization,
  572. preferences: traceStatePreferencesRef.current,
  573. }).then(() => {
  574. const maybeNode = TraceTree.Find(props.tree.root, n => n === node);
  575. if (!maybeNode) {
  576. return null;
  577. }
  578. const index = TraceTree.EnforceVisibility(props.tree, maybeNode);
  579. if (index === -1) {
  580. return null;
  581. }
  582. scrollRowIntoView(maybeNode, index, 'center if outside', true);
  583. traceDispatch({
  584. type: 'set roving index',
  585. node: maybeNode,
  586. index: index,
  587. action_source: 'click',
  588. });
  589. if (traceStateRef.current.search.resultsLookup.has(maybeNode)) {
  590. traceDispatch({
  591. type: 'set search iterator index',
  592. resultIndex: index,
  593. resultIteratorIndex:
  594. traceStateRef.current.search.resultsLookup.get(maybeNode)!,
  595. });
  596. } else if (traceStateRef.current.search.resultIteratorIndex !== null) {
  597. traceDispatch({type: 'clear search iterator index'});
  598. }
  599. return maybeNode;
  600. });
  601. },
  602. [api, props.organization, scrollRowIntoView, props.tree, traceDispatch]
  603. );
  604. const onTabScrollToNode = useCallback(
  605. (
  606. node: TraceTreeNode<TraceTree.NodeValue>
  607. ): Promise<TraceTreeNode<TraceTree.NodeValue> | null> => {
  608. return onScrollToNode(node).then(maybeNode => {
  609. if (maybeNode) {
  610. setRowAsFocused(
  611. maybeNode,
  612. null,
  613. traceStateRef.current.search.resultsLookup,
  614. null,
  615. 0
  616. );
  617. }
  618. return maybeNode;
  619. });
  620. },
  621. [onScrollToNode, setRowAsFocused]
  622. );
  623. // Callback that is invoked when the trace loads and reaches its initialied state,
  624. // that is when the trace tree data and any data that the trace depends on is loaded,
  625. // but the trace is not yet rendered in the view.
  626. const onTraceLoad = useCallback(() => {
  627. logTraceMetadata(props.tree, projectsRef.current, props.organization);
  628. // The tree has the data fetched, but does not yet respect the user preferences.
  629. // We will autogroup and inject missing instrumentation if the preferences are set.
  630. // and then we will perform a search to find the node the user is interested in.
  631. const query = qs.parse(location.search);
  632. if (query.fov && typeof query.fov === 'string') {
  633. viewManager.maybeInitializeTraceViewFromQS(query.fov);
  634. }
  635. if (traceStateRef.current.preferences.missing_instrumentation) {
  636. TraceTree.DetectMissingInstrumentation(props.tree.root);
  637. }
  638. if (traceStateRef.current.preferences.autogroup.sibling) {
  639. TraceTree.AutogroupSiblingSpanNodes(props.tree.root);
  640. }
  641. if (traceStateRef.current.preferences.autogroup.parent) {
  642. TraceTree.AutogroupDirectChildrenSpanNodes(props.tree.root);
  643. }
  644. // Construct the visual representation of the tree
  645. props.tree.build();
  646. const eventId = scrollQueueRef.current?.eventId;
  647. const [type, path] = scrollQueueRef.current?.path?.[0]?.split('-') ?? [];
  648. scrollQueueRef.current = null;
  649. let node =
  650. (path === 'root' && props.tree.root.children[0]) ||
  651. (path && TraceTree.FindByID(props.tree.root, path)) ||
  652. (eventId && TraceTree.FindByID(props.tree.root, eventId)) ||
  653. null;
  654. // If the node points to a span, but we found an autogrouped node, then
  655. // perform another search inside the autogrouped node to find the more detailed
  656. // location of the span. This is necessary because the id of the autogrouped node
  657. // is in some cases inferred from the spans it contains and searching by the span id
  658. // just gives us the first match which may not be the one the user is looking for.
  659. if (node) {
  660. if (isAutogroupedNode(node) && type !== 'ag') {
  661. if (isParentAutogroupedNode(node)) {
  662. node = TraceTree.FindByID(node.head, eventId ?? path) ?? node;
  663. } else if (isSiblingAutogroupedNode(node)) {
  664. node = node.children.find(n => TraceTree.FindByID(n, eventId ?? path)) ?? node;
  665. }
  666. }
  667. }
  668. const index = node ? TraceTree.EnforceVisibility(props.tree, node) : -1;
  669. if (traceStateRef.current.search.query) {
  670. onTraceSearch(traceStateRef.current.search.query, node, 'persist');
  671. }
  672. if (index === -1 || !node) {
  673. const hasScrollComponent = !!(path || eventId);
  674. if (hasScrollComponent) {
  675. Sentry.withScope(scope => {
  676. scope.setFingerprint(['trace-view-scroll-to-node-error']);
  677. scope.captureMessage('Failed to scroll to node in trace tree');
  678. });
  679. }
  680. return;
  681. }
  682. // At load time, we want to scroll the row into view, but we need to wait for the view
  683. // to initialize before we can do that. We listen for the 'initialize virtualized list' and scroll
  684. // to the row in the view if it is not in view yet. If its in the view, then scroll to it immediately.
  685. traceScheduler.once('initialize virtualized list', () => {
  686. function onTargetRowMeasure() {
  687. if (!node || !viewManager.row_measurer.cache.has(node)) {
  688. return;
  689. }
  690. viewManager.row_measurer.off('row measure end', onTargetRowMeasure);
  691. if (viewManager.isOutsideOfView(node)) {
  692. viewManager.scrollRowIntoViewHorizontally(node!, 0, 48, 'measured');
  693. }
  694. }
  695. viewManager.scrollToRow(index, 'center');
  696. viewManager.row_measurer.on('row measure end', onTargetRowMeasure);
  697. previouslyScrolledToNodeRef.current = node;
  698. setRowAsFocused(node, null, traceStateRef.current.search.resultsLookup, index);
  699. traceDispatch({
  700. type: 'set roving index',
  701. node: node,
  702. index: index,
  703. action_source: 'load',
  704. });
  705. });
  706. }, [
  707. setRowAsFocused,
  708. traceDispatch,
  709. onTraceSearch,
  710. viewManager,
  711. traceScheduler,
  712. scrollQueueRef,
  713. props.tree,
  714. props.organization,
  715. ]);
  716. // Setup the middleware for the trace reducer
  717. useLayoutEffect(() => {
  718. const beforeTraceNextStateDispatch: DispatchingReducerMiddleware<
  719. typeof TraceReducer
  720. >['before next state'] = (prevState, nextState, action) => {
  721. // This effect is responsible fo syncing the keyboard interactions with the search results,
  722. // we observe the changes to the roving tab index and search results and react by syncing the state.
  723. const {node: nextRovingNode, index: nextRovingTabIndex} = nextState.rovingTabIndex;
  724. const {resultIndex: nextSearchResultIndex} = nextState.search;
  725. if (
  726. nextRovingNode &&
  727. action.type === 'set roving index' &&
  728. action.action_source !== 'click' &&
  729. typeof nextRovingTabIndex === 'number' &&
  730. prevState.rovingTabIndex.node !== nextRovingNode
  731. ) {
  732. // When the roving tabIndex updates mark the node as focused and sync search results
  733. setRowAsFocused(
  734. nextRovingNode,
  735. null,
  736. nextState.search.resultsLookup,
  737. nextRovingTabIndex
  738. );
  739. if (action.type === 'set roving index' && action.action_source === 'keyboard') {
  740. scrollRowIntoView(nextRovingNode, nextRovingTabIndex, undefined);
  741. }
  742. if (nextState.search.resultsLookup.has(nextRovingNode)) {
  743. const idx = nextState.search.resultsLookup.get(nextRovingNode)!;
  744. traceDispatch({
  745. type: 'set search iterator index',
  746. resultIndex: nextRovingTabIndex,
  747. resultIteratorIndex: idx,
  748. });
  749. } else if (nextState.search.resultIteratorIndex !== null) {
  750. traceDispatch({type: 'clear search iterator index'});
  751. }
  752. } else if (
  753. typeof nextSearchResultIndex === 'number' &&
  754. prevState.search.resultIndex !== nextSearchResultIndex &&
  755. action.type !== 'set search iterator index'
  756. ) {
  757. // If the search result index changes, mark the node as focused and scroll it into view
  758. const nextNode = props.tree.list[nextSearchResultIndex];
  759. setRowAsFocused(
  760. nextNode,
  761. null,
  762. nextState.search.resultsLookup,
  763. nextSearchResultIndex
  764. );
  765. scrollRowIntoView(nextNode, nextSearchResultIndex, 'center if outside');
  766. }
  767. };
  768. traceStateEmitter.on('before next state', beforeTraceNextStateDispatch);
  769. return () => {
  770. traceStateEmitter.off('before next state', beforeTraceNextStateDispatch);
  771. };
  772. }, [
  773. props.tree,
  774. onTraceSearch,
  775. traceStateEmitter,
  776. traceDispatch,
  777. setRowAsFocused,
  778. scrollRowIntoView,
  779. ]);
  780. // Setup the middleware for the view manager and store the list width as a preference
  781. useLayoutEffect(() => {
  782. function onDividerResizeEnd(list_width: number) {
  783. traceDispatch({
  784. type: 'set list width',
  785. payload: list_width,
  786. });
  787. }
  788. traceScheduler.on('divider resize end', onDividerResizeEnd);
  789. return () => {
  790. traceScheduler.off('divider resize end', onDividerResizeEnd);
  791. };
  792. }, [traceScheduler, traceDispatch]);
  793. const [traceGridRef, setTraceGridRef] = useState<HTMLElement | null>(null);
  794. // Memoized because it requires tree traversal
  795. const shape = useMemo(() => props.tree.shape, [props.tree]);
  796. useLayoutEffect(() => {
  797. if (props.tree.type !== 'trace') {
  798. return undefined;
  799. }
  800. traceScheduler.dispatch('initialize trace space', [
  801. props.tree.root.space[0],
  802. 0,
  803. props.tree.root.space[1],
  804. 1,
  805. ]);
  806. // Whenever the timeline changes, update the trace space and trigger a redraw
  807. const onTraceTimelineChange = (s: [number, number]) => {
  808. traceScheduler.dispatch('set trace space', [s[0], 0, s[1], 1]);
  809. };
  810. props.tree.on('trace timeline change', onTraceTimelineChange);
  811. return () => {
  812. props.tree.off('trace timeline change', onTraceTimelineChange);
  813. };
  814. }, [viewManager, traceScheduler, props.tree]);
  815. const onLoadScrollStatus = useTraceOnLoad({
  816. onTraceLoad,
  817. pathToNodeOrEventId: scrollQueueRef.current,
  818. tree: props.tree,
  819. });
  820. // Sync part of the state with the URL
  821. const traceQueryStateSync = useMemo(() => {
  822. return {search: traceState.search.query};
  823. }, [traceState.search.query]);
  824. useTraceQueryParamStateSync(traceQueryStateSync);
  825. const onAutogroupChange = useCallback(() => {
  826. const value = !traceState.preferences.autogroup.parent;
  827. if (!value) {
  828. let removeCount = 0;
  829. removeCount += TraceTree.RemoveSiblingAutogroupNodes(props.tree.root);
  830. removeCount += TraceTree.RemoveDirectChildrenAutogroupNodes(props.tree.root);
  831. addSuccessMessage(
  832. removeCount > 0
  833. ? tct('Autogrouping disabled, removed [count] autogroup spans', {
  834. count: removeCount,
  835. })
  836. : t('Autogrouping disabled')
  837. );
  838. } else {
  839. let autogroupCount = 0;
  840. autogroupCount += TraceTree.AutogroupSiblingSpanNodes(props.tree.root);
  841. autogroupCount += TraceTree.AutogroupDirectChildrenSpanNodes(props.tree.root);
  842. addSuccessMessage(
  843. autogroupCount > 0
  844. ? tct('Autogrouping enabled, detected [count] autogrouping spans', {
  845. count: autogroupCount,
  846. })
  847. : t('Autogrouping enabled')
  848. );
  849. }
  850. traceAnalytics.trackAutogroupingPreferenceChange(props.organization, value);
  851. props.tree.rebuild();
  852. traceDispatch({
  853. type: 'set autogrouping',
  854. payload: value,
  855. });
  856. }, [traceDispatch, traceState.preferences.autogroup, props.tree, props.organization]);
  857. const onMissingInstrumentationChange = useCallback(() => {
  858. const value = !traceState.preferences.missing_instrumentation;
  859. if (!value) {
  860. const removeCount = TraceTree.RemoveMissingInstrumentationNodes(props.tree.root);
  861. addSuccessMessage(
  862. removeCount > 0
  863. ? tct(
  864. 'Missing instrumentation disabled, removed [count] missing instrumentation spans',
  865. {
  866. count: removeCount,
  867. }
  868. )
  869. : t('Missing instrumentation disabled')
  870. );
  871. } else {
  872. const missingInstrumentationCount = TraceTree.DetectMissingInstrumentation(
  873. props.tree.root
  874. );
  875. addSuccessMessage(
  876. missingInstrumentationCount > 0
  877. ? tct(
  878. 'Missing instrumentation enabled, found [count] missing instrumentation spans',
  879. {
  880. count: missingInstrumentationCount,
  881. }
  882. )
  883. : t('Missing instrumentation enabled')
  884. );
  885. }
  886. traceAnalytics.trackMissingInstrumentationPreferenceChange(props.organization, value);
  887. props.tree.rebuild();
  888. traceDispatch({
  889. type: 'set missing instrumentation',
  890. payload: value,
  891. });
  892. }, [
  893. traceDispatch,
  894. traceState.preferences.missing_instrumentation,
  895. props.tree,
  896. props.organization,
  897. ]);
  898. return (
  899. <Fragment>
  900. <TraceTypeWarnings
  901. tree={props.tree}
  902. traceSlug={props.traceSlug}
  903. organization={organization}
  904. />
  905. <TraceToolbar>
  906. <TraceSearchInput onTraceSearch={onTraceSearch} organization={organization} />
  907. <TraceResetZoomButton
  908. viewManager={viewManager}
  909. organization={props.organization}
  910. />
  911. <TraceShortcuts />
  912. <TracePreferencesDropdown
  913. autogroup={
  914. traceState.preferences.autogroup.parent &&
  915. traceState.preferences.autogroup.sibling
  916. }
  917. missingInstrumentation={traceState.preferences.missing_instrumentation}
  918. onAutogroupChange={onAutogroupChange}
  919. onMissingInstrumentationChange={onMissingInstrumentationChange}
  920. />
  921. </TraceToolbar>
  922. <TraceGrid layout={traceState.preferences.layout} ref={setTraceGridRef}>
  923. <Trace
  924. trace={props.tree}
  925. rerender={rerender}
  926. trace_id={props.traceSlug}
  927. onRowClick={onRowClick}
  928. onTraceSearch={onTraceSearch}
  929. previouslyFocusedNodeRef={previouslyFocusedNodeRef}
  930. manager={viewManager}
  931. scheduler={traceScheduler}
  932. forceRerender={forceRender}
  933. isEmbedded={props.isEmbedded}
  934. isLoading={props.tree.type === 'loading' || onLoadScrollStatus === 'pending'}
  935. />
  936. {props.tree.type === 'loading' || onLoadScrollStatus === 'pending' ? (
  937. <TraceLoading />
  938. ) : props.tree.type === 'error' ? (
  939. <TraceError />
  940. ) : props.tree.type === 'empty' ? (
  941. <TraceEmpty />
  942. ) : null}
  943. <TraceDrawer
  944. replay={props.replay}
  945. meta={props.meta}
  946. traceType={shape}
  947. trace={props.tree}
  948. traceGridRef={traceGridRef}
  949. manager={viewManager}
  950. scheduler={traceScheduler}
  951. onTabScrollToNode={onTabScrollToNode}
  952. onScrollToNode={onScrollToNode}
  953. rootEventResults={props.rootEvent}
  954. traceEventView={props.traceEventView}
  955. />
  956. </TraceGrid>
  957. </Fragment>
  958. );
  959. }
  960. function TraceResetZoomButton(props: {
  961. organization: Organization;
  962. viewManager: VirtualizedViewManager;
  963. }) {
  964. const onResetZoom = useCallback(() => {
  965. traceAnalytics.trackResetZoom(props.organization);
  966. props.viewManager.resetZoom();
  967. }, [props.viewManager, props.organization]);
  968. return (
  969. <ResetZoomButton
  970. size="xs"
  971. onClick={onResetZoom}
  972. ref={props.viewManager.registerResetZoomRef}
  973. >
  974. {t('Reset Zoom')}
  975. </ResetZoomButton>
  976. );
  977. }
  978. const ResetZoomButton = styled(Button)`
  979. transition: opacity 0.2s 0.5s ease-in-out;
  980. &[disabled] {
  981. cursor: not-allowed;
  982. opacity: 0.65;
  983. }
  984. `;
  985. const TraceExternalLayout = styled('div')`
  986. display: flex;
  987. flex-direction: column;
  988. flex: 1 1 100%;
  989. ~ footer {
  990. display: none;
  991. }
  992. `;
  993. const TraceInnerLayout = styled('div')`
  994. display: flex;
  995. flex-direction: column;
  996. flex: 1 1 100%;
  997. padding: ${space(2)};
  998. background-color: ${p => p.theme.background};
  999. `;
  1000. const TraceToolbar = styled('div')`
  1001. flex-grow: 0;
  1002. display: grid;
  1003. grid-template-columns: 1fr min-content min-content min-content;
  1004. gap: ${space(1)};
  1005. `;
  1006. const TraceGrid = styled('div')<{
  1007. layout: 'drawer bottom' | 'drawer left' | 'drawer right';
  1008. }>`
  1009. border: 1px solid ${p => p.theme.border};
  1010. flex: 1 1 100%;
  1011. display: grid;
  1012. border-radius: ${p => p.theme.borderRadius};
  1013. overflow: hidden;
  1014. position: relative;
  1015. /* false positive for grid layout */
  1016. /* stylelint-disable */
  1017. grid-template-areas: ${p =>
  1018. p.layout === 'drawer bottom'
  1019. ? `
  1020. 'trace'
  1021. 'drawer'
  1022. `
  1023. : p.layout === 'drawer left'
  1024. ? `'drawer trace'`
  1025. : `'trace drawer'`};
  1026. grid-template-columns: ${p =>
  1027. p.layout === 'drawer bottom'
  1028. ? '1fr'
  1029. : p.layout === 'drawer left'
  1030. ? 'min-content 1fr'
  1031. : '1fr min-content'};
  1032. grid-template-rows: 1fr auto;
  1033. `;
  1034. const LoadingContainer = styled('div')<{animate: boolean; error?: boolean}>`
  1035. display: flex;
  1036. justify-content: center;
  1037. align-items: center;
  1038. flex-direction: column;
  1039. left: 50%;
  1040. top: 50%;
  1041. position: absolute;
  1042. height: auto;
  1043. font-size: ${p => p.theme.fontSizeMedium};
  1044. color: ${p => p.theme.gray300};
  1045. z-index: 30;
  1046. padding: 24px;
  1047. background-color: ${p => p.theme.background};
  1048. border-radius: ${p => p.theme.borderRadius};
  1049. border: 1px solid ${p => p.theme.border};
  1050. transform-origin: 50% 50%;
  1051. transform: translate(-50%, -50%);
  1052. animation: ${p =>
  1053. p.animate
  1054. ? `${p.error ? 'showLoadingContainerShake' : 'showLoadingContainer'} 300ms cubic-bezier(0.61, 1, 0.88, 1) forwards`
  1055. : 'none'};
  1056. @keyframes showLoadingContainer {
  1057. from {
  1058. opacity: 0.6;
  1059. transform: scale(0.99) translate(-50%, -50%);
  1060. }
  1061. to {
  1062. opacity: 1;
  1063. transform: scale(1) translate(-50%, -50%);
  1064. }
  1065. }
  1066. @keyframes showLoadingContainerShake {
  1067. 0% {
  1068. transform: translate(-50%, -50%);
  1069. }
  1070. 25% {
  1071. transform: translate(-51%, -50%);
  1072. }
  1073. 75% {
  1074. transform: translate(-49%, -50%);
  1075. }
  1076. 100% {
  1077. transform: translate(-50%, -50%);
  1078. }
  1079. }
  1080. `;
  1081. function TraceLoading() {
  1082. return (
  1083. // Dont flash the animation on load because it's annoying
  1084. <LoadingContainer animate={false}>
  1085. <NoMarginIndicator size={24}>
  1086. <div>{t('Assembling the trace')}</div>
  1087. </NoMarginIndicator>
  1088. </LoadingContainer>
  1089. );
  1090. }
  1091. function TraceError() {
  1092. const linkref = useRef<HTMLAnchorElement>(null);
  1093. const feedback = useFeedbackWidget({buttonRef: linkref});
  1094. useEffect(() => {
  1095. traceAnalytics.trackFailedToFetchTraceState();
  1096. }, []);
  1097. return (
  1098. <LoadingContainer animate error>
  1099. <div>{t('Ughhhhh, we failed to load your trace...')}</div>
  1100. <div>
  1101. {t('Seeing this often? Send us ')}
  1102. {feedback ? (
  1103. <a href="#" ref={linkref}>
  1104. {t('feedback')}
  1105. </a>
  1106. ) : (
  1107. <a href="mailto:support@sentry.io?subject=Trace%20fails%20to%20load">
  1108. {t('feedback')}
  1109. </a>
  1110. )}
  1111. </div>
  1112. </LoadingContainer>
  1113. );
  1114. }
  1115. function TraceEmpty() {
  1116. const linkref = useRef<HTMLAnchorElement>(null);
  1117. const feedback = useFeedbackWidget({buttonRef: linkref});
  1118. useEffect(() => {
  1119. traceAnalytics.trackEmptyTraceState();
  1120. }, []);
  1121. return (
  1122. <LoadingContainer animate>
  1123. <div>{t('This trace does not contain any data?!')}</div>
  1124. <div>
  1125. {t('Seeing this often? Send us ')}
  1126. {feedback ? (
  1127. <a href="#" ref={linkref}>
  1128. {t('feedback')}
  1129. </a>
  1130. ) : (
  1131. <a href="mailto:support@sentry.io?subject=Trace%20does%20not%20contain%20data">
  1132. {t('feedback')}
  1133. </a>
  1134. )}
  1135. </div>
  1136. </LoadingContainer>
  1137. );
  1138. }
  1139. const NoMarginIndicator = styled(LoadingIndicator)`
  1140. margin: 0;
  1141. `;