sentry.client.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import * as Sentry from '@sentry/nextjs';
  2. import { getSentryTunnelURL } from 'utils/common/apiUtil';
  3. import { getSentryUserID } from 'utils/user';
  4. import {
  5. getSentryDSN,
  6. getSentryENV,
  7. getSentryRelease,
  8. getIsSentryEnabled,
  9. } from 'constants/sentry';
  10. const SENTRY_DSN = getSentryDSN();
  11. const SENTRY_ENV = getSentryENV();
  12. const SENTRY_RELEASE = getSentryRelease();
  13. const IS_ENABLED = getIsSentryEnabled();
  14. Sentry.init({
  15. dsn: SENTRY_DSN,
  16. enabled: IS_ENABLED,
  17. environment: SENTRY_ENV,
  18. release: SENTRY_RELEASE,
  19. attachStacktrace: true,
  20. autoSessionTracking: false,
  21. tunnel: getSentryTunnelURL(),
  22. beforeSend(event) {
  23. event.request = event.request || {};
  24. const currentURL = new URL(document.location.href);
  25. currentURL.hash = '';
  26. event.request.url = currentURL;
  27. return event;
  28. },
  29. integrations: function (i) {
  30. return i.filter(function (i) {
  31. return i.name !== 'Breadcrumbs';
  32. });
  33. },
  34. // ...
  35. // Note: if you want to override the automatic release value, do not set a
  36. // `release` value here - use the environment variable `SENTRY_RELEASE`, so
  37. // that it will also get attached to your source maps
  38. });
  39. const main = async () => {
  40. Sentry.setUser({ id: await getSentryUserID() });
  41. };
  42. main();