platforms.tsx 2.5 KB

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