aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaheshtheDev <[email protected]>2025-08-21 19:46:41 +0000
committerMaheshtheDev <[email protected]>2025-08-21 19:46:41 +0000
commit52cbf55763fa51bcf3497d3b760eed87ca515b7d (patch)
tree625d0a7ba31aad1317dd710abebea882a036ebae
parentAdd AI SDK Utilities (#375) (diff)
downloadsupermemory-52cbf55763fa51bcf3497d3b760eed87ca515b7d.tar.xz
supermemory-52cbf55763fa51bcf3497d3b760eed87ca515b7d.zip
feat: sentry integration (#376)
-rw-r--r--apps/web/.gitignore3
-rw-r--r--apps/web/app/global-error.tsx23
-rw-r--r--apps/web/instrumentation-client.ts28
-rw-r--r--apps/web/instrumentation.ts13
-rw-r--r--apps/web/next.config.ts78
-rw-r--r--apps/web/package.json2
-rw-r--r--apps/web/sentry.edge.config.ts19
-rw-r--r--apps/web/sentry.server.config.ts18
-rwxr-xr-xbun.lockbbin699608 -> 694040 bytes
9 files changed, 134 insertions, 50 deletions
diff --git a/apps/web/.gitignore b/apps/web/.gitignore
index 4f328319..c740f883 100644
--- a/apps/web/.gitignore
+++ b/apps/web/.gitignore
@@ -35,3 +35,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
+
+# Sentry Config File
+.env.sentry-build-plugin
diff --git a/apps/web/app/global-error.tsx b/apps/web/app/global-error.tsx
new file mode 100644
index 00000000..9bda5fee
--- /dev/null
+++ b/apps/web/app/global-error.tsx
@@ -0,0 +1,23 @@
+"use client";
+
+import * as Sentry from "@sentry/nextjs";
+import NextError from "next/error";
+import { useEffect } from "react";
+
+export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
+ useEffect(() => {
+ Sentry.captureException(error);
+ }, [error]);
+
+ return (
+ <html>
+ <body>
+ {/* `NextError` is the default Next.js error page component. Its type
+ definition requires a `statusCode` prop. However, since the App Router
+ does not expose status codes for errors, we simply pass 0 to render a
+ generic error message. */}
+ <NextError statusCode={0} />
+ </body>
+ </html>
+ );
+} \ No newline at end of file
diff --git a/apps/web/instrumentation-client.ts b/apps/web/instrumentation-client.ts
index d348b544..2c9c9e2d 100644
--- a/apps/web/instrumentation-client.ts
+++ b/apps/web/instrumentation-client.ts
@@ -2,23 +2,29 @@
// The added config here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
-import * as Sentry from "@sentry/nextjs";
+import * as Sentry from '@sentry/nextjs';
Sentry.init({
- _experiments: {
- enableLogs: true,
- },
+ dsn: 'https://2451ebfd1a7490f05fa7776482df81b6@o4508385422802944.ingest.us.sentry.io/4509872269819904',
- enabled: process.env.NODE_ENV === "production",
+ // Add optional integrations for additional features
+ integrations: [Sentry.replayIntegration()],
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
- debug: false,
- dsn: "https://a12ac22517d938dc69f9c5ad67bf8e2d@o4508385422802944.ingest.us.sentry.io/4509454536998913",
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
+ tracesSampleRate: 1,
+ // Enable logs to be sent to Sentry
+ enableLogs: true,
- integrations: [Sentry.consoleLoggingIntegration()],
+ // Define how likely Replay events are sampled.
+ // This sets the sample rate to be 10%. You may want this to be 100% while
+ // in development and sample at a lower rate in production
+ replaysSessionSampleRate: 0.1,
- // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
- tracesSampleRate: 1,
+ // Define how likely Replay events are sampled when an error occurs.
+ replaysOnErrorSampleRate: 1.0,
+
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
+ debug: false,
});
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
diff --git a/apps/web/instrumentation.ts b/apps/web/instrumentation.ts
new file mode 100644
index 00000000..964f937c
--- /dev/null
+++ b/apps/web/instrumentation.ts
@@ -0,0 +1,13 @@
+import * as Sentry from '@sentry/nextjs';
+
+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 = Sentry.captureRequestError;
diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts
index 6a92e72c..a6ee01f3 100644
--- a/apps/web/next.config.ts
+++ b/apps/web/next.config.ts
@@ -2,60 +2,62 @@ import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
- experimental: {
- reactCompiler: true,
- viewTransition: true,
- },
- eslint: {
- ignoreDuringBuilds: true,
- },
- poweredByHeader: false,
- async rewrites() {
- return [
- {
- source: "/ingest/static/:path*",
- destination: "https://us-assets.i.posthog.com/static/:path*",
- },
- {
- source: "/ingest/:path*",
- destination: "https://us.i.posthog.com/:path*",
- },
- ];
- },
- skipTrailingSlashRedirect: true,
+ experimental: {
+ reactCompiler: true,
+ viewTransition: true,
+ },
+ eslint: {
+ ignoreDuringBuilds: true,
+ },
+ poweredByHeader: false,
+ async rewrites() {
+ return [
+ {
+ source: "/ingest/static/:path*",
+ destination: "https://us-assets.i.posthog.com/static/:path*",
+ },
+ {
+ source: "/ingest/:path*",
+ destination: "https://us.i.posthog.com/:path*",
+ },
+ ];
+ },
+ skipTrailingSlashRedirect: true,
};
export default withSentryConfig(nextConfig, {
- // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
- // See the following for more information:
- // https://docs.sentry.io/product/crons/
- // https://vercel.com/docs/cron-jobs
- automaticVercelMonitors: true,
-
- // Automatically tree-shake Sentry logger statements to reduce bundle size
- disableLogger: true,
- // For all available options, see:
+ // For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: "supermemory",
- project: "consumer",
- // Only print logs for uploading source maps in CI
+ project: "consumer-app",
+
+ // Only print logs for uploading source maps in CI
silent: !process.env.CI,
- // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
+ // For all available options, see:
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
+
+ // Upload a larger set of source maps for prettier stack traces (increases build time)
+ widenClientFileUpload: true,
+
+ // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
- // For all available options, see:
- // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
+ // Automatically tree-shake Sentry logger statements to reduce bundle size
+ disableLogger: true,
- // Upload a larger set of source maps for prettier stack traces (increases build time)
- widenClientFileUpload: true,
+ // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
+ // See the following for more information:
+ // https://docs.sentry.io/product/crons/
+ // https://vercel.com/docs/cron-jobs
+ automaticVercelMonitors: true,
});
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
-initOpenNextCloudflareForDev();
+initOpenNextCloudflareForDev(); \ No newline at end of file
diff --git a/apps/web/package.json b/apps/web/package.json
index 47f2bff8..546dd9f3 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -39,7 +39,7 @@
"@react-router/fs-routes": "^7.6.2",
"@react-router/node": "^7.6.2",
"@react-router/serve": "^7.6.2",
- "@sentry/nextjs": "^9.33.0",
+ "@sentry/nextjs": "^10",
"@tabler/icons-react": "^3.34.0",
"@tailwindcss/typography": "^0.5.16",
"@tanstack/react-form": "^1.12.4",
diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.ts
new file mode 100644
index 00000000..cff5a86d
--- /dev/null
+++ b/apps/web/sentry.edge.config.ts
@@ -0,0 +1,19 @@
+// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
+// The config you add here will be used whenever one of the edge features is loaded.
+// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
+// https://docs.sentry.io/platforms/javascript/guides/nextjs/
+
+import * as Sentry from "@sentry/nextjs";
+
+Sentry.init({
+ dsn: "https://2451ebfd1a7490f05fa7776482df81b6@o4508385422802944.ingest.us.sentry.io/4509872269819904",
+
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
+ tracesSampleRate: 1,
+
+ // Enable logs to be sent to Sentry
+ enableLogs: true,
+
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
+ debug: false,
+});
diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.ts
new file mode 100644
index 00000000..2cd5afbe
--- /dev/null
+++ b/apps/web/sentry.server.config.ts
@@ -0,0 +1,18 @@
+// This file configures the initialization of Sentry on the server.
+// The config you add here will be used whenever the server handles a request.
+// https://docs.sentry.io/platforms/javascript/guides/nextjs/
+
+import * as Sentry from "@sentry/nextjs";
+
+Sentry.init({
+ dsn: "https://2451ebfd1a7490f05fa7776482df81b6@o4508385422802944.ingest.us.sentry.io/4509872269819904",
+
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
+ tracesSampleRate: 1,
+
+ // Enable logs to be sent to Sentry
+ enableLogs: true,
+
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
+ debug: false,
+});
diff --git a/bun.lockb b/bun.lockb
index 2143da85..0a1edefa 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ