Commit e564b95f authored by tom goriunov's avatar tom goriunov Committed by GitHub

Merge pull request #133 from blockscout/sentry-fixes

sentry fixes
parents fd0fbe8a 4d71e07d
import * as Sentry from '@sentry/nextjs';
import type { NextApiRequest } from 'next'; import type { NextApiRequest } from 'next';
import * as cookies from 'lib/cookies'; import * as cookies from 'lib/cookies';
...@@ -7,8 +8,7 @@ export default function getUrlWithNetwork(_req: NextApiRequest, path: string) { ...@@ -7,8 +8,7 @@ export default function getUrlWithNetwork(_req: NextApiRequest, path: string) {
const networkSubType = _req.cookies[cookies.NAMES.NETWORK_SUB_TYPE]; const networkSubType = _req.cookies[cookies.NAMES.NETWORK_SUB_TYPE];
if (!networkType || !networkSubType) { if (!networkType || !networkSubType) {
// eslint-disable-next-line no-console Sentry.captureException(new Error('Incorrect network'), { extra: { networkType, networkSubType } });
console.error(`Incorrect network: NETWORK_TYPE=${ networkType } NETWORK_SUB_TYPE=${ networkSubType }`);
} }
return `/${ networkType }/${ networkSubType }/${ path }`; return `/${ networkType }/${ networkSubType }/${ path }`;
......
import * as Sentry from '@sentry/nextjs';
export interface ErrorType<T> { export interface ErrorType<T> {
error?: T; error?: T;
status: Response['status']; status: Response['status'];
...@@ -13,10 +15,15 @@ export default function clientFetch<Success, Error>(path: string, init?: Request ...@@ -13,10 +15,15 @@ export default function clientFetch<Success, Error>(path: string, init?: Request
status: response.status, status: response.status,
statusText: response.statusText, statusText: response.statusText,
}), }),
() => Promise.reject({ () => {
status: response.status, const error = {
statusText: response.statusText, status: response.status,
}), statusText: response.statusText,
};
Sentry.captureException(new Error('Client fetch failed'), { extra: error, tags: { source: 'fetch' } });
return Promise.reject(error);
},
); );
} else { } else {
......
...@@ -30,6 +30,9 @@ const sentryWebpackPluginOptions = { ...@@ -30,6 +30,9 @@ const sentryWebpackPluginOptions = {
silent: true, // Suppresses all logs silent: true, // Suppresses all logs
// For all available options, see: // For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options. // https://github.com/getsentry/sentry-webpack-plugin#options.
deploy: {
env: process.env.VERCEL_ENV || process.env.NODE_ENV,
},
}; };
module.exports = withReactSvg(withSentryConfig(moduleExports, sentryWebpackPluginOptions)); module.exports = withReactSvg(withSentryConfig(moduleExports, sentryWebpackPluginOptions));
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
import * as Sentry from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs';
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const ENV = process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.NODE_ENV;
Sentry.init({ Sentry.init({
environment: ENV,
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control // Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
import * as Sentry from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs';
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
const ENV = process.env.VERCEL_ENV || process.env.NODE_ENV;
Sentry.init({ Sentry.init({
environment: ENV,
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control // Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1.0, tracesSampleRate: 1.0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment