Skip to content

Commit

Permalink
fix sentry error reporting for Nuxt (server side)
Browse files Browse the repository at this point in the history
  • Loading branch information
usu committed Jun 1, 2024
1 parent 5921a88 commit b2b2ae2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 81 deletions.
74 changes: 0 additions & 74 deletions print/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions print/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"dependencies": {
"@jamescoyle/vue-icon": "0.1.2",
"@mdi/js": "7.4.47",
"@sentry/integrations": "7.114.0",
"@sentry/node": "8.7.0",
"axios": "1.7.2",
"colorjs.io": "0.5.0",
Expand All @@ -39,11 +38,11 @@
"@vitest/coverage-v8": "1.6.0",
"@vue/compiler-dom": "3.4.27",
"@vue/compiler-sfc": "3.4.27",
"@vue/test-utils": "2.4.5",
"eslint": "8.57.0",
"@vue/runtime-dom": "3.4.27",
"@vue/server-renderer": "3.4.27",
"@vue/shared": "3.4.27",
"@vue/test-utils": "2.4.5",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-local-rules": "2.0.1",
"eslint-plugin-prettier": "5.1.3",
Expand Down
5 changes: 3 additions & 2 deletions print/server/api/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import puppeteer from 'puppeteer-core'
import { performance } from 'perf_hooks'
import { URL } from 'url'
import { memoryUsage } from 'process'
import * as Sentry from '@sentry/node'

let lastTime = null
function measurePerformance(msg) {
Expand Down Expand Up @@ -165,8 +166,8 @@ export default defineEventHandler(async (event) => {
* @param {Error} error
*/
function captureError(error) {
if (process.sentry) {
process.sentry.captureException(error)
if (Sentry.isInitialized()) {
Sentry.captureException(error)
} else {
console.error(error)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Sentry from '@sentry/node'
import { CaptureConsole } from '@sentry/integrations'

export default defineNitroPlugin((nitroApp) => {
const { sentry } = useRuntimeConfig()
Expand All @@ -16,7 +15,7 @@ export default defineNitroPlugin((nitroApp) => {
environment: sentry.environment,
enableTracing: false,
autoSessionTracking: false,
integrations: [new CaptureConsole({ levels: ['warn', 'error'] })],
integrations: [Sentry.captureConsoleIntegration({ levels: ['warn', 'error'] })],
})

nitroApp.hooks.hook('error', (error) => {
Expand Down

0 comments on commit b2b2ae2

Please sign in to comment.