data.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. import {Location} from 'history';
  2. import {COL_WIDTH_UNDEFINED} from 'app/components/gridEditable';
  3. import {t} from 'app/locale';
  4. import {LightWeightOrganization, NewQuery, SelectValue} from 'app/types';
  5. import EventView from 'app/utils/discover/eventView';
  6. import {decodeScalar} from 'app/utils/queryString';
  7. import {tokenizeSearch} from 'app/utils/tokenizeSearch';
  8. import {getCurrentLandingDisplay, LandingDisplayField} from './landing/utils';
  9. import {
  10. getVitalDetailTableMehStatusFunction,
  11. getVitalDetailTablePoorStatusFunction,
  12. vitalNameFromLocation,
  13. } from './vitalDetail/utils';
  14. export const DEFAULT_STATS_PERIOD = '24h';
  15. export const COLUMN_TITLES = [
  16. 'transaction',
  17. 'project',
  18. 'tpm',
  19. 'p50',
  20. 'p95',
  21. 'failure rate',
  22. 'apdex',
  23. 'users',
  24. 'user misery',
  25. ];
  26. export enum PERFORMANCE_TERM {
  27. APDEX = 'apdex',
  28. TPM = 'tpm',
  29. THROUGHPUT = 'throughput',
  30. FAILURE_RATE = 'failureRate',
  31. P50 = 'p50',
  32. P75 = 'p75',
  33. P95 = 'p95',
  34. P99 = 'p99',
  35. LCP = 'lcp',
  36. FCP = 'fcp',
  37. USER_MISERY = 'userMisery',
  38. STATUS_BREAKDOWN = 'statusBreakdown',
  39. DURATION_DISTRIBUTION = 'durationDistribution',
  40. USER_MISERY_NEW = 'userMiseryNew',
  41. APDEX_NEW = 'apdexNew',
  42. }
  43. export type TooltipOption = SelectValue<string> & {
  44. tooltip: string;
  45. };
  46. export function getAxisOptions(organization: LightWeightOrganization): TooltipOption[] {
  47. let apdexOption: TooltipOption;
  48. if (organization.features.includes('project-transaction-threshold')) {
  49. apdexOption = {
  50. tooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX_NEW),
  51. value: 'apdex()',
  52. label: t('Apdex'),
  53. };
  54. } else {
  55. apdexOption = {
  56. tooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX),
  57. value: `apdex(${organization.apdexThreshold})`,
  58. label: t('Apdex'),
  59. };
  60. }
  61. return [
  62. apdexOption,
  63. {
  64. tooltip: getTermHelp(organization, PERFORMANCE_TERM.TPM),
  65. value: 'tpm()',
  66. label: t('Transactions Per Minute'),
  67. },
  68. {
  69. tooltip: getTermHelp(organization, PERFORMANCE_TERM.FAILURE_RATE),
  70. value: 'failure_rate()',
  71. label: t('Failure Rate'),
  72. },
  73. {
  74. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P50),
  75. value: 'p50()',
  76. label: t('p50 Duration'),
  77. },
  78. {
  79. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P95),
  80. value: 'p95()',
  81. label: t('p95 Duration'),
  82. },
  83. {
  84. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P99),
  85. value: 'p99()',
  86. label: t('p99 Duration'),
  87. },
  88. ];
  89. }
  90. export type AxisOption = TooltipOption & {
  91. field: string;
  92. backupOption?: AxisOption;
  93. label: string;
  94. isDistribution?: boolean;
  95. isLeftDefault?: boolean;
  96. isRightDefault?: boolean;
  97. };
  98. export function getFrontendAxisOptions(
  99. organization: LightWeightOrganization
  100. ): AxisOption[] {
  101. return [
  102. {
  103. tooltip: getTermHelp(organization, PERFORMANCE_TERM.LCP),
  104. value: `p75(lcp)`,
  105. label: t('LCP p75'),
  106. field: 'p75(measurements.lcp)',
  107. isLeftDefault: true,
  108. backupOption: {
  109. tooltip: getTermHelp(organization, PERFORMANCE_TERM.FCP),
  110. value: `p75(fcp)`,
  111. label: t('FCP p75'),
  112. field: 'p75(measurements.fcp)',
  113. },
  114. },
  115. {
  116. tooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  117. value: 'lcp_distribution',
  118. label: t('LCP Distribution'),
  119. field: 'measurements.lcp',
  120. isDistribution: true,
  121. isRightDefault: true,
  122. backupOption: {
  123. tooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  124. value: 'fcp_distribution',
  125. label: t('FCP Distribution'),
  126. field: 'measurements.fcp',
  127. isDistribution: true,
  128. },
  129. },
  130. {
  131. tooltip: getTermHelp(organization, PERFORMANCE_TERM.TPM),
  132. value: 'tpm()',
  133. label: t('Transactions Per Minute'),
  134. field: 'tpm()',
  135. },
  136. ];
  137. }
  138. export function getFrontendOtherAxisOptions(
  139. organization: LightWeightOrganization
  140. ): AxisOption[] {
  141. return [
  142. {
  143. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P50),
  144. value: `p50()`,
  145. label: t('Duration p50'),
  146. field: 'p50(transaction.duration)',
  147. },
  148. {
  149. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  150. value: `p75()`,
  151. label: t('Duration p75'),
  152. field: 'p75(transaction.duration)',
  153. isLeftDefault: true,
  154. },
  155. {
  156. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P95),
  157. value: `p95()`,
  158. label: t('Duration p95'),
  159. field: 'p95(transaction.duration)',
  160. },
  161. {
  162. tooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  163. value: 'duration_distribution',
  164. label: t('Duration Distribution'),
  165. field: 'transaction.duration',
  166. isDistribution: true,
  167. isRightDefault: true,
  168. },
  169. ];
  170. }
  171. export function getBackendAxisOptions(
  172. organization: LightWeightOrganization
  173. ): AxisOption[] {
  174. let apdexOption: AxisOption;
  175. if (organization.features.includes('project-transaction-threshold')) {
  176. apdexOption = {
  177. tooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX),
  178. value: 'apdex()',
  179. label: t('Apdex'),
  180. field: 'apdex()',
  181. };
  182. } else {
  183. apdexOption = {
  184. tooltip: getTermHelp(organization, PERFORMANCE_TERM.APDEX),
  185. value: `apdex(${organization.apdexThreshold})`,
  186. label: t('Apdex'),
  187. field: `apdex(${organization.apdexThreshold})`,
  188. };
  189. }
  190. return [
  191. {
  192. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P50),
  193. value: `p50()`,
  194. label: t('Duration p50'),
  195. field: 'p50(transaction.duration)',
  196. },
  197. {
  198. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P75),
  199. value: `p75()`,
  200. label: t('Duration p75'),
  201. field: 'p75(transaction.duration)',
  202. isLeftDefault: true,
  203. },
  204. {
  205. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P95),
  206. value: `p95()`,
  207. label: t('Duration p95'),
  208. field: 'p95(transaction.duration)',
  209. },
  210. {
  211. tooltip: getTermHelp(organization, PERFORMANCE_TERM.P99),
  212. value: `p99()`,
  213. label: t('Duration p99'),
  214. field: 'p99(transaction.duration)',
  215. },
  216. {
  217. tooltip: getTermHelp(organization, PERFORMANCE_TERM.TPM),
  218. value: 'tpm()',
  219. label: t('Transactions Per Minute'),
  220. field: 'tpm()',
  221. },
  222. {
  223. tooltip: getTermHelp(organization, PERFORMANCE_TERM.FAILURE_RATE),
  224. value: 'failure_rate()',
  225. label: t('Failure Rate'),
  226. field: 'failure_rate()',
  227. },
  228. {
  229. tooltip: getTermHelp(organization, PERFORMANCE_TERM.DURATION_DISTRIBUTION),
  230. value: 'duration_distribution',
  231. label: t('Duration Distribution'),
  232. field: 'transaction.duration',
  233. isDistribution: true,
  234. isRightDefault: true,
  235. },
  236. apdexOption,
  237. ];
  238. }
  239. type TermFormatter = (organization: LightWeightOrganization) => string;
  240. const PERFORMANCE_TERMS: Record<PERFORMANCE_TERM, TermFormatter> = {
  241. apdex: () =>
  242. t(
  243. 'Apdex is the ratio of both satisfactory and tolerable response times to all response times. To adjust the tolerable threshold, go to performance settings.'
  244. ),
  245. tpm: () => t('TPM is the number of recorded transaction events per minute.'),
  246. throughput: () =>
  247. t('Throughput is the number of recorded transaction events per minute.'),
  248. failureRate: () =>
  249. t(
  250. 'Failure rate is the percentage of recorded transactions that had a known and unsuccessful status.'
  251. ),
  252. p50: () => t('p50 indicates the duration that 50% of transactions are faster than.'),
  253. p75: () => t('p75 indicates the duration that 75% of transactions are faster than.'),
  254. p95: () => t('p95 indicates the duration that 95% of transactions are faster than.'),
  255. p99: () => t('p99 indicates the duration that 99% of transactions are faster than.'),
  256. lcp: () =>
  257. t('Largest contentful paint (LCP) is a web vital meant to represent user load times'),
  258. fcp: () =>
  259. t('First contentful paint (FCP) is a web vital meant to represent user load times'),
  260. userMisery: organization =>
  261. t(
  262. "User Misery is a score that represents the number of unique users who have experienced load times 4x your organization's apdex threshold of %sms.",
  263. organization.apdexThreshold
  264. ),
  265. statusBreakdown: () =>
  266. t(
  267. 'The breakdown of transaction statuses. This may indicate what type of failure it is.'
  268. ),
  269. durationDistribution: () =>
  270. t(
  271. 'Distribution buckets counts of transactions at specifics times for your current date range'
  272. ),
  273. userMiseryNew: () =>
  274. t(
  275. "User Misery is a score that represents the number of unique users who have experienced load times 4x the project's configured threshold. Adjust project threshold in project performance settings."
  276. ),
  277. apdexNew: () =>
  278. t(
  279. 'Apdex is the ratio of both satisfactory and tolerable response times to all response times. To adjust the tolerable threshold, go to project performance settings.'
  280. ),
  281. };
  282. export function getTermHelp(
  283. organization: LightWeightOrganization,
  284. term: keyof typeof PERFORMANCE_TERMS
  285. ): string {
  286. if (!PERFORMANCE_TERMS.hasOwnProperty(term)) {
  287. return '';
  288. }
  289. return PERFORMANCE_TERMS[term](organization);
  290. }
  291. function generateGenericPerformanceEventView(
  292. organization: LightWeightOrganization,
  293. location: Location
  294. ): EventView {
  295. const {query} = location;
  296. const fields = [
  297. organization.features.includes('team-key-transactions')
  298. ? 'team_key_transaction'
  299. : 'key_transaction',
  300. 'transaction',
  301. 'project',
  302. 'tpm()',
  303. 'p50()',
  304. 'p95()',
  305. 'failure_rate()',
  306. ];
  307. const featureFields = organization.features.includes('project-transaction-threshold')
  308. ? ['apdex()', 'count_unique(user)', 'count_miserable(user)', 'user_misery()']
  309. : [
  310. `apdex(${organization.apdexThreshold})`,
  311. 'count_unique(user)',
  312. `count_miserable(user,${organization.apdexThreshold})`,
  313. `user_misery(${organization.apdexThreshold})`,
  314. ];
  315. const hasStartAndEnd = query.start && query.end;
  316. const savedQuery: NewQuery = {
  317. id: undefined,
  318. name: t('Performance'),
  319. query: 'event.type:transaction',
  320. projects: [],
  321. fields: [...fields, ...featureFields],
  322. version: 2,
  323. };
  324. const widths = Array(savedQuery.fields.length).fill(COL_WIDTH_UNDEFINED);
  325. widths[savedQuery.fields.length - 1] = '110';
  326. savedQuery.widths = widths;
  327. if (!query.statsPeriod && !hasStartAndEnd) {
  328. savedQuery.range = DEFAULT_STATS_PERIOD;
  329. }
  330. savedQuery.orderby = decodeScalar(query.sort, '-tpm');
  331. const searchQuery = decodeScalar(query.query, '');
  332. const conditions = tokenizeSearch(searchQuery);
  333. // This is not an override condition since we want the duration to appear in the search bar as a default.
  334. if (!conditions.hasTag('transaction.duration')) {
  335. conditions.setTagValues('transaction.duration', ['<15m']);
  336. }
  337. // If there is a bare text search, we want to treat it as a search
  338. // on the transaction name.
  339. if (conditions.query.length > 0) {
  340. conditions.setTagValues('transaction', [`*${conditions.query.join(' ')}*`]);
  341. conditions.query = [];
  342. }
  343. savedQuery.query = conditions.formatString();
  344. const eventView = EventView.fromNewQueryWithLocation(savedQuery, location);
  345. eventView.additionalConditions.addTagValues('event.type', ['transaction']);
  346. return eventView;
  347. }
  348. function generateBackendPerformanceEventView(
  349. organization: LightWeightOrganization,
  350. location: Location
  351. ): EventView {
  352. const {query} = location;
  353. const fields = [
  354. organization.features.includes('team-key-transactions')
  355. ? 'team_key_transaction'
  356. : 'key_transaction',
  357. 'transaction',
  358. 'project',
  359. 'transaction.op',
  360. 'http.method',
  361. 'tpm()',
  362. 'p50()',
  363. 'p95()',
  364. 'failure_rate()',
  365. ];
  366. const featureFields = organization.features.includes('project-transaction-threshold')
  367. ? ['apdex()', 'count_unique(user)', 'count_miserable(user)', 'user_misery()']
  368. : [
  369. `apdex(${organization.apdexThreshold})`,
  370. 'count_unique(user)',
  371. `count_miserable(user,${organization.apdexThreshold})`,
  372. `user_misery(${organization.apdexThreshold})`,
  373. ];
  374. const hasStartAndEnd = query.start && query.end;
  375. const savedQuery: NewQuery = {
  376. id: undefined,
  377. name: t('Performance'),
  378. query: 'event.type:transaction',
  379. projects: [],
  380. fields: [...fields, ...featureFields],
  381. version: 2,
  382. };
  383. const widths = Array(savedQuery.fields.length).fill(COL_WIDTH_UNDEFINED);
  384. widths[savedQuery.fields.length - 1] = '110';
  385. savedQuery.widths = widths;
  386. if (!query.statsPeriod && !hasStartAndEnd) {
  387. savedQuery.range = DEFAULT_STATS_PERIOD;
  388. }
  389. savedQuery.orderby = decodeScalar(query.sort, '-tpm');
  390. const searchQuery = decodeScalar(query.query, '');
  391. const conditions = tokenizeSearch(searchQuery);
  392. // This is not an override condition since we want the duration to appear in the search bar as a default.
  393. if (!conditions.hasTag('transaction.duration')) {
  394. conditions.setTagValues('transaction.duration', ['<15m']);
  395. }
  396. // If there is a bare text search, we want to treat it as a search
  397. // on the transaction name.
  398. if (conditions.query.length > 0) {
  399. conditions.setTagValues('transaction', [`*${conditions.query.join(' ')}*`]);
  400. conditions.query = [];
  401. }
  402. savedQuery.query = conditions.formatString();
  403. const eventView = EventView.fromNewQueryWithLocation(savedQuery, location);
  404. eventView.additionalConditions.addTagValues('event.type', ['transaction']);
  405. return eventView;
  406. }
  407. function generateFrontendPageloadPerformanceEventView(
  408. organization: LightWeightOrganization,
  409. location: Location
  410. ): EventView {
  411. const {query} = location;
  412. const fields = [
  413. organization.features.includes('team-key-transactions')
  414. ? 'team_key_transaction'
  415. : 'key_transaction',
  416. 'transaction',
  417. 'project',
  418. 'tpm()',
  419. 'p75(measurements.fcp)',
  420. 'p75(measurements.lcp)',
  421. 'p75(measurements.fid)',
  422. 'p75(measurements.cls)',
  423. ];
  424. const featureFields = organization.features.includes('project-transaction-threshold')
  425. ? ['count_unique(user)', 'count_miserable(user)', 'user_misery()']
  426. : [
  427. 'count_unique(user)',
  428. `count_miserable(user,${organization.apdexThreshold})`,
  429. `user_misery(${organization.apdexThreshold})`,
  430. ];
  431. const hasStartAndEnd = query.start && query.end;
  432. const savedQuery: NewQuery = {
  433. id: undefined,
  434. name: t('Performance'),
  435. query: 'event.type:transaction',
  436. projects: [],
  437. fields: [...fields, ...featureFields],
  438. version: 2,
  439. };
  440. const widths = Array(savedQuery.fields.length).fill(COL_WIDTH_UNDEFINED);
  441. widths[savedQuery.fields.length - 1] = '110';
  442. savedQuery.widths = widths;
  443. if (!query.statsPeriod && !hasStartAndEnd) {
  444. savedQuery.range = DEFAULT_STATS_PERIOD;
  445. }
  446. savedQuery.orderby = decodeScalar(query.sort, '-tpm');
  447. const searchQuery = decodeScalar(query.query, '');
  448. const conditions = tokenizeSearch(searchQuery);
  449. // This is not an override condition since we want the duration to appear in the search bar as a default.
  450. if (!conditions.hasTag('transaction.duration')) {
  451. conditions.setTagValues('transaction.duration', ['<15m']);
  452. }
  453. // If there is a bare text search, we want to treat it as a search
  454. // on the transaction name.
  455. if (conditions.query.length > 0) {
  456. conditions.setTagValues('transaction', [`*${conditions.query.join(' ')}*`]);
  457. conditions.query = [];
  458. }
  459. savedQuery.query = conditions.formatString();
  460. const eventView = EventView.fromNewQueryWithLocation(savedQuery, location);
  461. eventView.additionalConditions
  462. .addTagValues('event.type', ['transaction'])
  463. .addTagValues('transaction.op', ['pageload']);
  464. return eventView;
  465. }
  466. function generateFrontendOtherPerformanceEventView(
  467. organization: LightWeightOrganization,
  468. location: Location
  469. ): EventView {
  470. const {query} = location;
  471. const fields = [
  472. organization.features.includes('team-key-transactions')
  473. ? 'team_key_transaction'
  474. : 'key_transaction',
  475. 'transaction',
  476. 'project',
  477. 'transaction.op',
  478. 'tpm()',
  479. 'p50(transaction.duration)',
  480. 'p75(transaction.duration)',
  481. 'p95(transaction.duration)',
  482. ];
  483. const featureFields = organization.features.includes('project-transaction-threshold')
  484. ? ['count_unique(user)', 'count_miserable(user)', 'user_misery()']
  485. : [
  486. 'count_unique(user)',
  487. `count_miserable(user,${organization.apdexThreshold})`,
  488. `user_misery(${organization.apdexThreshold})`,
  489. ];
  490. const hasStartAndEnd = query.start && query.end;
  491. const savedQuery: NewQuery = {
  492. id: undefined,
  493. name: t('Performance'),
  494. query: 'event.type:transaction',
  495. projects: [],
  496. fields: [...fields, ...featureFields],
  497. version: 2,
  498. };
  499. const widths = Array(savedQuery.fields.length).fill(COL_WIDTH_UNDEFINED);
  500. widths[savedQuery.fields.length - 1] = '110';
  501. savedQuery.widths = widths;
  502. if (!query.statsPeriod && !hasStartAndEnd) {
  503. savedQuery.range = DEFAULT_STATS_PERIOD;
  504. }
  505. savedQuery.orderby = decodeScalar(query.sort, '-tpm');
  506. const searchQuery = decodeScalar(query.query, '');
  507. const conditions = tokenizeSearch(searchQuery);
  508. // This is not an override condition since we want the duration to appear in the search bar as a default.
  509. if (!conditions.hasTag('transaction.duration')) {
  510. conditions.setTagValues('transaction.duration', ['<15m']);
  511. }
  512. // If there is a bare text search, we want to treat it as a search
  513. // on the transaction name.
  514. if (conditions.query.length > 0) {
  515. conditions.setTagValues('transaction', [`*${conditions.query.join(' ')}*`]);
  516. conditions.query = [];
  517. }
  518. savedQuery.query = conditions.formatString();
  519. const eventView = EventView.fromNewQueryWithLocation(savedQuery, location);
  520. eventView.additionalConditions
  521. .addTagValues('event.type', ['transaction'])
  522. .addTagValues('!transaction.op', ['pageload']);
  523. return eventView;
  524. }
  525. export function generatePerformanceEventView(
  526. organization,
  527. location,
  528. projects,
  529. isTrends = false
  530. ) {
  531. const eventView = generateGenericPerformanceEventView(organization, location);
  532. if (isTrends) {
  533. return eventView;
  534. }
  535. const display = getCurrentLandingDisplay(location, projects, eventView);
  536. switch (display?.field) {
  537. case LandingDisplayField.FRONTEND_PAGELOAD:
  538. return generateFrontendPageloadPerformanceEventView(organization, location);
  539. case LandingDisplayField.FRONTEND_OTHER:
  540. return generateFrontendOtherPerformanceEventView(organization, location);
  541. case LandingDisplayField.BACKEND:
  542. return generateBackendPerformanceEventView(organization, location);
  543. default:
  544. return eventView;
  545. }
  546. }
  547. export function generatePerformanceVitalDetailView(
  548. organization: LightWeightOrganization,
  549. location: Location
  550. ): EventView {
  551. const {query} = location;
  552. const vitalName = vitalNameFromLocation(location);
  553. const hasStartAndEnd = query.start && query.end;
  554. const savedQuery: NewQuery = {
  555. id: undefined,
  556. name: t('Vitals Performance Details'),
  557. query: 'event.type:transaction',
  558. projects: [],
  559. fields: [
  560. organization.features.includes('team-key-transactions')
  561. ? 'team_key_transaction'
  562. : 'key_transaction',
  563. 'transaction',
  564. 'project',
  565. 'count_unique(user)',
  566. 'count()',
  567. `p50(${vitalName})`,
  568. `p75(${vitalName})`,
  569. `p95(${vitalName})`,
  570. getVitalDetailTablePoorStatusFunction(vitalName),
  571. getVitalDetailTableMehStatusFunction(vitalName),
  572. ],
  573. version: 2,
  574. };
  575. if (!query.statsPeriod && !hasStartAndEnd) {
  576. savedQuery.range = DEFAULT_STATS_PERIOD;
  577. }
  578. savedQuery.orderby = decodeScalar(query.sort, '-count');
  579. const searchQuery = decodeScalar(query.query, '');
  580. const conditions = tokenizeSearch(searchQuery);
  581. // If there is a bare text search, we want to treat it as a search
  582. // on the transaction name.
  583. if (conditions.query.length > 0) {
  584. conditions.setTagValues('transaction', [`*${conditions.query.join(' ')}*`]);
  585. conditions.query = [];
  586. }
  587. savedQuery.query = conditions.formatString();
  588. const eventView = EventView.fromNewQueryWithLocation(savedQuery, location);
  589. eventView.additionalConditions
  590. .addTagValues('event.type', ['transaction'])
  591. .addTagValues('has', [vitalName]);
  592. return eventView;
  593. }