Skip to content

Commit ca7e343

Browse files
update to next 16 stable and add sentry
1 parent 9aa070e commit ca7e343

13 files changed

Lines changed: 1761 additions & 199 deletions

apps/login/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
custom-config.js
22
.env*.local
33
standalone
4+
5+
# Sentry Config File
6+
.env.sentry-build-plugin

apps/login/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { withSentryConfig } from "@sentry/nextjs";
2+
import type { NextConfig } from "next";
13
import createNextIntlPlugin from "next-intl/plugin";
24
import { DEFAULT_CSP } from "./constants/csp.js";
35

@@ -49,41 +51,36 @@ const secureHeaders = (() => {
4951

5052
const imageRemotePatterns = [
5153
{
52-
protocol: "http",
54+
protocol: "http" as const,
5355
hostname: "localhost",
5456
port: "8080",
5557
pathname: "/**",
5658
},
5759
{
58-
protocol: "https",
60+
protocol: "https" as const,
5961
hostname: "*.zitadel.*",
6062
port: "",
6163
pathname: "/**",
6264
},
63-
];
65+
] satisfies NonNullable<NextConfig["images"]>["remotePatterns"];
6466

6567
if (process.env.ZITADEL_API_URL) {
6668
imageRemotePatterns.push({
67-
protocol: "https",
69+
protocol: "https" as const,
6870
hostname: process.env.ZITADEL_API_URL?.replace("https://", "") || "",
6971
port: "",
7072
pathname: "/**",
7173
});
7274
}
7375

74-
const nextConfig = {
76+
const nextConfig: NextConfig = {
7577
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
76-
output: process.env.NEXT_OUTPUT_MODE || undefined,
78+
output: process.env.NEXT_OUTPUT_MODE as "standalone" | "export" | undefined,
7779
reactStrictMode: true, // Recommended for the `pages` directory, default in `app`.
78-
experimental: {
79-
dynamicIO: true,
80-
},
80+
cacheComponents: true,
8181
images: {
8282
remotePatterns: imageRemotePatterns,
8383
},
84-
eslint: {
85-
ignoreDuringBuilds: true,
86-
},
8784
async headers() {
8885
return [
8986
{
@@ -94,4 +91,29 @@ const nextConfig = {
9491
},
9592
};
9693

97-
export default withNextIntl(nextConfig);
94+
export default withSentryConfig(withNextIntl(nextConfig), {
95+
// For all available options, see:
96+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
97+
98+
org: "sentry",
99+
100+
project: "auth-ui",
101+
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
102+
103+
// Only print logs for uploading source maps in CI
104+
silent: !process.env.CI,
105+
106+
// For all available options, see:
107+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
108+
109+
// Upload a larger set of source maps for prettier stack traces (increases build time)
110+
widenClientFileUpload: true,
111+
112+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
113+
// This can increase your server load as well as your hosting bill.
114+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
115+
// side errors will fail.
116+
tunnelRoute: "/monitoring",
117+
118+
119+
});

apps/login/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dependencies": {
2626
"@headlessui/react": "^2.1.9",
2727
"@heroicons/react": "2.1.3",
28+
"@sentry/nextjs": "^10.34.0",
2829
"@tailwindcss/forms": "0.5.7",
2930
"@vercel/analytics": "^1.2.2",
3031
"@zitadel/client": "workspace:*",
@@ -35,13 +36,13 @@
3536
"fathom-client": "^3.7.2",
3637
"lucide-react": "0.469.0",
3738
"moment": "^2.29.4",
38-
"next": "15.6.0-canary.58",
39+
"next": "16.1.1",
3940
"next-intl": "^4.7.0",
4041
"next-themes": "^0.4.6",
4142
"nice-grpc": "2.0.1",
4243
"qrcode.react": "^3.1.0",
43-
"react": "19.1.4",
44-
"react-dom": "19.1.4",
44+
"react": "19.2.3",
45+
"react-dom": "19.2.3",
4546
"react-hook-form": "7.39.5",
4647
"tinycolor2": "1.4.2",
4748
"uuid": "^11.1.0"
@@ -52,8 +53,8 @@
5253
"@testing-library/react": "^16.3.0",
5354
"@types/ms": "2.1.0",
5455
"@types/node": "^22.14.1",
55-
"@types/react": "19.1.4",
56-
"@types/react-dom": "19.1.4",
56+
"@types/react": "19.2.3",
57+
"@types/react-dom": "19.2.3",
5758
"@types/tinycolor2": "1.4.3",
5859
"@types/uuid": "^10.0.0",
5960
"@vercel/git-hooks": "1.0.0",

apps/login/sentry.server.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file configures the initialization of Sentry on the server.
2+
// The config you add here will be used whenever the server handles a request.
3+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
4+
5+
import * as Sentry from "@sentry/nextjs";
6+
7+
Sentry.init({
8+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
9+
10+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
11+
tracesSampleRate: 1,
12+
13+
// Enable sending user PII (Personally Identifiable Information)
14+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
15+
sendDefaultPii: true,
16+
});

apps/login/src/app/(main)/error.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import { Boundary } from "@/components/boundary";
44
import { Button } from "@/components/button";
55
import { Translated } from "@/components/translated";
6+
import { captureException } from "@sentry/nextjs";
67
import { useEffect } from "react";
78

89
export default function Error({ error, reset }: any) {
910
useEffect(() => {
1011
console.log("logging error:", error);
12+
captureException(error);
1113
}, [error]);
1214

1315
return (
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use client";
2+
3+
import { Button } from "@/components/button";
4+
5+
const page = () => {
6+
return (
7+
<div>
8+
<Button
9+
onClick={() => {
10+
throw new Error("Test error");
11+
}}
12+
>
13+
Test
14+
</Button>
15+
</div>
16+
);
17+
};
18+
19+
export default page;

apps/login/src/app/global-error.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Boundary } from "@/components/boundary";
44
import { Button } from "@/components/button";
55
import { ThemeWrapper } from "@/components/theme-wrapper";
66
import { Translated } from "@/components/translated";
7+
import { captureException } from "@sentry/nextjs";
8+
import { useEffect } from "react";
79

810
export default function GlobalError({
911
error,
@@ -12,6 +14,9 @@ export default function GlobalError({
1214
error: Error & { digest?: string };
1315
reset: () => void;
1416
}) {
17+
useEffect(() => {
18+
captureException(error);
19+
}, [error]);
1520
return (
1621
// global-error must include html and body tags
1722
<html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This file configures the initialization of Sentry on the client.
2+
// The added config here will be used whenever a users loads a page in their browser.
3+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
4+
5+
import * as Sentry from "@sentry/nextjs";
6+
7+
Sentry.init({
8+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
9+
10+
// Add optional integrations for additional features
11+
integrations: [Sentry.replayIntegration()],
12+
13+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
14+
tracesSampleRate: 1,
15+
16+
// Define how likely Replay events are sampled.
17+
// This sets the sample rate to be 10%. You may want this to be 100% while
18+
// in development and sample at a lower rate in production
19+
replaysSessionSampleRate: 0.1,
20+
21+
// Define how likely Replay events are sampled when an error occurs.
22+
replaysOnErrorSampleRate: 1.0,
23+
24+
// Enable sending user PII (Personally Identifiable Information)
25+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
26+
sendDefaultPii: true,
27+
});
28+
29+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

apps/login/src/instrumentation.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+
export async function register() {
4+
await import("../sentry.server.config");
5+
}
6+
7+
export const onRequestError = Sentry.captureRequestError;

0 commit comments

Comments
 (0)