Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fix: logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshew committed Jul 4, 2022
1 parent f69a3e4 commit f576c58
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/components/shared/FirebaseStorageResolver.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from "@Components/shared"
import { download } from "@Services/firebase/storage"
import { logError } from "@kittr/logger/nextjs"
import { captureException } from "@kittr/logger/nextjs"
import { useEffect } from "react"
import { useQuery } from "react-query"

Expand All @@ -16,7 +16,7 @@ export const FirebaseStorageResolver = ({ path, noSpinner, render }: FirebaseRes

useEffect(() => {
if (error) {
logError(error)
captureException(error)
}
}, [error])

Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/pages/_error.page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// @ts-nocheck
import NextErrorComponent from "next/error"
import { logError, flush } from "@kittr/logger/nextjs"
import { captureException, flush } from "@kittr/logger/nextjs"

const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
if (!hasGetInitialPropsRun && err) {
// getInitialProps is not called in case of
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
console.error(err)
logError(JSON.stringify(err))
console.error({ firstOne: err })
captureException(err)
// Flushing is not required in this case as it only happens on the client
}

Expand Down Expand Up @@ -43,8 +43,8 @@ MyError.getInitialProps = async (context) => {
// Boundaries: https://reactjs.org/docs/error-boundaries.html

if (err) {
console.error(err)
logError(JSON.stringify(err))
console.error({ err })
captureException(err)

// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
Expand All @@ -56,7 +56,7 @@ MyError.getInitialProps = async (context) => {
// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Logger
logError(new Error(`_error.js getInitialProps missing data at path: ${asPath}`))
captureException(new Error(`_error.js getInitialProps missing data at path: ${asPath}`))
await flush(2000)

return errorInitialProps
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { kitsRouter } from "./routers/kits"
import { managersRouter } from "./routers/managers"
import { twitchRouter } from "./routers/twitch"
import { usersRouter } from "./routers/users"
import { logError } from '@kittr/logger/node'
import { captureException } from '@kittr/logger/node'

export const appRouter = createRouter()
.formatError(({ shape, error }) => {
logError(JSON.stringify({ message: shape.message, error }))
captureException({ message: shape.message, error })
return shape
})
.transformer(superjson)
Expand Down

0 comments on commit f576c58

Please sign in to comment.