Skip to content

Commit 8779672

Browse files
authored
Merge branch 'main' into fix-stripe-ux
2 parents ff9662b + 11f75a3 commit 8779672

11 files changed

+1695
-51
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ UPLOAD_ACCESS_KEY_ID="captable"
4141
UPLOAD_SECRET_ACCESS_KEY="password"
4242
UPLOAD_BUCKET_PUBLIC="captable-public-bucket"
4343
UPLOAD_BUCKET_PRIVATE="captable-private-bucket"
44+
45+
# Sentry
46+
SENTRY_ORG=YOUR_SENTRY_ORG
47+
SENTRY_PROJECT=YOUR_SENTRY_PROJECT
48+
NEXT_PUBLIC_SENTRY_DSN=YOUR_SENTRY_DSN

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ yarn-error.log*
5454
/prisma/enums.ts
5555

5656
/.pnpm-store
57+
58+
# Sentry Config File
59+
.env.sentry-build-plugin

next.config.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import withBundleAnalyzer from "@next/bundle-analyzer";
2+
import { withSentryConfig } from "@sentry/nextjs";
23

34
const bundleAnalyzer = withBundleAnalyzer({
45
enabled: process.env.ANALYZE === "true",
@@ -11,7 +12,7 @@ const bundleAnalyzer = withBundleAnalyzer({
1112
await import("./src/env.js");
1213

1314
/** @type {import("next").NextConfig} */
14-
const config = {
15+
const nextConfig = {
1516
output: process.env.DOCKER_OUTPUT ? "standalone" : undefined,
1617
images: {
1718
remotePatterns: [
@@ -43,4 +44,18 @@ const config = {
4344
},
4445
};
4546

46-
export default bundleAnalyzer(config);
47+
const sentryOptions = {
48+
org: process.env.SENTRY_ORG,
49+
project: process.env.SENTRY_PROJECT,
50+
silent: true,
51+
widenClientFileUpload: true,
52+
hideSourceMaps: true,
53+
disableLogger: true,
54+
automaticVercelMonitors: true,
55+
};
56+
57+
const hasSentry = !!process.env.NEXT_PUBLIC_SENTRY_DSN;
58+
59+
export default hasSentry
60+
? withSentryConfig(bundleAnalyzer(nextConfig), sentryOptions)
61+
: bundleAnalyzer(nextConfig);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@radix-ui/react-toolbar": "^1.0.4",
5656
"@react-pdf/renderer": "^3.4.4",
5757
"@remixicon/react": "^4.0.1",
58+
"@sentry/nextjs": "^8",
5859
"@simplewebauthn/browser": "^10.0.0",
5960
"@simplewebauthn/server": "^10.0.0",
6061
"@sindresorhus/slugify": "^2.2.1",

pnpm-lock.yaml

Lines changed: 1606 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sentry.client.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as Sentry from "@sentry/nextjs";
2+
3+
Sentry.init({
4+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5+
tracesSampleRate: 1,
6+
debug: false,
7+
replaysOnErrorSampleRate: 1.0,
8+
replaysSessionSampleRate: 0.1,
9+
integrations: [
10+
Sentry.replayIntegration({
11+
maskAllText: true,
12+
blockAllMedia: true,
13+
}),
14+
],
15+
});

sentry.edge.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as Sentry from "@sentry/nextjs";
2+
3+
Sentry.init({
4+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5+
tracesSampleRate: 1,
6+
debug: false,
7+
});

sentry.server.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as Sentry from "@sentry/nextjs";
2+
3+
Sentry.init({
4+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
5+
tracesSampleRate: 1,
6+
debug: false,
7+
});

src/app/global-error.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
3+
import * as Sentry from "@sentry/nextjs";
4+
import NextError from "next/error";
5+
import { useEffect } from "react";
6+
7+
export default function GlobalError({
8+
error,
9+
}: {
10+
error: Error & { digest?: string };
11+
}) {
12+
useEffect(() => {
13+
Sentry.captureException(error);
14+
}, [error]);
15+
16+
return (
17+
<html lang="en">
18+
<body>
19+
<NextError statusCode={undefined as never} />
20+
</body>
21+
</html>
22+
);
23+
}

src/env.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export const env = createEnv({
5252
// stripe
5353
STRIPE_API_KEY: z.string().optional(),
5454
STRIPE_WEBHOOK_SECRET: z.string().optional(),
55+
56+
// sentry
57+
SENTRY_ORG: z.string().optional(),
58+
SENTRY_PROJECT: z.string().optional(),
5559
},
5660

5761
/**
@@ -63,6 +67,7 @@ export const env = createEnv({
6367
NEXT_PUBLIC_BASE_URL: z.string(),
6468
NEXT_PUBLIC_UPLOAD_DOMAIN: z.string().optional(),
6569
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().optional(),
70+
NEXT_PUBLIC_SENTRY_DSN: z.string().optional(),
6671
},
6772

6873
/**

src/instrumentation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@ export async function register() {
22
if (process.env.NEXT_RUNTIME === "nodejs") {
33
const { startJobs } = await import("@/jobs/start");
44
await startJobs();
5+
6+
await import("../sentry.server.config");
7+
}
8+
9+
if (process.env.NEXT_RUNTIME === "edge") {
10+
await import("../sentry.edge.config");
511
}
612
}

0 commit comments

Comments
 (0)