Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Feb 3, 2025
1 parent b883181 commit da44cb7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
19 changes: 16 additions & 3 deletions packages/app/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,28 @@ Sentry.init({

debug: true, // Temporarily enable debug mode to troubleshoot

// Development-specific settings
maxBreadcrumbs: 10,
autoSessionTracking: false,
sendClientReports: true, // Enable immediate client reports
sampleRate: 1.0, // Capture all errors in development

// Enable performance monitoring through traces
enableTracing: true,

beforeSend(event) {
// Log the event being sent
console.log("Sentry event:", event);
console.log("Sentry beforeSend called with event:", {
eventId: event.event_id,
type: event.type,
exception: event.exception?.values?.[0],
environment: event.environment,
});

// Filter out non-error events in production
if (IS_PRODUCTION && !event.exception) return null;
if (IS_PRODUCTION && !event.exception) {
console.log("Filtering out non-error event in production");
return null;
}

// Filter out known unnecessary errors
const ignoreErrors = [
Expand Down
14 changes: 12 additions & 2 deletions packages/app/src/components/utils/SentryErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,18 @@ export class SentryErrorBoundary extends Component<PropsWithChildren, State> {
scope.setLevel("error");

console.log("Sending error to Sentry...");
const eventId = Sentry.captureException(errorWithContext);
console.log("Error sent to Sentry with event ID:", eventId);
try {
const eventId = Sentry.captureException(errorWithContext);
console.log("Error sent to Sentry with event ID:", eventId);

// Flush events to ensure they are sent immediately
Sentry.flush().then(
() => console.log("Successfully flushed Sentry events"),
error => console.error("Failed to flush Sentry events:", error),
);
} catch (e) {
console.error("Failed to send error to Sentry:", e);
}
});
}

Expand Down
24 changes: 14 additions & 10 deletions packages/app/src/components/utils/SentryTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ import { useCallback } from "react";

export const SentryTest = () => {
const triggerError = useCallback(() => {
// Log configuration for debugging
console.log("Sentry Configuration:", {
// Log configuration and start of error test
console.log("Starting Sentry test with config:", {
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
environment: process.env.NEXT_PUBLIC_EGAPRO_ENV,
});

// Create and throw an error that will be caught by the error boundary
const error = new Error("Test error for Sentry integration");
error.name = "SentryTestError";
error.cause = "Manual test trigger";

// Add a stack trace starting from this point
Error.captureStackTrace(error, triggerError);
console.log("Triggering test error - this should be caught by the error boundary...");

throw error;
// Create and throw an error that will be caught by the error boundary
try {
// Create an error with a stack trace by actually throwing it
throw new Error("Test error for Sentry integration");
} catch (e) {
const error = e as Error;
error.name = "SentryTestError";
error.cause = "Manual test trigger";
throw error;
}
}, []);

return (
Expand Down

0 comments on commit da44cb7

Please sign in to comment.