Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Jan 28, 2025
1 parent d6fe9a5 commit 7673958
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 116 deletions.
17 changes: 13 additions & 4 deletions packages/app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,31 @@ module.exports = nextConfig;
// Injected content via Sentry wizard below

const { withSentryConfig } = require("@sentry/nextjs");
const Sentry = require("@sentry/nextjs");

module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

// Clean output before source map upload
cleanArtifacts: true,

// Enable debug IDs
injectDebugIds: true,

// Enable source map uploading
sourcemaps: {
assets: "./**/*.{js,map}",
ignore: ["node_modules/**/*"],
deleteSourcemapsAfterUpload: true,
},

org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
url: process.env.SENTRY_URL,
authToken: process.env.SENTRY_AUTH_TOKEN,
release: process.env.SENTRY_RELEASE,
setCommits: {
auto: true,
},

// Enable debug mode for more verbose output
debug: true,
Expand All @@ -126,6 +127,14 @@ module.exports = withSentryConfig(
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,

// Enable release injection and component names
release: {
inject: true,
name: process.env.SENTRY_RELEASE || process.env.NEXT_PUBLIC_GITHUB_SHA || "dev",
},
includeNames: true,
autoInstrumentServerFunctions: false,

// Enables automatic instrumentation of Vercel Cron Monitors.
// See the following for more information:
// https://docs.sentry.io/product/crons/
Expand Down
3 changes: 0 additions & 3 deletions packages/app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ Sentry.init({
// Enable performance monitoring through traces
enableTracing: true,

// Track releases for better error monitoring
release: process.env.SENTRY_RELEASE || process.env.NEXT_PUBLIC_GITHUB_SHA || ENVIRONMENT,

beforeSend(event) {
// Filter out non-error events in production
if (IS_PRODUCTION && !event.exception) return null;
Expand Down
53 changes: 0 additions & 53 deletions packages/app/sentry.edge.config.ts

This file was deleted.

56 changes: 0 additions & 56 deletions packages/app/sentry.server.config.ts

This file was deleted.

103 changes: 103 additions & 0 deletions packages/app/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
// Initialize Sentry for server-side
const Sentry = await import("@sentry/nextjs");

const ENVIRONMENT = process.env.NEXT_PUBLIC_EGAPRO_ENV || "dev";
const IS_PRODUCTION = ENVIRONMENT === "production";

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
environment: ENVIRONMENT,

// Optimal sample rates based on environment
tracesSampleRate: IS_PRODUCTION ? 0.1 : 1.0,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

// Enable performance monitoring through traces
enableTracing: true,

beforeSend(event) {
// Filter out non-error events in production
if (IS_PRODUCTION && !event.exception) return null;

// Filter out known unnecessary errors
const ignoreErrors = [
"ResizeObserver loop limit exceeded",
"Network request failed",
/^Loading chunk .* failed/,
/^Loading CSS chunk .* failed/,
/^ECONNREFUSED/,
/^ECONNRESET/,
/^ETIMEDOUT/,
"Database connection timeout",
];

if (
event.exception &&
ignoreErrors.some(pattern => {
if (typeof pattern === "string") {
return event.exception?.values?.[0]?.value?.includes(pattern);
}
return pattern.test(event.exception?.values?.[0]?.value || "");
})
) {
return null;
}

return event;
},
});
}

if (process.env.NEXT_RUNTIME === "edge") {
// Initialize Sentry for edge runtime
const Sentry = await import("@sentry/nextjs");

const ENVIRONMENT = process.env.NEXT_PUBLIC_EGAPRO_ENV || "dev";
const IS_PRODUCTION = ENVIRONMENT === "production";

Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
environment: ENVIRONMENT,

// Optimal sample rates based on environment
tracesSampleRate: IS_PRODUCTION ? 0.1 : 1.0,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

// Enable performance monitoring through traces
enableTracing: true,

beforeSend(event) {
// Filter out non-error events in production
if (IS_PRODUCTION && !event.exception) return null;

// Filter out known unnecessary errors
const ignoreErrors = [
"ResizeObserver loop limit exceeded",
"Network request failed",
/^Loading chunk .* failed/,
/^Loading CSS chunk .* failed/,
];

if (
event.exception &&
ignoreErrors.some(pattern => {
if (typeof pattern === "string") {
return event.exception?.values?.[0]?.value?.includes(pattern);
}
return pattern.test(event.exception?.values?.[0]?.value || "");
})
) {
return null;
}

return event;
},
});
}
}

0 comments on commit 7673958

Please sign in to comment.