platforms.tsx 1.9 KB

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