mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
feat: support sentry report (#1729)
This commit is contained in:
@@ -16,3 +16,7 @@ ENABLE_BC_PROVIDER=1
|
||||
EXPOSE_INTERNAL=1
|
||||
ENABLE_DEBUG_PAGE=
|
||||
ENABLE_SUBPAGE=
|
||||
|
||||
# Sentry
|
||||
SENTRY_AUTH_TOKEN=
|
||||
NEXT_PUBLIC_SENTRY_DSN=
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
|
||||
import { PerfseePlugin } from '@perfsee/webpack';
|
||||
import { withSentryConfig } from '@sentry/nextjs';
|
||||
import debugLocal from 'next-debug-local';
|
||||
|
||||
import preset from './preset.config.mjs';
|
||||
@@ -45,6 +46,9 @@ const getRedirectConfig = profile => {
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
sentry: {
|
||||
hideSourceMaps: true,
|
||||
},
|
||||
productionBrowserSourceMaps: true,
|
||||
compiler: {
|
||||
styledComponents: true,
|
||||
@@ -158,4 +162,14 @@ const detectFirebaseConfig = () => {
|
||||
};
|
||||
detectFirebaseConfig();
|
||||
|
||||
export default withDebugLocal(nextConfig);
|
||||
let config = withDebugLocal(nextConfig);
|
||||
|
||||
if (process.env.SENTRY_AUTH_TOKEN) {
|
||||
config = withSentryConfig(config, {
|
||||
silent: true,
|
||||
});
|
||||
} else {
|
||||
console.log('Sentry not enabled, please set SENTRY_AUTH_TOKEN to enable it');
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"@emotion/server": "^11.10.0",
|
||||
"@emotion/styled": "^11.10.6",
|
||||
"@mui/material": "^5.11.13",
|
||||
"@sentry/nextjs": "^7.45.0",
|
||||
"cmdk": "^0.2.0",
|
||||
"css-spring": "^4.1.0",
|
||||
"dayjs": "^1.11.7",
|
||||
|
||||
8
apps/web/sentry.client.config.ts
Normal file
8
apps/web/sentry.client.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
|
||||
|
||||
Sentry.init({
|
||||
dsn: SENTRY_DSN,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
8
apps/web/sentry.edge.config.ts
Normal file
8
apps/web/sentry.edge.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
|
||||
|
||||
Sentry.init({
|
||||
dsn: SENTRY_DSN,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
4
apps/web/sentry.properties
Normal file
4
apps/web/sentry.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
defaults.url=https://sentry.io/
|
||||
defaults.org=
|
||||
defaults.project=
|
||||
cli.executable=../../node_modules/@sentry/cli/bin/sentry-cli
|
||||
8
apps/web/sentry.server.config.ts
Normal file
8
apps/web/sentry.server.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN;
|
||||
|
||||
Sentry.init({
|
||||
dsn: SENTRY_DSN,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
15
apps/web/src/pages/_error.tsx
Normal file
15
apps/web/src/pages/_error.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
import type { NextPageContext } from 'next';
|
||||
import type { ErrorProps } from 'next/error';
|
||||
import NextErrorComponent from 'next/error';
|
||||
|
||||
const CustomErrorComponent = (props: ErrorProps) => {
|
||||
return <NextErrorComponent statusCode={props.statusCode} />;
|
||||
};
|
||||
|
||||
CustomErrorComponent.getInitialProps = async (contextData: NextPageContext) => {
|
||||
await Sentry.captureUnderscoreErrorException(contextData);
|
||||
return NextErrorComponent.getInitialProps(contextData);
|
||||
};
|
||||
|
||||
export default CustomErrorComponent;
|
||||
Reference in New Issue
Block a user