functionName.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import AnnotatedText from 'sentry/components/events/meta/annotatedText';
  2. import {getMeta} from 'sentry/components/events/meta/metaProxy';
  3. import {t} from 'sentry/locale';
  4. import {Frame} from 'sentry/types';
  5. type Props = {
  6. frame: Frame;
  7. className?: string;
  8. hasHiddenDetails?: boolean;
  9. showCompleteFunctionName?: boolean;
  10. };
  11. const FunctionName = ({
  12. frame,
  13. showCompleteFunctionName,
  14. hasHiddenDetails,
  15. className,
  16. ...props
  17. }: Props) => {
  18. const getValueOutput = ():
  19. | {meta: ReturnType<typeof getMeta>; value: Frame['function']}
  20. | undefined => {
  21. if (hasHiddenDetails && showCompleteFunctionName && frame.rawFunction) {
  22. return {
  23. value: frame.rawFunction,
  24. meta: getMeta(frame, 'rawFunction'),
  25. };
  26. }
  27. if (frame.function) {
  28. return {
  29. value: frame.function,
  30. meta: getMeta(frame, 'function'),
  31. };
  32. }
  33. if (frame.rawFunction) {
  34. return {
  35. value: frame.rawFunction,
  36. meta: getMeta(frame, 'rawFunction'),
  37. };
  38. }
  39. return undefined;
  40. };
  41. const valueOutput = getValueOutput();
  42. return (
  43. <code className={className} {...props}>
  44. {!valueOutput ? (
  45. t('<unknown>')
  46. ) : (
  47. <AnnotatedText value={valueOutput.value} meta={valueOutput.meta} />
  48. )}
  49. </code>
  50. );
  51. };
  52. export default FunctionName;