sentryFunctions.tsx 781 B

1234567891011121314151617181920212223242526272829303132
  1. import type {Client} from 'sentry/api';
  2. import {t, tct} from 'sentry/locale';
  3. import type {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. return true;
  25. } catch (err) {
  26. clearIndicators();
  27. addErrorMessage(err?.responseJSON?.detail || t('Unknown Error'));
  28. return false;
  29. }
  30. }