Skip to content

Commit

Permalink
feat(site): sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
uonr committed Dec 21, 2024
1 parent e661190 commit bdc8893
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 91 deletions.
18 changes: 17 additions & 1 deletion apps/site/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const withBundleAnalyzer = require('@next/bundle-analyzer')();
const { withSentryConfig } = require('@sentry/nextjs');
const BACKEND_URL = process.env.BACKEND_URL;
const STANDALONE = process.env.STANDALONE === 'true';
if (!BACKEND_URL) {
Expand Down Expand Up @@ -27,6 +28,7 @@ const config = {
BACKEND_URL: process.env.BACKEND_URL,
APP_URL: process.env.APP_URL,
DOMAIN: process.env.DOMAIN,
SENTRY_DSN: process.env.SENTRY_DSN,
},
transpilePackages: ['@boluo/ui', '@boluo/common'],
experimental: {
Expand All @@ -43,4 +45,18 @@ const config = {
},
};

module.exports = process.env.ANALYZE === 'true' ? withBundleAnalyzer(config) : config;
if (process.env.SENTRY_DSN) {
module.exports = withSentryConfig(config, {
org: 'mythal' ?? process.env.SENTRY_ORG,
sentryUrl: process.env.SENTRY_URL ?? 'https://sentry.io/',
project: 'boluo-site' ?? process.env.SENTRY_PROJECT_SITE,
disableLogger: true,
authToken: process.env.SENTRY_TOKEN,
widenClientFileUpload: true,
silent: true,
});
} else if (process.env.ANALYZE === 'true') {
module.exports = withBundleAnalyzer(config);
} else {
module.exports = config;
}
1 change: 1 addition & 0 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@boluo/utils": "*",
"@formatjs/intl": "^3.0.4",
"@next/mdx": "^14.1.1",
"@sentry/nextjs": "^8.47.0",
"clsx": "^2.1.0",
"jotai": "^2.7.0",
"negotiator": "^1.0.0",
Expand Down
12 changes: 12 additions & 0 deletions apps/site/sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: process.env.SENTRY_DSN,

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
});
12 changes: 12 additions & 0 deletions apps/site/sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: process.env.SENTRY_DSN,

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// We recommend adjusting this value in production
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
});
4 changes: 2 additions & 2 deletions apps/site/src/app/[lang]/echo/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata } from 'next';
import { type Metadata } from 'next';
import { cookies, headers } from 'next/headers';
import { getIntl, LangParams } from '@boluo/common/server';
import { getIntl, type LangParams } from '@boluo/common/server';

export function generateMetadata({ params }: { params: LangParams }): Metadata {
const intl = getIntl(params);
Expand Down
2 changes: 1 addition & 1 deletion apps/spa/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (process.env.SENTRY_DSN) {
module.exports = withSentryConfig(config, {
org: 'mythal' ?? process.env.SENTRY_ORG,
sentryUrl: process.env.SENTRY_URL ?? 'https://sentry.io/',
project: 'boluo-app' ?? process.env.SENTRY_PROJECT,
project: 'boluo-spa' ?? process.env.SENTRY_PROJECT,
autoInstrumentServerFunctions: false,
autoInstrumentMiddleware: false,
disableLogger: true,
Expand Down
Loading

0 comments on commit bdc8893

Please sign in to comment.