sentryFunctions.tsx 841 B

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