platforms.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. 'node',
  8. 'python',
  9. 'php',
  10. 'rust',
  11. ] as const;
  12. export type SupportedProfilingPlatform = (typeof supportedProfilingPlatforms)[number];
  13. export type SupportedProfilingPlatformSDK =
  14. (typeof supportedProfilingPlatformSDKs)[number];
  15. export function getDocsPlatformSDKForPlatform(
  16. platform: string | undefined
  17. ): SupportedProfilingPlatform | null {
  18. if (!platform) {
  19. return null;
  20. }
  21. if (platform === 'android') {
  22. return 'android';
  23. }
  24. if (platform === 'apple-ios') {
  25. return 'apple-ios';
  26. }
  27. if (platform.startsWith('node')) {
  28. return 'node';
  29. }
  30. if (platform.startsWith('python')) {
  31. return 'python';
  32. }
  33. if (platform === 'rust') {
  34. return 'rust';
  35. }
  36. return null;
  37. }
  38. export function isProfilingSupportedOrProjectHasProfiles(project: Project): boolean {
  39. return !!(
  40. (project.platform && getDocsPlatformSDKForPlatform(project.platform)) ||
  41. // If this project somehow managed to send profiles, then profiling is supported for this project.
  42. // Sometimes and for whatever reason, platform can also not be set on a project so the above check alone would fail
  43. project.hasProfiles
  44. );
  45. }
  46. export function getProfilingDocsForPlatform(platform: string | undefined): string | null {
  47. const docsPlatform = getDocsPlatformSDKForPlatform(platform);
  48. if (!docsPlatform) {
  49. return null;
  50. }
  51. return docsPlatform === 'apple-ios'
  52. ? 'https://docs.sentry.io/platforms/apple/guides/ios/profiling/'
  53. : `https://docs.sentry.io/platforms/${docsPlatform}/profiling/`;
  54. }