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. meta?: Record<any, any>;
  10. showCompleteFunctionName?: boolean;
  11. };
  12. export function FunctionName({
  13. frame,
  14. showCompleteFunctionName,
  15. hasHiddenDetails,
  16. className,
  17. meta,
  18. ...props
  19. }: Props) {
  20. const getValueOutput = ():
  21. | {meta: ReturnType<typeof getMeta>; value: Frame['function']}
  22. | undefined => {
  23. if (hasHiddenDetails && showCompleteFunctionName && frame.rawFunction) {
  24. return {
  25. value: frame.rawFunction,
  26. meta: meta?.rawFunction?.[''],
  27. };
  28. }
  29. if (frame.function) {
  30. return {
  31. value: frame.function,
  32. meta: meta?.function?.[''],
  33. };
  34. }
  35. if (frame.rawFunction) {
  36. return {
  37. value: frame.rawFunction,
  38. meta: meta?.rawFunction?.[''],
  39. };
  40. }
  41. return undefined;
  42. };
  43. const valueOutput = getValueOutput();
  44. return (
  45. <code className={className} {...props}>
  46. {!valueOutput ? (
  47. t('<unknown>')
  48. ) : (
  49. <AnnotatedText value={valueOutput.value} meta={valueOutput.meta} />
  50. )}
  51. </code>
  52. );
  53. }