Skip to content

Commit

Permalink
improve sentry calls
Browse files Browse the repository at this point in the history
  • Loading branch information
berekuk committed Mar 4, 2024
1 parent 866a0a5 commit b3cdec9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 0 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",

Expand Down
2 changes: 1 addition & 1 deletion src/lib/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export function captureApiError(
}

export function searchError(name: string, e: unknown) {
sentry.captureException(e, { tags: name });
sentry.captureException(e, { tags: { name } });
}
19 changes: 11 additions & 8 deletions src/server/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import { __API_ENV__ } from "~/lib/constants";

import * as Sentry from "@sentry/nextjs";

export function captureException(e, metadata) {
if (__API_ENV__ === "development") {
console.log("exception", e, metadata);
} else {
export function captureException(
e: unknown,
metadata: Parameters<typeof Sentry.captureException>[1]
) {
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
Sentry.captureException(e, metadata);
} else {
console.log("exception", e, metadata);
}
}

export function captureMessage(message, metadata) {
if (__API_ENV__ === "development") {
console.log("captureMessage", message, metadata);
export function captureMessage(message: string, tags: Record<string, any>) {
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
Sentry.captureMessage(message, { tags });
} else {
Sentry.captureMessage(message, { tags: metadata });
console.log("captureMessage", message, tags);
}
}

0 comments on commit b3cdec9

Please sign in to comment.