sentryFunctions.tsx 736 B

123456789101112131415161718192021222324252627282930
  1. import {Client} from 'sentry/api';
  2. import {t, tct} from 'sentry/locale';
  3. import {Organization, SentryFunction} from 'sentry/types';
  4. import {
  5. addErrorMessage,
  6. addLoadingMessage,
  7. addSuccessMessage,
  8. clearIndicators,
  9. } from './indicator';
  10. export async function removeSentryFunction(
  11. client: Client,
  12. org: Organization,
  13. sentryFn: SentryFunction
  14. ) {
  15. addLoadingMessage();
  16. try {
  17. await client.requestPromise(
  18. `/organizations/${org.slug}/functions/${sentryFn.slug}/`,
  19. {
  20. method: 'DELETE',
  21. }
  22. );
  23. addSuccessMessage(tct('[name] successfully deleted.', {name: sentryFn.name}));
  24. } catch (err) {
  25. clearIndicators();
  26. addErrorMessage(err?.responseJSON?.detail || t('Unknown Error'));
  27. }
  28. }