import React, { useCallback } from 'react';
import { SentryUtils } from '@assets/js-shop/sentry/utils/SentryUtils';
import * as Sentry from '@sentry/react';
import { Scope } from '@sentry/react';

export function SentryErrorBoundary(props: { children: any, runtime?: string  }) {
   const sentryBeforeCapture = useCallback((scope: Scope) => {
      SentryUtils.setRuntimeTag(scope, {runtime: props.runtime});
   }, []);

   return (
      <Sentry.ErrorBoundary beforeCapture={sentryBeforeCapture}>
         {props.children}
      </Sentry.ErrorBoundary>
   );
}
