feat(frontend): @sentry/nextjs init для GlitchTip (#204 frontend) (#208)
All checks were successful
Deploy / changes (push) Successful in 4s
Deploy / build-backend (push) Has been skipped
Deploy / build-worker (push) Has been skipped
Deploy / build-frontend (push) Successful in 4m17s
Deploy / deploy (push) Successful in 31s

This commit is contained in:
lekss361 2026-05-16 15:09:38 +00:00
parent b61f025673
commit 277499684b
9 changed files with 3183 additions and 418 deletions

4
.gitignore vendored
View file

@ -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

View file

@ -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/

View file

@ -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,
},
});

File diff suppressed because it is too large Load diff

View file

@ -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",

View 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: [],
});
}

View 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 });
}

View 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,
});
}

View 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;