utils.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import * as Sentry from '@sentry/react';
  2. import {t} from 'sentry/locale';
  3. import {BuiltinSymbolSource} from 'sentry/types/debugFiles';
  4. import {
  5. CandidateDownloadStatus,
  6. ImageCandidate,
  7. ImageFeature,
  8. } from 'sentry/types/debugImage';
  9. import {INTERNAL_SOURCE} from '../utils';
  10. export function getImageFeatureDescription(type: ImageFeature) {
  11. switch (type) {
  12. case ImageFeature.has_debug_info:
  13. return {
  14. label: t('debug'),
  15. description: t(
  16. 'Debug information provides function names and resolves inlined frames during symbolication'
  17. ),
  18. };
  19. case ImageFeature.has_sources:
  20. return {
  21. label: t('sources'),
  22. description: t(
  23. 'Source code information allows Sentry to display source code context for stack frames'
  24. ),
  25. };
  26. case ImageFeature.has_symbols:
  27. return {
  28. label: t('symtab'),
  29. description: t(
  30. 'Symbol tables are used as a fallback when full debug information is not available'
  31. ),
  32. };
  33. case ImageFeature.has_unwind_info:
  34. return {
  35. label: t('unwind'),
  36. description: t(
  37. 'Stack unwinding information improves the quality of stack traces extracted from minidumps'
  38. ),
  39. };
  40. default: {
  41. Sentry.withScope(scope => {
  42. scope.setLevel('warning');
  43. Sentry.captureException(new Error('Unknown image candidate feature'));
  44. });
  45. return {}; // this shall not happen
  46. }
  47. }
  48. }
  49. export function getSourceTooltipDescription(
  50. source: string,
  51. builtinSymbolSources: Array<BuiltinSymbolSource> | null
  52. ) {
  53. if (source === INTERNAL_SOURCE) {
  54. return t(
  55. "This debug information file is from Sentry's internal symbol server for this project"
  56. );
  57. }
  58. if (
  59. builtinSymbolSources?.find(builtinSymbolSource => builtinSymbolSource.id === source)
  60. ) {
  61. return t('This debug information file is from a built-in symbol server');
  62. }
  63. return t('This debug information file is from a custom symbol server');
  64. }
  65. export function getStatusTooltipDescription(
  66. candidate: ImageCandidate,
  67. hasReprocessWarning: boolean
  68. ) {
  69. const {download, location, source} = candidate;
  70. switch (download.status) {
  71. case CandidateDownloadStatus.OK: {
  72. return {
  73. label: t('Download Details'),
  74. description: location,
  75. disabled: !location || source === INTERNAL_SOURCE,
  76. };
  77. }
  78. case CandidateDownloadStatus.ERROR:
  79. case CandidateDownloadStatus.MALFORMED: {
  80. const {details} = download;
  81. return {
  82. label: t('Download Details'),
  83. description: details,
  84. disabled: !details,
  85. };
  86. }
  87. case CandidateDownloadStatus.NOT_FOUND: {
  88. return {};
  89. }
  90. case CandidateDownloadStatus.NO_PERMISSION: {
  91. const {details} = download;
  92. return {
  93. label: t('Permission Error'),
  94. description: details,
  95. disabled: !details,
  96. };
  97. }
  98. case CandidateDownloadStatus.DELETED: {
  99. return {
  100. label: t('This file was deleted after the issue was processed.'),
  101. };
  102. }
  103. case CandidateDownloadStatus.UNAPPLIED: {
  104. return {
  105. label: hasReprocessWarning
  106. ? t(
  107. 'This issue was processed before this debug information file was available. To apply new debug information, reprocess this issue.'
  108. )
  109. : t(
  110. 'This issue was processed before this debug information file was available'
  111. ),
  112. };
  113. }
  114. default: {
  115. Sentry.withScope(scope => {
  116. scope.setLevel('warning');
  117. Sentry.captureException(new Error('Unknown image candidate download status'));
  118. });
  119. return {}; // This shall not happen
  120. }
  121. }
  122. }