utils.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type {Frame} from 'sentry/types';
  2. import {getFileExtension} from 'sentry/utils/fileExtension';
  3. const fileNameBlocklist = ['@webkit-masked-url'];
  4. export function isFrameFilenamePathlike(frame: Frame): boolean {
  5. let filename = frame.absPath ?? '';
  6. try {
  7. filename = new URL(filename).pathname.split('/').reverse()[0];
  8. } catch {
  9. // do nothing
  10. }
  11. return (
  12. // If all filenames are anonymous, we do not want to show this alert
  13. (frame.filename === '<anonymous>' && frame.inApp) ||
  14. // If all function names are on the blocklist, we do not want to show this alert
  15. fileNameBlocklist.includes(frame.function ?? '') ||
  16. // If all absolute paths do not have a file extension, we do not want to show this alert
  17. (!!frame.absPath && !getFileExtension(filename))
  18. );
  19. }
  20. // Maps the SDK name to the url token for docs
  21. export const sourceMapSdkDocsMap: Record<string, string> = {
  22. 'sentry.javascript.browser': 'javascript',
  23. 'sentry.javascript.node': 'node',
  24. 'sentry.javascript.react': 'react',
  25. 'sentry.javascript.angular': 'angular',
  26. 'sentry.javascript.angular-ivy': 'angular',
  27. 'sentry.javascript.ember': 'ember',
  28. 'sentry.javascript.gatsby': 'gatsby',
  29. 'sentry.javascript.vue': 'vue',
  30. 'sentry.javascript.nextjs': 'nextjs',
  31. 'sentry.javascript.remix': 'remix',
  32. 'sentry.javascript.svelte': 'svelte',
  33. 'sentry.javascript.sveltekit': 'sveltekit',
  34. 'sentry.javascript.react-native': 'react-native',
  35. 'sentry.javascript.atro': 'astro',
  36. };