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