1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-09-16 17:55:32 -04:00

bump next to 12.1.0

This commit is contained in:
2022-02-17 19:38:12 -05:00
parent 147128516e
commit 6256223517
8 changed files with 99 additions and 140 deletions

7
lib/helpers/fetcher.ts Normal file
View File

@@ -0,0 +1,7 @@
// very simple fetch wrapper that's passed into SWR hooks:
// https://swr.vercel.app/docs/data-fetching#fetch
// note: fetch does *not* need to be poly/ponyfilled in Next.js:
// https://nextjs.org/blog/next-9-1-7#new-built-in-polyfills-fetch-url-and-objectassign
// eslint-disable-next-line no-undef
export const fetcher = (url: RequestInfo) => fetch(url).then((res) => res.json());

31
lib/helpers/sentry.ts Normal file
View File

@@ -0,0 +1,31 @@
import * as Sentry from "@sentry/node";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as Tracing from "@sentry/tracing";
// https://docs.sentry.io/platforms/node/configuration/options/
Sentry.init({
dsn: process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN || "",
environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "",
tracesSampleRate: 1.0,
});
export const logServerError = async (error: string | Error) => {
try {
// log error to sentry
Sentry.captureException(error);
// give it 2 seconds to finish sending:
// https://docs.sentry.io/platforms/node/configuration/draining/
await Sentry.flush(2000);
} catch (sentryError) {
// cue inception bong
console.error("Encountered an error logging an error... We are doomed.", sentryError);
}
// also log the error normally to the Vercel console; will get picked up by log drain
console.error(error);
// we really don't want to return *any* error from logging an error, so just keep it on the dl
return true;
};
export default Sentry;