feat(frontend): @sentry/nextjs init для GlitchTip (#204 frontend) #208
9 changed files with 3183 additions and 418 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -13,6 +13,10 @@ node_modules/
|
|||
.next/
|
||||
frontend/.next/
|
||||
out/
|
||||
|
||||
# Sentry CLI config (auto-generated, contains auth tokens)
|
||||
.sentryclirc
|
||||
frontend/.sentryclirc
|
||||
# TypeScript incremental build info — must NOT be committed; locally-generated
|
||||
# and changes on every build, which busts Docker build context cache.
|
||||
*.tsbuildinfo
|
||||
|
|
|
|||
|
|
@ -1,2 +1,9 @@
|
|||
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000
|
||||
NEXT_PUBLIC_MAPBOX_TOKEN=
|
||||
|
||||
# GlitchTip error tracking (errors.gendsgn.ru)
|
||||
NEXT_PUBLIC_GLITCHTIP_DSN=
|
||||
GLITCHTIP_AUTH_TOKEN=
|
||||
SENTRY_ORG=gendesign
|
||||
SENTRY_PROJECT=frontend
|
||||
SENTRY_URL=https://errors.gendsgn.ru/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { NextConfig } from "next";
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
reactStrictMode: true,
|
||||
|
|
@ -47,4 +48,29 @@ const nextConfig: NextConfig = {
|
|||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
export default withSentryConfig(nextConfig, {
|
||||
org: process.env.SENTRY_ORG ?? "gendesign",
|
||||
project: process.env.SENTRY_PROJECT ?? "frontend",
|
||||
sentryUrl: process.env.SENTRY_URL ?? "https://errors.gendsgn.ru/",
|
||||
// Only upload source maps when auth token is present (CI builds).
|
||||
// Without authToken the upload step is silently skipped.
|
||||
authToken: process.env.GLITCHTIP_AUTH_TOKEN,
|
||||
silent: !process.env.CI,
|
||||
widenClientFileUpload: true,
|
||||
// Delete generated source maps from the build output after upload to
|
||||
// prevent them from being served publicly.
|
||||
sourcemaps: {
|
||||
deleteSourcemapsAfterUpload: true,
|
||||
},
|
||||
// No tunnel route — GlitchTip is not behind a CORS proxy
|
||||
tunnelRoute: undefined,
|
||||
// Webpack-specific options
|
||||
webpack: {
|
||||
// Treeshake Sentry SDK logger statements from the bundle
|
||||
treeshake: {
|
||||
removeDebugLogging: true,
|
||||
},
|
||||
// Not deploying on Vercel — no cron monitors needed
|
||||
automaticVercelMonitors: false,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
3520
frontend/package-lock.json
generated
3520
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,7 @@
|
|||
"codegen": "openapi-typescript http://localhost:8000/openapi.json -o src/lib/api-types.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sentry/nextjs": "^10.53.1",
|
||||
"@tanstack/react-query": "^5.50.0",
|
||||
"echarts": "^6.0.0",
|
||||
"echarts-for-react": "^3.0.6",
|
||||
|
|
|
|||
14
frontend/sentry.client.config.ts
Normal file
14
frontend/sentry.client.config.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const dsn = process.env.NEXT_PUBLIC_GLITCHTIP_DSN;
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
environment: process.env.NEXT_PUBLIC_ENVIRONMENT ?? "development",
|
||||
tracesSampleRate: 0.05,
|
||||
// GlitchTip does not support Session Replay — disable explicitly
|
||||
replaysSessionSampleRate: 0,
|
||||
replaysOnErrorSampleRate: 0,
|
||||
integrations: [],
|
||||
});
|
||||
}
|
||||
6
frontend/sentry.edge.config.ts
Normal file
6
frontend/sentry.edge.config.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const dsn = process.env.GLITCHTIP_DSN ?? process.env.NEXT_PUBLIC_GLITCHTIP_DSN;
|
||||
if (dsn) {
|
||||
Sentry.init({ dsn, tracesSampleRate: 0.05 });
|
||||
}
|
||||
10
frontend/sentry.server.config.ts
Normal file
10
frontend/sentry.server.config.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import * as Sentry from "@sentry/nextjs";
|
||||
|
||||
const dsn = process.env.GLITCHTIP_DSN ?? process.env.NEXT_PUBLIC_GLITCHTIP_DSN;
|
||||
if (dsn) {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
environment: process.env.NODE_ENV ?? "development",
|
||||
tracesSampleRate: 0.05,
|
||||
});
|
||||
}
|
||||
11
frontend/src/instrumentation.ts
Normal file
11
frontend/src/instrumentation.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
await import("../sentry.server.config");
|
||||
}
|
||||
if (process.env.NEXT_RUNTIME === "edge") {
|
||||
await import("../sentry.edge.config");
|
||||
}
|
||||
}
|
||||
|
||||
export const onRequestError = (await import("@sentry/nextjs"))
|
||||
.captureRequestError;
|
||||
Loading…
Add table
Reference in a new issue