|
@@ -6,13 +6,12 @@ import {ProfileHeader} from 'sentry/components/profiling/profileHeader';
|
|
|
import {t} from 'sentry/locale';
|
|
|
import type {EventTransaction, Organization, Project} from 'sentry/types';
|
|
|
import {RequestState} from 'sentry/types/core';
|
|
|
+import {isSchema} from 'sentry/utils/profiling/guards/profile';
|
|
|
import {useSentryEvent} from 'sentry/utils/profiling/hooks/useSentryEvent';
|
|
|
import useApi from 'sentry/utils/useApi';
|
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
import {useParams} from 'sentry/utils/useParams';
|
|
|
|
|
|
-import {isSchema} from '../../utils/profiling/guards/profile';
|
|
|
-
|
|
|
function fetchFlamegraphs(
|
|
|
api: Client,
|
|
|
eventId: string,
|
|
@@ -64,7 +63,7 @@ export function useSetProfiles() {
|
|
|
return context;
|
|
|
}
|
|
|
|
|
|
-const ProfileTransactionContext =
|
|
|
+export const ProfileTransactionContext =
|
|
|
createContext<RequestState<EventTransaction | null> | null>(null);
|
|
|
|
|
|
export function useProfileTransaction() {
|
|
@@ -77,7 +76,7 @@ export function useProfileTransaction() {
|
|
|
return context;
|
|
|
}
|
|
|
|
|
|
-function ProfileProviderWrapper(props: FlamegraphViewProps): React.ReactElement {
|
|
|
+function ProfilesAndTransactionProvider(props: FlamegraphViewProps): React.ReactElement {
|
|
|
const organization = useOrganization();
|
|
|
const params = useParams();
|
|
|
|
|
@@ -148,7 +147,13 @@ export function ProfilesProvider({
|
|
|
onUpdateProfiles?.({type: 'resolved', data: p});
|
|
|
})
|
|
|
.catch(err => {
|
|
|
- const message = err.toString() || t('Error: Unable to load profiles');
|
|
|
+ // XXX: our API client mock implementation does not mimick the real
|
|
|
+ // implementation, so we need to check for an empty object here. #sad
|
|
|
+ const isEmptyObject = err.toString() === '[object Object]';
|
|
|
+ const message = isEmptyObject
|
|
|
+ ? t('Error: Unable to load profiles')
|
|
|
+ : err.toString();
|
|
|
+
|
|
|
setProfiles({type: 'errored', error: message});
|
|
|
onUpdateProfiles?.({type: 'errored', error: message});
|
|
|
Sentry.captureException(err);
|
|
@@ -162,4 +167,4 @@ export function ProfilesProvider({
|
|
|
return <ProfileContext.Provider value={profiles}>{children}</ProfileContext.Provider>;
|
|
|
}
|
|
|
|
|
|
-export default ProfileProviderWrapper;
|
|
|
+export default ProfilesAndTransactionProvider;
|