ente/apps/photos/sentry.client.config.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-06-07 10:45:46 +00:00
import * as Sentry from '@sentry/nextjs';
2022-01-20 06:43:10 +00:00
import { getSentryTunnelURL } from 'utils/common/apiUtil';
2022-07-27 06:14:13 +00:00
import { getSentryUserID } from 'utils/user';
import { runningInBrowser } from 'utils/common';
import { getHasOptedOutOfCrashReports } from 'utils/storage/index';
2022-01-07 11:58:05 +00:00
import {
getSentryDSN,
getSentryENV,
getSentryRelease,
getIsSentryEnabled,
} from 'constants/sentry';
2021-07-17 10:21:05 +00:00
const HAS_OPTED_OUT_OF_CRASH_REPORTING =
runningInBrowser() && getHasOptedOutOfCrashReports();
2021-07-17 10:21:05 +00:00
if (!HAS_OPTED_OUT_OF_CRASH_REPORTING) {
const SENTRY_DSN = getSentryDSN();
const SENTRY_ENV = getSentryENV();
const SENTRY_RELEASE = getSentryRelease();
const IS_ENABLED = getIsSentryEnabled();
2022-11-17 09:08:22 +00:00
Sentry.init({
dsn: SENTRY_DSN,
enabled: IS_ENABLED,
environment: SENTRY_ENV,
release: SENTRY_RELEASE,
attachStacktrace: true,
autoSessionTracking: false,
tunnel: getSentryTunnelURL(),
beforeSend(event) {
event.request = event.request || {};
const currentURL = new URL(document.location.href);
currentURL.hash = '';
event.request.url = currentURL;
return event;
},
integrations: function (i) {
return i.filter(function (i) {
return i.name !== 'Breadcrumbs';
});
},
// ...
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
});
2022-11-17 09:14:10 +00:00
const main = async () => {
Sentry.setUser({ id: await getSentryUserID() });
};
main();
}