Browse Source

fix(profiling): add check for project.hasProfiles (#42337)

We noticed a customer project had no platform set, so the check was
failing and we were not showing them the profiling tab. This slightly
extends the check to check for presence of any profiles that may have
already been sent - in that case consider profiling to be supported.
Jonas 2 years ago
parent
commit
9dd21d3256

+ 7 - 2
static/app/components/profiling/ProfilingOnboarding/util.ts

@@ -35,8 +35,13 @@ const platformToDocsPlatform: Record<
   'python-tornado': 'python',
 };
 
-export function isProfilingSupportedForProject(project: Project): boolean {
-  return !!(project.platform && platformToDocsPlatform[project.platform]);
+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 = [

+ 2 - 2
static/app/views/performance/transactionSummary/header.tsx

@@ -9,6 +9,7 @@ import {CreateAlertFromViewButton} from 'sentry/components/createAlertButton';
 import FeatureBadge from 'sentry/components/featureBadge';
 import IdBadge from 'sentry/components/idBadge';
 import * as Layout from 'sentry/components/layouts/thirds';
+import {isProfilingSupportedOrProjectHasProfiles} from 'sentry/components/profiling/ProfilingOnboarding/util';
 import ReplayCountBadge from 'sentry/components/replays/replayCountBadge';
 import ReplaysFeatureBadge from 'sentry/components/replays/replaysFeatureBadge';
 import useReplaysCount from 'sentry/components/replays/useReplaysCount';
@@ -23,7 +24,6 @@ import HasMeasurementsQuery from 'sentry/utils/performance/vitals/hasMeasurement
 import projectSupportsReplay from 'sentry/utils/replays/projectSupportsReplay';
 import Breadcrumb from 'sentry/views/performance/breadcrumb';
 
-import {isProfilingSupportedForProject} from '../../../components/profiling/ProfilingOnboarding/util';
 import {getCurrentLandingDisplay, LandingDisplayField} from '../landing/utils';
 
 import Tab from './tabs';
@@ -76,7 +76,7 @@ function TransactionHeader({
   const hasProfiling =
     project &&
     organization.features.includes('profiling') &&
-    isProfilingSupportedForProject(project);
+    isProfilingSupportedOrProjectHasProfiles(project);
 
   const getWebVitals = useCallback(
     (hasMeasurements: boolean) => {