How to use the @commercetools-frontend/sentry.reportErrorToSentry function in @commercetools-frontend/sentry

To help you get started, we’ve selected a few @commercetools-frontend/sentry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / merchant-center-application-kit / packages / permissions / src / hooks / use-is-authorized / use-is-authorized.ts View on Github external
applicationContext => applicationContext.permissions
  );
  const actualActionRights = useApplicationContext(
    applicationContext => applicationContext.actionRights
  );
  const actualDataFences = useApplicationContext(
    applicationContext => applicationContext.dataFences
  );

  // if the user has no permissions and no dataFences assigned to them, they are not authorized
  if (!actualPermissions && !actualDataFences) return false;

  let hasDemandeDataFences = false;
  if (demandedDataFences && demandedDataFences.length > 0) {
    if (!selectDataFenceData) {
      reportErrorToSentry(
        new Error(
          `@commercetools-frontend/permissions/Authorized: Missing data fences selector "selectDataFenceData".`
        )
      );
    }
    hasDemandeDataFences = hasAppliedDataFence({
      demandedDataFences,
      actualDataFences,
      selectDataFenceData,
    });
  }

  const hasDemandedPermissions = shouldMatchSomePermissions
    ? hasSomePermissions(demandedPermissions, actualPermissions)
    : hasEveryPermissions(demandedPermissions, actualPermissions);
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / requests-in-flight-loader / reducer.js View on Github external
export default (requestsInFlight, action) => {
  if (!requestsInFlight) return [];

  if (action && action.type === 'SHOW_LOADING')
    return [...requestsInFlight, action.payload];

  if (action && action.type === 'HIDE_LOADING') {
    // may only remove first occurence
    if (!requestsInFlight.includes(action.payload)) {
      reportErrorToSentry(
        new Error(
          `Tried to hide "${action.payload}", but it was not progressing!`
        )
      );
      return requestsInFlight;
    }
    return excludeFirstOccurrence(requestsInFlight, action.payload);
  }

  return requestsInFlight;
};
github commercetools / merchant-center-application-kit / packages / react-notifications / src / components / notification-kinds / api-error-message / api-error-message.js View on Github external
React.useEffect(() => {
    if (!message) {
      // This error is not mapped / translated yet,
      // we log, report it to sentry and show the original error, unless `error.code` is `invalid_scope`
      // which an error code emitted for expired project(s)
      if (
        props.error.code !== 'invalid_scope' &&
        !props.error.message.includes('has expired')
      ) {
        reportErrorToSentry(new Error('Unmapped error'), {
          extra: props.error,
        });
      }
    }
  }, [message]);
  if (!message) {
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / project-container / project-container.js View on Github external
componentDidCatch(error, errorInfo) {
    this.setState({ hasError: true });
    // Note: In development mode componentDidCatch is not based on try-catch
    // to catch exceptions. Thus exceptions caught here will also be caught in
    // the global `error` event listener (setup-global-error-listener.js).
    // see: https://github.com/facebook/react/issues/10474
    reportErrorToSentry(error, { extra: errorInfo });
  }
  // Makes it easier to test
github commercetools / merchant-center-application-kit / packages / permissions / src / utils / has-permissions.ts View on Github external
const hasDemandedPermission = hasPermission(options.demandedDataFence.name, {
    [options.actualDataFence.name]: true,
  });

  if (!hasDemandedPermission) return false;

  const selectedDataFenceData = options.selectDataFenceData({
    type: options.demandedDataFence.type,
    group: options.demandedDataFence.group,
    name: options.demandedDataFence.name,
    actualDataFenceValues: options.actualDataFence.dataFenceValue.values,
  });

  if (!selectedDataFenceData) {
    reportErrorToSentry(
      new Error(`missing mapper for type "${options.demandedDataFence.type}"`),
      { extra: options.demandedDataFence.type }
    );
    return false;
  }

  // it is enough to only have a subset of demanded dataFence data belonging to actual dataFence values
  return selectedDataFenceData.some(value =>
    options.actualDataFence.dataFenceValue.values.includes(value)
  );
};
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / async-chunk-loader / async-chunk-loader.js View on Github external
componentDidUpdate(prevProps) {
    if (prevProps.error !== this.props.error)
      reportErrorToSentry(this.props.error, {});
  }
  render() {
github commercetools / merchant-center-application-kit / packages / i18n / src / async-locale-data / async-locale-data.tsx View on Github external
loadLocaleData = async (locale: string) => {
    try {
      if (!this.isUnmounting) {
        const messages = await loadI18n(locale);
        const applicationMessages = await loadApplicationMessages(
          this.props.applicationMessages,
          locale
        );
        this.setState({
          isLoading: false,
          locale,
          messages: mergeMessages(messages, applicationMessages),
        });
      }
    } catch (error) {
      reportErrorToSentry(error, {});
    }
  };
github commercetools / merchant-center-application-kit / packages / application-shell / src / components / async-chunk-loader / async-chunk-loader.js View on Github external
componentDidMount() {
    if (this.props.error) reportErrorToSentry(this.props.error, {});
  }
  componentDidUpdate(prevProps) {
github commercetools / merchant-center-application-kit / packages / l10n / src / create-l10n-injector / create-l10n-injector.tsx View on Github external
async function run() {
        try {
          const data = await loadLocale(locale);
          !cleaning && dispatch({ type: 'ok', data });
        } catch (error) {
          reportErrorToSentry(error);
          !cleaning && dispatch({ type: 'error', error });
        }
      }
      run();

@commercetools-frontend/sentry

Components to set up Sentry for a MC application

MIT
Latest version published 3 days ago

Package Health Score

87 / 100
Full package analysis