123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import partition from 'lodash/partition';
- import {PlatformKey, profiling} from 'sentry/data/platformCategories';
- import {Project} from 'sentry/types/project';
- export const supportedProfilingPlatforms = [
- 'android',
- 'apple-ios',
- 'node',
- 'python',
- ] as const;
- export type SupportedProfilingPlatform = Extract<
- typeof profiling[number],
- typeof supportedProfilingPlatforms[number]
- >;
- const platformToDocsPlatform: Record<
- typeof profiling[number],
- typeof supportedProfilingPlatforms[number]
- > = {
- android: 'android',
- 'apple-ios': 'apple-ios',
- node: 'node',
- 'node-express': 'node',
- 'node-koa': 'node',
- 'node-connect': 'node',
- python: 'python',
- 'python-django': 'python',
- 'python-flask': 'python',
- 'python-sanic': 'python',
- 'python-bottle': 'python',
- 'python-pylons': 'python',
- 'python-pyramid': 'python',
- 'python-tornado': 'python',
- };
- export function isProfilingSupportedOrProjectHasProfiles(project: Project): boolean {
- return !!(
- (project.platform && platformToDocsPlatform[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 const profilingOnboardingDocKeys = [
- '0-alert',
- '1-install',
- '2-configure-performance',
- '3-configure-profiling',
- '4-upload',
- ] as const;
- type ProfilingOnboardingDocKeys = typeof profilingOnboardingDocKeys[number];
- export const supportedPlatformExpectedDocKeys: Record<
- SupportedProfilingPlatform,
- ProfilingOnboardingDocKeys[]
- > = {
- android: ['1-install', '2-configure-performance', '3-configure-profiling', '4-upload'],
- 'apple-ios': [
- '1-install',
- '2-configure-performance',
- '3-configure-profiling',
- '4-upload',
- ],
- node: ['0-alert', '1-install', '2-configure-performance', '3-configure-profiling'],
- python: ['0-alert', '1-install', '2-configure-performance', '3-configure-profiling'],
- };
- function makeDocKey(platformId: PlatformKey, key: string) {
- return `${platformId}-profiling-onboarding-${key}`;
- }
- type DocKeyMap = Record<typeof profilingOnboardingDocKeys[number], string>;
- export function makeDocKeyMap(platformId: PlatformKey | undefined) {
- if (!platformId || !platformToDocsPlatform[platformId]) {
- return null;
- }
- const docsPlatform = platformToDocsPlatform[platformId];
- const expectedDocKeys: ProfilingOnboardingDocKeys[] =
- supportedPlatformExpectedDocKeys[docsPlatform];
- return expectedDocKeys.reduce((acc: DocKeyMap, key) => {
- acc[key] = makeDocKey(docsPlatform, key);
- return acc;
- }, {} as DocKeyMap);
- }
- export function splitProjectsByProfilingSupport(projects: Project[]): {
- supported: Project[];
- unsupported: Project[];
- } {
- const [supported, unsupported] = partition(
- projects,
- project => project.platform && platformToDocsPlatform[project.platform]
- );
- return {supported, unsupported};
- }
|