Skip to content

Commit bef682f

Browse files
committed
add sentry
1 parent 21624cc commit bef682f

File tree

9 files changed

+2973
-177
lines changed

9 files changed

+2973
-177
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ yarn-error.log*
3232

3333
# vercel
3434
.vercel
35+
36+
# Sentry Config File
37+
.env.sentry-build-plugin

components/loginout.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { useSession } from 'next-auth/react';
22
import Link from 'next/link';
3+
import { useEffect } from 'react';
34
import Nav from 'react-bootstrap/Nav';
45
import { useSelector } from 'react-redux';
6+
import * as Sentry from "@sentry/nextjs";
57

68
function LoginOut() {
79
const { data: session } = useSession();
810
const currentUserInfo = useSelector((state) => state.currentUser);
11+
useEffect(() => {
12+
if (currentUserInfo.loaded) {
13+
Sentry.setUser({ id: currentUserInfo.id, username: currentUserInfo.username });
14+
}
15+
}, [session, currentUserInfo.loaded]);
916
// const loginStatus = useSelector((state) => state.loginStatus);
1017
return session ? (
1118
<Link href="/api/auth/signout" passHref legacyBehavior>

instrumentation.js

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

next.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,47 @@ module.exports = {
1717
defaultLocale: 'en',
1818
},
1919
};
20+
21+
// Injected content via Sentry wizard below
22+
23+
const { withSentryConfig } = require('@sentry/nextjs');
24+
25+
module.exports = withSentryConfig(module.exports, {
26+
// For all available options, see:
27+
// https://github.com/getsentry/sentry-webpack-plugin#options
28+
29+
org: 'lab-lab-lab',
30+
project: 'music-cpr-prod',
31+
32+
// Only print logs for uploading source maps in CI
33+
silent: !process.env.CI,
34+
35+
// For all available options, see:
36+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
37+
38+
// Upload a larger set of source maps for prettier stack traces (increases build time)
39+
widenClientFileUpload: true,
40+
41+
// Automatically annotate React components to show their full name in breadcrumbs and session replay
42+
reactComponentAnnotation: {
43+
enabled: true,
44+
},
45+
46+
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
47+
// This can increase your server load as well as your hosting bill.
48+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
49+
// side errors will fail.
50+
// tunnelRoute: "/monitoring",
51+
52+
// Hides source maps from generated client bundles
53+
hideSourceMaps: true,
54+
55+
// Automatically tree-shake Sentry logger statements to reduce bundle size
56+
disableLogger: true,
57+
58+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
59+
// See the following for more information:
60+
// https://docs.sentry.io/product/crons/
61+
// https://vercel.com/docs/cron-jobs
62+
automaticVercelMonitors: true,
63+
});

0 commit comments

Comments
 (0)