Skip to content

Commit 5195136

Browse files
committed
Merge branch 'feat/sentry'
2 parents 7828f75 + c5d0f37 commit 5195136

File tree

13 files changed

+1065
-1141
lines changed

13 files changed

+1065
-1141
lines changed

apps/kafka-consumer/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const consumer = kafka.consumer({ groupId: "group-1" });
2222

2323
const run = async () => {
2424
await consumer.connect().then(() => console.log("Connected"));
25-
25+
const topic = process.env.KAFKA_TOPIC || "delete-child";
2626
await consumer
2727
.subscribe({
28-
topic: process.env.KAFKA_TOPIC || "delete-child",
28+
topic,
2929
fromBeginning: true,
3030
})
31-
.then(() => console.log("Subscribed to topic"));
31+
.then(() => console.log("Subscribed to topic: "+ topic));
3232

3333
await consumer.run({
3434
eachMessage: async ({ topic, partition, message }) => {

apps/web/app/api/kafka/produce/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { KafkaMessage } from "@repo/backend/lib/types";
44
export const POST = async (req: Request) => {
55
const body: KafkaMessage = await req.json();
66

7+
console.log("body from route", body);
8+
79
const res = await produceMessage(body);
810

911
return Response.json({ message: "Message sent", res });

apps/web/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({ error }: { error: Error & { digest?: string } }) {
8+
useEffect(() => {
9+
Sentry.captureException(error);
10+
}, [error]);
11+
12+
return (
13+
<html>
14+
<body>
15+
{/* `NextError` is the default Next.js error page component. Its type
16+
definition requires a `statusCode` prop. However, since the App Router
17+
does not expose status codes for errors, we simply pass 0 to render a
18+
generic error message. */}
19+
<NextError statusCode={0} />
20+
</body>
21+
</html>
22+
);
23+
}

apps/web/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/web/lib/kafka.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable turbo/no-undeclared-env-vars */
21
import { KafkaMessage } from "@repo/backend/lib/types";
32
import { Kafka, logLevel } from "kafkajs";
43

@@ -15,10 +14,11 @@ const kafka = new Kafka({
1514
}).producer();
1615

1716
export const produceMessage = async (message: KafkaMessage) => {
17+
const topic = process.env.KAFKA_TOPIC || "delete-child";
1818
try {
1919
await kafka.connect();
2020
await kafka.send({
21-
topic:process.env.KAFKA_TOPIC || "delete-child",
21+
topic,
2222
messages: [{ value: JSON.stringify(message) }],
2323
});
2424
} catch (error) {

apps/web/next.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,47 @@ module.exports = {
3131
}
3232
]
3333
};
34+
35+
36+
// Injected content via Sentry wizard below
37+
38+
const { withSentryConfig } = require("@sentry/nextjs");
39+
40+
module.exports = withSentryConfig(
41+
module.exports,
42+
{
43+
// For all available options, see:
44+
// https://github.com/getsentry/sentry-webpack-plugin#options
45+
46+
org: "vigneshfixes",
47+
project: "projectify",
48+
sentryUrl: "https://sentry.io/",
49+
50+
// Only print logs for uploading source maps in CI
51+
silent: !process.env.CI,
52+
53+
// For all available options, see:
54+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
55+
56+
// Upload a larger set of source maps for prettier stack traces (increases build time)
57+
widenClientFileUpload: true,
58+
59+
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
60+
// This can increase your server load as well as your hosting bill.
61+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
62+
// side errors will fail.
63+
// tunnelRoute: "/monitoring",
64+
65+
// Hides source maps from generated client bundles
66+
hideSourceMaps: true,
67+
68+
// Automatically tree-shake Sentry logger statements to reduce bundle size
69+
disableLogger: true,
70+
71+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
72+
// See the following for more information:
73+
// https://docs.sentry.io/product/crons/
74+
// https://vercel.com/docs/cron-jobs
75+
automaticVercelMonitors: true,
76+
}
77+
);

apps/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev --turbo",
6+
"dev": "next dev",
77
"app:build": "npx convex deploy --cmd 'npm run build' -y",
88
"start": "next start",
99
"lint": "next lint",
@@ -31,6 +31,7 @@
3131
"@radix-ui/react-toggle": "^1.1.0",
3232
"@radix-ui/react-tooltip": "^1.0.7",
3333
"@repo/backend": "*",
34+
"@sentry/nextjs": "8",
3435
"@tanstack/react-table": "^8.16.0",
3536
"@tiptap/extension-link": "^2.4.0",
3637
"@tiptap/pm": "^2.4.0",

apps/web/sentry.client.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This file configures the initialization of Sentry on the client.
2+
// The config you add 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+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
11+
tracesSampleRate: 1,
12+
13+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
14+
debug: false,
15+
});

apps/web/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: process.env.NEXT_PUBLIC_SENTRY_DSN,
10+
11+
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
12+
tracesSampleRate: 1,
13+
14+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
15+
debug: false,
16+
});

apps/web/sentry.server.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
// Setting this option to true will print useful information to the console while you're setting up Sentry.
14+
debug: false,
15+
});

0 commit comments

Comments
 (0)