platforms.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import {profiling} from 'sentry/data/platformCategories';
  2. import {Project} from 'sentry/types/project';
  3. export const supportedProfilingPlatforms = profiling;
  4. export const supportedProfilingPlatformSDKs = [
  5. 'android',
  6. 'apple-ios',
  7. 'go',
  8. 'node',
  9. 'python',
  10. 'php',
  11. 'php',
  12. 'php-laravel',
  13. 'php-symfony2',
  14. 'ruby',
  15. 'javascript-nextjs',
  16. 'javascript-remix',
  17. 'javascript-sveltekit',
  18. ] as const;
  19. export type SupportedProfilingPlatform = (typeof supportedProfilingPlatforms)[number];
  20. export type SupportedProfilingPlatformSDK =
  21. (typeof supportedProfilingPlatformSDKs)[number];
  22. export function getDocsPlatformSDKForPlatform(
  23. platform: string | undefined
  24. ): SupportedProfilingPlatform | null {
  25. if (!platform) {
  26. return null;
  27. }
  28. // Android
  29. if (platform === 'android') {
  30. return 'android';
  31. }
  32. // iOS
  33. if (platform === 'apple-ios') {
  34. return 'apple-ios';
  35. }
  36. // Go
  37. if (platform === 'go') {
  38. return 'go';
  39. }
  40. // Javascript
  41. if (platform.startsWith('node')) {
  42. return 'node';
  43. }
  44. if (platform === 'javascript-nextjs') {
  45. return 'javascript-nextjs';
  46. }
  47. if (platform === 'javascript-remix') {
  48. return 'javascript-remix';
  49. }
  50. if (platform === 'javascript-sveltekit') {
  51. return 'javascript-sveltekit';
  52. }
  53. // Python
  54. if (platform.startsWith('python')) {
  55. return 'python';
  56. }
  57. // PHP
  58. if (platform === 'php-laravel') {
  59. return 'php-laravel';
  60. }
  61. if (platform === 'php-symfony') {
  62. return 'php-symfony2';
  63. }
  64. if (platform.startsWith('php')) {
  65. return 'php';
  66. }
  67. // Ruby
  68. if (platform.startsWith('ruby')) {
  69. return 'ruby';
  70. }
  71. return null;
  72. }
  73. export function isProfilingSupportedOrProjectHasProfiles(project: Project): boolean {
  74. return !!(
  75. (project.platform && getDocsPlatformSDKForPlatform(project.platform)) ||
  76. // If this project somehow managed to send profiles, then profiling is supported for this project.
  77. // Sometimes and for whatever reason, platform can also not be set on a project so the above check alone would fail
  78. project.hasProfiles
  79. );
  80. }
  81. export function getProfilingDocsForPlatform(platform: string | undefined): string | null {
  82. const docsPlatform = getDocsPlatformSDKForPlatform(platform);
  83. if (!docsPlatform) {
  84. return null;
  85. }
  86. return docsPlatform === 'apple-ios'
  87. ? 'https://docs.sentry.io/platforms/apple/guides/ios/profiling/'
  88. : `https://docs.sentry.io/platforms/${docsPlatform}/profiling/`;
  89. }