Skip to content

Commit 23a49e2

Browse files
authored
Merge pull request #2707 from trycompai/main
[comp] Production Deploy
2 parents 4359295 + e985b8b commit 23a49e2

18 files changed

Lines changed: 766 additions & 29 deletions

apps/app/.mcp.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mcpServers": {
3+
"Sentry": {
4+
"url": "https://mcp.sentry.dev/mcp/comp-ai/comp"
5+
}
6+
}
7+
}

apps/app/instrumentation-client.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/app/next.config.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { withSentryConfig } from '@sentry/nextjs';
12
import { withBotId } from 'botid/next/config';
23
import type { NextConfig } from 'next';
34
import path from 'path';
@@ -124,4 +125,40 @@ const config: NextConfig = {
124125
},
125126
};
126127

127-
export default withBotId(config);
128+
export default withSentryConfig(withBotId(config), {
129+
// For all available options, see:
130+
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
131+
132+
org: "comp-ai",
133+
134+
project: "comp",
135+
136+
// Only print logs for uploading source maps in CI
137+
silent: !process.env.CI,
138+
139+
// For all available options, see:
140+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
141+
142+
// Upload a larger set of source maps for prettier stack traces (increases build time)
143+
widenClientFileUpload: true,
144+
145+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
146+
// This can increase your server load as well as your hosting bill.
147+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
148+
// side errors will fail.
149+
tunnelRoute: "/monitoring",
150+
151+
webpack: {
152+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
153+
// See the following for more information:
154+
// https://docs.sentry.io/product/crons/
155+
// https://vercel.com/docs/cron-jobs
156+
automaticVercelMonitors: true,
157+
158+
// Tree-shaking options for reducing bundle size
159+
treeshake: {
160+
// Automatically tree-shake Sentry logger statements to reduce bundle size
161+
removeDebugLogging: true,
162+
},
163+
},
164+
});

apps/app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"@react-three/drei": "^10.3.0",
5353
"@react-three/fiber": "^9.1.2",
5454
"@react-three/postprocessing": "^3.0.4",
55+
"@sentry/cli": "^2",
56+
"@sentry/nextjs": "^10",
5557
"@streamdown/cjk": "^1.0.2",
5658
"@streamdown/code": "^1.0.3",
5759
"@streamdown/math": "^1.0.2",

apps/app/sentry.edge.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 for edge features (middleware, edge routes, and so on).
2+
// The config you add here will be used whenever one of the edge features is loaded.
3+
// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
4+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
5+
6+
import * as Sentry from '@sentry/nextjs';
7+
8+
Sentry.init({
9+
dsn:
10+
process.env.SENTRY_DSN ??
11+
'https://331f1c3d4b08e9352dd1a2621e1ae845@o4509214247813120.ingest.us.sentry.io/4511304630927360',
12+
13+
tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.1,
14+
15+
enableLogs: true,
16+
});

apps/app/sentry.server.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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:
9+
process.env.SENTRY_DSN ??
10+
'https://331f1c3d4b08e9352dd1a2621e1ae845@o4509214247813120.ingest.us.sentry.io/4511304630927360',
11+
12+
tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.1,
13+
14+
// Off in production: local variables in stack frames can expose request-scoped
15+
// data (DB rows, auth tokens, request bodies) to Sentry payloads.
16+
includeLocalVariables: process.env.NODE_ENV !== 'production',
17+
18+
enableLogs: true,
19+
});

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
'use client';
22

3+
import * as Sentry from '@sentry/nextjs';
34
import { Button } from '@trycompai/ui/button';
45
import NextError from 'next/error';
56
import Link from 'next/link';
7+
import { useEffect } from 'react';
68

79
export default function GlobalError({ error, reset }: { error: Error; reset: () => void }) {
10+
useEffect(() => {
11+
Sentry.captureException(error);
12+
}, [error]);
13+
814
return (
915
<html lang="en">
1016
<body>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 { initBotId } from 'botid/client/core';
6+
import * as Sentry from '@sentry/nextjs';
7+
8+
initBotId({
9+
protect: [
10+
{ path: '/api/chat', method: 'POST' },
11+
{
12+
path: `${process.env.NEXT_PUBLIC_ENTERPRISE_API_URL}/api/tasks-automations/chat`,
13+
method: 'POST',
14+
},
15+
{
16+
path: `${process.env.NEXT_PUBLIC_ENTERPRISE_API_URL}/api/tasks-automations/errors`,
17+
method: 'POST',
18+
},
19+
],
20+
});
21+
22+
Sentry.init({
23+
dsn:
24+
process.env.NEXT_PUBLIC_SENTRY_DSN ??
25+
'https://331f1c3d4b08e9352dd1a2621e1ae845@o4509214247813120.ingest.us.sentry.io/4511304630927360',
26+
27+
integrations: [
28+
// Add `data-sentry-mask` (or `.sentry-mask`) to any element rendering
29+
// customer-confidential data; `data-sentry-block` to drop whole sections.
30+
Sentry.replayIntegration({
31+
maskAllText: false,
32+
blockAllMedia: false,
33+
mask: ['.sentry-mask', '[data-sentry-mask]'],
34+
block: ['[data-sentry-block]'],
35+
}),
36+
],
37+
38+
tracesSampleRate: process.env.NODE_ENV === 'development' ? 1.0 : 0.1,
39+
40+
enableLogs: true,
41+
42+
// 10% of all sessions; 100% of sessions where an error occurs.
43+
replaysSessionSampleRate: 0.1,
44+
replaysOnErrorSampleRate: 1.0,
45+
});
46+
47+
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

apps/app/src/instrumentation.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as Sentry from "@sentry/nextjs";
2+
3+
export async function register() {
4+
if (process.env.NEXT_RUNTIME === "nodejs") {
5+
await import("../sentry.server.config");
6+
}
7+
8+
if (process.env.NEXT_RUNTIME === "edge") {
9+
await import("../sentry.edge.config");
10+
}
11+
}
12+
13+
export const onRequestError = Sentry.captureRequestError;

apps/portal/next.config.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { withSentryConfig } from '@sentry/nextjs';
12
import path from 'path';
23
import './src/env.mjs';
34

@@ -71,4 +72,23 @@ const config = {
7172
: {}),
7273
};
7374

74-
export default config;
75+
export default withSentryConfig(config, {
76+
org: 'comp-ai',
77+
project: 'comp',
78+
79+
// Only print logs for uploading source maps in CI
80+
silent: !process.env.CI,
81+
82+
// Upload a larger set of source maps for prettier stack traces
83+
widenClientFileUpload: true,
84+
85+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
86+
tunnelRoute: '/monitoring',
87+
88+
webpack: {
89+
// Automatically tree-shake Sentry logger statements to reduce bundle size
90+
treeshake: {
91+
removeDebugLogging: true,
92+
},
93+
},
94+
});

0 commit comments

Comments
 (0)