regressionMessage.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {DataSection} from 'sentry/components/events/styles';
  2. import Link from 'sentry/components/links/link';
  3. import {t, tct} from 'sentry/locale';
  4. import {Event} from 'sentry/types';
  5. import {formatPercentage} from 'sentry/utils/formatters';
  6. import useOrganization from 'sentry/utils/useOrganization';
  7. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  8. import {
  9. DisplayModes,
  10. transactionSummaryRouteWithQuery,
  11. } from 'sentry/views/performance/transactionSummary/utils';
  12. type EventStatisticalDetectorMessageProps = {
  13. event: Event;
  14. };
  15. function EventStatisticalDetectorMessage({event}: EventStatisticalDetectorMessageProps) {
  16. const organization = useOrganization();
  17. const transactionName = event?.occurrence?.evidenceData?.transaction;
  18. const transactionSummaryLink = transactionSummaryRouteWithQuery({
  19. orgSlug: organization.slug,
  20. transaction: transactionName,
  21. query: {},
  22. projectID: event.projectID,
  23. display: DisplayModes.TREND,
  24. });
  25. const detectionTime = new Date(event?.occurrence?.evidenceData?.breakpoint * 1000);
  26. // TODO: This messaging should respect selected locale in user settings
  27. return (
  28. <DataSection>
  29. <div style={{display: 'inline'}}>
  30. {tct(
  31. '[detected] Based on the transaction [transactionName], there was a [amount] increase in duration (P95) around [date] at [time] UTC. Overall operation percentage changes indicate what may have changed in the regression.',
  32. {
  33. detected: <strong>{t('Detected:')}</strong>,
  34. transactionName: (
  35. <Link to={normalizeUrl(transactionSummaryLink)}>{transactionName}</Link>
  36. ),
  37. amount: formatPercentage(
  38. event?.occurrence?.evidenceData?.trendPercentage - 1
  39. ),
  40. date: detectionTime.toLocaleDateString(undefined, {
  41. month: 'short',
  42. day: 'numeric',
  43. }),
  44. time: detectionTime.toLocaleTimeString(undefined, {
  45. hour12: true,
  46. hour: 'numeric',
  47. minute: 'numeric',
  48. }),
  49. }
  50. )}
  51. </div>
  52. </DataSection>
  53. );
  54. }
  55. export default EventStatisticalDetectorMessage;