@sentry/nuxt 8.44.0 → 8.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/build/esm/package.json +1 -1
  2. package/build/module/module.json +1 -1
  3. package/build/module/runtime/plugins/sentry.server.js +28 -2
  4. package/build/types/build.config.d.ts.map +1 -1
  5. package/build/types/index.types.d.ts +1 -0
  6. package/build/types/src/runtime/plugins/sentry.server.d.ts.map +1 -1
  7. package/package.json +7 -8
  8. package/build/cjs/runtime/nitro-utils/build/esm/nitro/patchEventHandler.js +0 -43
  9. package/build/cjs/runtime/nitro-utils/build/esm/nitro/patchEventHandler.js.map +0 -1
  10. package/build/cjs/runtime/nitro-utils/build/esm/util/flush.js +0 -36
  11. package/build/cjs/runtime/nitro-utils/build/esm/util/flush.js.map +0 -1
  12. package/build/cjs/runtime/nuxt/src/runtime/plugins/sentry.client.js +0 -55
  13. package/build/cjs/runtime/nuxt/src/runtime/plugins/sentry.client.js.map +0 -1
  14. package/build/cjs/runtime/nuxt/src/runtime/plugins/sentry.server.js +0 -70
  15. package/build/cjs/runtime/nuxt/src/runtime/plugins/sentry.server.js.map +0 -1
  16. package/build/cjs/runtime/nuxt/src/runtime/utils.js +0 -81
  17. package/build/cjs/runtime/nuxt/src/runtime/utils.js.map +0 -1
  18. package/build/esm/runtime/nitro-utils/build/esm/nitro/patchEventHandler.js +0 -41
  19. package/build/esm/runtime/nitro-utils/build/esm/nitro/patchEventHandler.js.map +0 -1
  20. package/build/esm/runtime/nitro-utils/build/esm/util/flush.js +0 -33
  21. package/build/esm/runtime/nitro-utils/build/esm/util/flush.js.map +0 -1
  22. package/build/esm/runtime/nuxt/src/runtime/plugins/sentry.client.js +0 -55
  23. package/build/esm/runtime/nuxt/src/runtime/plugins/sentry.client.js.map +0 -1
  24. package/build/esm/runtime/nuxt/src/runtime/plugins/sentry.server.js +0 -70
  25. package/build/esm/runtime/nuxt/src/runtime/plugins/sentry.server.js.map +0 -1
  26. package/build/esm/runtime/nuxt/src/runtime/utils.js +0 -77
  27. package/build/esm/runtime/nuxt/src/runtime/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"type":"module","version":"8.44.0"}
1
+ {"type":"module","version":"8.45.1"}
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.7.0"
6
6
  },
7
- "version": "8.44.0",
7
+ "version": "8.45.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -1,5 +1,13 @@
1
- import { patchEventHandler } from "@sentry-internal/nitro-utils";
2
- import { GLOBAL_OBJ, flush, getClient, logger, vercelWaitUntil } from "@sentry/core";
1
+ import {
2
+ GLOBAL_OBJ,
3
+ flush,
4
+ getClient,
5
+ getDefaultIsolationScope,
6
+ getIsolationScope,
7
+ logger,
8
+ vercelWaitUntil,
9
+ withIsolationScope
10
+ } from "@sentry/core";
3
11
  import * as Sentry from "@sentry/node";
4
12
  import { H3Error } from "h3";
5
13
  import { defineNitroPlugin } from "nitropack/runtime";
@@ -49,3 +57,21 @@ async function flushWithTimeout() {
49
57
  isDebug && logger.log("Error while flushing events:\n", e);
50
58
  }
51
59
  }
60
+ function patchEventHandler(handler) {
61
+ return new Proxy(handler, {
62
+ async apply(handlerTarget, handlerThisArg, handlerArgs) {
63
+ const isolationScope = getIsolationScope();
64
+ const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
65
+ logger.log(
66
+ `Patched h3 event handler. ${isolationScope === newIsolationScope ? "Using existing" : "Created new"} isolation scope.`
67
+ );
68
+ return withIsolationScope(newIsolationScope, async () => {
69
+ try {
70
+ return await handlerTarget.apply(handlerThisArg, handlerArgs);
71
+ } finally {
72
+ await flushIfServerless();
73
+ }
74
+ });
75
+ }
76
+ });
77
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"build.config.d.ts","sourceRoot":"","sources":["../../build.config.ts"],"names":[],"mappings":";AAGA,wBAGG"}
1
+ {"version":3,"file":"build.config.d.ts","sourceRoot":"","sources":["../../build.config.ts"],"names":[],"mappings":";AAGA,wBAAqC"}
@@ -0,0 +1 @@
1
+ export {}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AAQA,wBAmCG"}
1
+ {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AAgBA,wBAmCG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/nuxt",
3
- "version": "8.44.0",
3
+ "version": "8.45.1",
4
4
  "description": "Official Sentry SDK for Nuxt (EXPERIMENTAL)",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
@@ -43,23 +43,22 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@nuxt/kit": "^3.13.2",
46
- "@sentry/browser": "8.44.0",
47
- "@sentry/core": "8.44.0",
48
- "@sentry/node": "8.44.0",
49
- "@sentry/opentelemetry": "8.44.0",
46
+ "@sentry/browser": "8.45.1",
47
+ "@sentry/core": "8.45.1",
48
+ "@sentry/node": "8.45.1",
49
+ "@sentry/opentelemetry": "8.45.1",
50
50
  "@sentry/rollup-plugin": "2.22.7",
51
51
  "@sentry/vite-plugin": "2.22.6",
52
- "@sentry/vue": "8.44.0"
52
+ "@sentry/vue": "8.45.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@nuxt/module-builder": "^0.8.4",
56
- "@sentry-internal/nitro-utils": "8.44.0",
57
56
  "nuxt": "^3.13.2"
58
57
  },
59
58
  "scripts": {
60
59
  "build": "run-s build:types build:transpile",
61
60
  "build:dev": "yarn build",
62
- "build:nuxt-module": "nuxt-module-build build --outDir build/module",
61
+ "build:nuxt-module": "bash ./generate-build-stubs.bash && nuxt-module-build build --outDir build/module",
63
62
  "build:transpile": "rollup -c rollup.npm.config.mjs && yarn build:nuxt-module",
64
63
  "build:types": "tsc -p tsconfig.types.json",
65
64
  "build:watch": "run-p build:transpile:watch build:types:watch",
@@ -1,43 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const core = require('@sentry/core');
4
- const flush = require('../util/flush.js');
5
-
6
- /**
7
- * A helper to patch a given `h3` event handler, ensuring that
8
- * requests are properly isolated and data is flushed to Sentry.
9
- */
10
- function patchEventHandler(handler) {
11
- return new Proxy(handler, {
12
- async apply(handlerTarget, handlerThisArg, handlerArgs) {
13
- // In environments where we cannot make use of the OTel
14
- // http instrumentation (e.g. when using top level import
15
- // of the server instrumentation file instead of
16
- // `--import` or dynamic import, like on vercel)
17
- // we still need to ensure requests are properly isolated
18
- // by comparing the current isolation scope to the default
19
- // one.
20
- // Requests are properly isolated if they differ.
21
- // If that's not the case, we fork the isolation scope here.
22
- const isolationScope = core.getIsolationScope();
23
- const newIsolationScope = isolationScope === core.getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
24
-
25
- core.logger.log(
26
- `Patched h3 event handler. ${
27
- isolationScope === newIsolationScope ? 'Using existing' : 'Created new'
28
- } isolation scope.`,
29
- );
30
-
31
- return core.withIsolationScope(newIsolationScope, async () => {
32
- try {
33
- return await handlerTarget.apply(handlerThisArg, handlerArgs);
34
- } finally {
35
- await flush.flushIfServerless();
36
- }
37
- });
38
- },
39
- });
40
- }
41
-
42
- exports.patchEventHandler = patchEventHandler;
43
- //# sourceMappingURL=patchEventHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patchEventHandler.js","sources":["../../../../../../../../nitro-utils/build/esm/nitro/patchEventHandler.js"],"sourcesContent":["import { getIsolationScope, getDefaultIsolationScope, logger, withIsolationScope } from '@sentry/core';\nimport { flushIfServerless } from '../util/flush.js';\n\n/**\n * A helper to patch a given `h3` event handler, ensuring that\n * requests are properly isolated and data is flushed to Sentry.\n */\nfunction patchEventHandler(handler) {\n return new Proxy(handler, {\n async apply(handlerTarget, handlerThisArg, handlerArgs) {\n // In environments where we cannot make use of the OTel\n // http instrumentation (e.g. when using top level import\n // of the server instrumentation file instead of\n // `--import` or dynamic import, like on vercel)\n // we still need to ensure requests are properly isolated\n // by comparing the current isolation scope to the default\n // one.\n // Requests are properly isolated if they differ.\n // If that's not the case, we fork the isolation scope here.\n const isolationScope = getIsolationScope();\n const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;\n\n logger.log(\n `Patched h3 event handler. ${\n isolationScope === newIsolationScope ? 'Using existing' : 'Created new'\n } isolation scope.`,\n );\n\n return withIsolationScope(newIsolationScope, async () => {\n try {\n return await handlerTarget.apply(handlerThisArg, handlerArgs);\n } finally {\n await flushIfServerless();\n }\n });\n },\n });\n}\n\nexport { patchEventHandler };\n//# sourceMappingURL=patchEventHandler.js.map\n"],"names":["getIsolationScope","getDefaultIsolationScope","logger","withIsolationScope","flushIfServerless"],"mappings":";;;;;AAGA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,OAAO,EAAE;AACpC,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;AAC5B,IAAI,MAAM,KAAK,CAAC,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,MAAM,cAAA,GAAiBA,sBAAiB,EAAE;AAChD,MAAM,MAAM,iBAAA,GAAoB,cAAA,KAAmBC,6BAAwB,EAAG,GAAE,cAAc,CAAC,KAAK,EAAC,GAAI,cAAc;;AAEvH,MAAMC,WAAM,CAAC,GAAG;AAChB,QAAQ,CAAC,0BAA0B;AACnC,UAAU,cAAe,KAAI,iBAAkB,GAAE,mBAAmB;AACpE,SAAS,iBAAiB,CAAC;AAC3B,OAAO;;AAEP,MAAM,OAAOC,uBAAkB,CAAC,iBAAiB,EAAE,YAAY;AAC/D,QAAQ,IAAI;AACZ,UAAU,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;AACvE,kBAAkB;AAClB,UAAU,MAAMC,uBAAiB,EAAE;AACnC;AACA,OAAO,CAAC;AACR,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
@@ -1,36 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const core = require('@sentry/core');
4
-
5
- /**
6
- * Flushes Sentry for serverless environments.
7
- */
8
- async function flushIfServerless() {
9
- const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;
10
-
11
- // @ts-expect-error - this is not typed
12
- if (core.GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {
13
- core.vercelWaitUntil(flushWithTimeout());
14
- } else if (isServerless) {
15
- await flushWithTimeout();
16
- }
17
- }
18
-
19
- /**
20
- * Flushes Sentry.
21
- */
22
- async function flushWithTimeout() {
23
- const isDebug = core._optionalChain([core.getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'optionalAccess', _4 => _4.debug]);
24
-
25
- try {
26
- isDebug && core.logger.log('Flushing events...');
27
- await core.flush(2000);
28
- isDebug && core.logger.log('Done flushing events');
29
- } catch (e) {
30
- isDebug && core.logger.log('Error while flushing events:\n', e);
31
- }
32
- }
33
-
34
- exports.flushIfServerless = flushIfServerless;
35
- exports.flushWithTimeout = flushWithTimeout;
36
- //# sourceMappingURL=flush.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flush.js","sources":["../../../../../../../../nitro-utils/build/esm/util/flush.js"],"sourcesContent":["import { _optionalChain } from '@sentry/core';\nimport { GLOBAL_OBJ, vercelWaitUntil, logger, flush, getClient } from '@sentry/core';\n\n/**\n * Flushes Sentry for serverless environments.\n */\nasync function flushIfServerless() {\n const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;\n\n // @ts-expect-error - this is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n vercelWaitUntil(flushWithTimeout());\n } else if (isServerless) {\n await flushWithTimeout();\n }\n}\n\n/**\n * Flushes Sentry.\n */\nasync function flushWithTimeout() {\n const isDebug = _optionalChain([getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'optionalAccess', _4 => _4.debug]);\n\n try {\n isDebug && logger.log('Flushing events...');\n await flush(2000);\n isDebug && logger.log('Done flushing events');\n } catch (e) {\n isDebug && logger.log('Error while flushing events:\\n', e);\n }\n}\n\nexport { flushIfServerless, flushWithTimeout };\n//# sourceMappingURL=flush.js.map\n"],"names":["GLOBAL_OBJ","vercelWaitUntil","_optionalChain","getClient","logger","flush"],"mappings":";;;;AAGA;AACA;AACA;AACA,eAAe,iBAAiB,GAAG;AACnC,EAAE,MAAM,YAAa,GAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA,IAAoB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAO,IAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEtG;AACA,EAAE,IAAIA,eAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD,IAAIC,oBAAe,CAAC,gBAAgB,EAAE,CAAC;AACvC,GAAI,MAAK,IAAI,YAAY,EAAE;AAC3B,IAAI,MAAM,gBAAgB,EAAE;AAC5B;AACA;;AAEA;AACA;AACA;AACA,eAAe,gBAAgB,GAAG;AAClC,EAAE,MAAM,OAAQ,GAAEC,mBAAc,CAAC,CAACC,cAAS,EAAE,MAAM,EAAE,CAAA,IAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,EAAG,IAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAG,IAAG,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAG,IAAG,EAAE,CAAC,KAAK,CAAC,CAAC;;AAE5J,EAAE,IAAI;AACN,IAAI,WAAWC,WAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;AAC/C,IAAI,MAAMC,UAAK,CAAC,IAAI,CAAC;AACrB,IAAI,WAAWD,WAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACjD,GAAI,CAAA,OAAO,CAAC,EAAE;AACd,IAAI,OAAA,IAAWA,WAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAC9D;AACA;;;;;"}
@@ -1,55 +0,0 @@
1
- const core = require('@sentry/core');
2
- const vue = require('@sentry/vue');
3
- const app = require('nuxt/app');
4
- const utils = require('../utils.js');
5
-
6
- // --- Types are copied from @sentry/vue (so it does not need to be exported) ---
7
- // The following type is an intersection of the Route type from VueRouter v2, v3, and v4.
8
- // This is not great, but kinda necessary to make it work with all versions at the same time.
9
-
10
- const sentry_client = app.defineNuxtPlugin({
11
- name: 'sentry-client-integrations',
12
- dependsOn: ['sentry-client-config'],
13
- async setup(nuxtApp) {
14
- // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside
15
- // will get tree-shaken away
16
- if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
17
- const sentryClient = core.getClient();
18
-
19
- if (sentryClient && '$router' in nuxtApp) {
20
- sentryClient.addIntegration(
21
- vue.browserTracingIntegration({ router: nuxtApp.$router , routeLabel: 'path' }),
22
- );
23
- }
24
- }
25
-
26
- nuxtApp.hook('app:created', vueApp => {
27
- const sentryClient = core.getClient();
28
-
29
- if (sentryClient) {
30
- // Adding the Vue integration without the Vue error handler
31
- // Nuxt is registering their own error handler, which is unset after hydration: https://github.com/nuxt/nuxt/blob/d3fdbcaac6cf66d21e25d259390d7824696f1a87/packages/nuxt/src/app/entry.ts#L64-L73
32
- // We don't want to wrap the existing error handler, as it leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515
33
- sentryClient.addIntegration(
34
- vue.vueIntegration({
35
- // We pick up the options from the "fake" vueIntegration exported by the SDK.
36
- ...(core.GLOBAL_OBJ )._sentryNuxtVueIntegrationOptions,
37
- app: vueApp,
38
- attachErrorHandler: false,
39
- }),
40
- );
41
- }
42
- });
43
-
44
- nuxtApp.hook('app:error', error => {
45
- utils.reportNuxtError({ error });
46
- });
47
-
48
- nuxtApp.hook('vue:error', (error, instance, info) => {
49
- utils.reportNuxtError({ error, instance, info });
50
- });
51
- },
52
- });
53
-
54
- module.exports = sentry_client;
55
- //# sourceMappingURL=sentry.client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry.client.js","sources":["../../../../../../../src/runtime/plugins/sentry.client.ts"],"sourcesContent":["import { GLOBAL_OBJ, getClient } from '@sentry/core';\nimport { browserTracingIntegration, vueIntegration } from '@sentry/vue';\nimport { defineNuxtPlugin } from 'nuxt/app';\nimport type { GlobalObjWithIntegrationOptions } from '../../client/vueIntegration';\nimport { reportNuxtError } from '../utils';\n\n// --- Types are copied from @sentry/vue (so it does not need to be exported) ---\n// The following type is an intersection of the Route type from VueRouter v2, v3, and v4.\n// This is not great, but kinda necessary to make it work with all versions at the same time.\ntype Route = {\n /** Unparameterized URL */\n path: string;\n /**\n * Query params (keys map to null when there is no value associated, e.g. \"?foo\" and to an array when there are\n * multiple query params that have the same key, e.g. \"?foo&foo=bar\")\n */\n query: Record<string, string | null | (string | null)[]>;\n /** Route name (VueRouter provides a way to give routes individual names) */\n name?: string | symbol | null | undefined;\n /** Evaluated parameters */\n params: Record<string, string | string[]>;\n /** All the matched route objects as defined in VueRouter constructor */\n matched: { path: string }[];\n};\n\ninterface VueRouter {\n onError: (fn: (err: Error) => void) => void;\n beforeEach: (fn: (to: Route, from: Route, next?: () => void) => void) => void;\n}\n\n// Tree-shakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean;\n\nexport default defineNuxtPlugin({\n name: 'sentry-client-integrations',\n dependsOn: ['sentry-client-config'],\n async setup(nuxtApp) {\n // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with \"false\", in which case everything inside\n // will get tree-shaken away\n if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {\n const sentryClient = getClient();\n\n if (sentryClient && '$router' in nuxtApp) {\n sentryClient.addIntegration(\n browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }),\n );\n }\n }\n\n nuxtApp.hook('app:created', vueApp => {\n const sentryClient = getClient();\n\n if (sentryClient) {\n // Adding the Vue integration without the Vue error handler\n // Nuxt is registering their own error handler, which is unset after hydration: https://github.com/nuxt/nuxt/blob/d3fdbcaac6cf66d21e25d259390d7824696f1a87/packages/nuxt/src/app/entry.ts#L64-L73\n // We don't want to wrap the existing error handler, as it leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515\n sentryClient.addIntegration(\n vueIntegration({\n // We pick up the options from the \"fake\" vueIntegration exported by the SDK.\n ...(GLOBAL_OBJ as GlobalObjWithIntegrationOptions)._sentryNuxtVueIntegrationOptions,\n app: vueApp,\n attachErrorHandler: false,\n }),\n );\n }\n });\n\n nuxtApp.hook('app:error', error => {\n reportNuxtError({ error });\n });\n\n nuxtApp.hook('vue:error', (error, instance, info) => {\n reportNuxtError({ error, instance, info });\n });\n },\n});\n"],"names":["defineNuxtPlugin","getClient","browserTracingIntegration","vueIntegration","GLOBAL_OBJ","reportNuxtError"],"mappings":";;;;;AAMA;AACA;AACA;;AAyBA,sBAAeA,oBAAgB,CAAC;AAChC,EAAE,IAAI,EAAE,4BAA4B;AACpC,EAAE,SAAS,EAAE,CAAC,sBAAsB,CAAC;AACrC,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE;AACvB;AACA;AACA,IAAI,IAAI,OAAO,kBAAA,KAAuB,WAAY,IAAG,kBAAkB,EAAE;AACzE,MAAM,MAAM,YAAA,GAAeC,cAAS,EAAE;;AAEtC,MAAM,IAAI,YAAA,IAAgB,SAAU,IAAG,OAAO,EAAE;AAChD,QAAQ,YAAY,CAAC,cAAc;AACnC,UAAUC,6BAAyB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,OAAA,GAAsB,UAAU,EAAE,MAAA,EAAQ,CAAC;AACjG,SAAS;AACT;AACA;;AAEA,IAAI,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU;AAC1C,MAAM,MAAM,YAAA,GAAeD,cAAS,EAAE;;AAEtC,MAAM,IAAI,YAAY,EAAE;AACxB;AACA;AACA;AACA,QAAQ,YAAY,CAAC,cAAc;AACnC,UAAUE,kBAAc,CAAC;AACzB;AACA,YAAY,GAAG,CAACC,eAAW,GAAoC,gCAAgC;AAC/F,YAAY,GAAG,EAAE,MAAM;AACvB,YAAY,kBAAkB,EAAE,KAAK;AACrC,WAAW,CAAC;AACZ,SAAS;AACT;AACA,KAAK,CAAC;;AAEN,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS;AACvC,MAAMC,qBAAe,CAAC,EAAE,KAAA,EAAO,CAAC;AAChC,KAAK,CAAC;;AAEN,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,KAAK;AACzD,MAAMA,qBAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAK,EAAC,CAAC;AAChD,KAAK,CAAC;AACN,GAAG;AACH,CAAC,CAAC;;;;"}
@@ -1,70 +0,0 @@
1
- const core = require('@sentry/core');
2
- const Sentry = require('@sentry/node');
3
- const h3 = require('h3');
4
- const runtime = require('nitropack/runtime');
5
- const utils = require('../utils.js');
6
- const patchEventHandler = require('../../../../nitro-utils/build/esm/nitro/patchEventHandler.js');
7
-
8
- const sentry_server = runtime.defineNitroPlugin(nitroApp => {
9
- nitroApp.h3App.handler = patchEventHandler.patchEventHandler(nitroApp.h3App.handler);
10
-
11
- nitroApp.hooks.hook('error', async (error, errorContext) => {
12
- // Do not handle 404 and 422
13
- if (error instanceof h3.H3Error) {
14
- // Do not report if status code is 3xx or 4xx
15
- if (error.statusCode >= 300 && error.statusCode < 500) {
16
- return;
17
- }
18
- }
19
-
20
- const { method, path } = {
21
- method: errorContext.event && errorContext.event._method ? errorContext.event._method : '',
22
- path: errorContext.event && errorContext.event._path ? errorContext.event._path : null,
23
- };
24
-
25
- if (path) {
26
- Sentry.getCurrentScope().setTransactionName(`${method} ${path}`);
27
- }
28
-
29
- const structuredContext = utils.extractErrorContext(errorContext);
30
-
31
- Sentry.captureException(error, {
32
- captureContext: { contexts: { nuxt: structuredContext } },
33
- mechanism: { handled: false },
34
- });
35
-
36
- await flushIfServerless();
37
- });
38
-
39
- // @ts-expect-error - 'render:html' is a valid hook name in the Nuxt context
40
- nitroApp.hooks.hook('render:html', (html) => {
41
- utils.addSentryTracingMetaTags(html.head);
42
- });
43
- });
44
-
45
- async function flushIfServerless() {
46
- const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;
47
-
48
- // @ts-expect-error This is not typed
49
- if (core.GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {
50
- core.vercelWaitUntil(flushWithTimeout());
51
- } else if (isServerless) {
52
- await flushWithTimeout();
53
- }
54
- }
55
-
56
- async function flushWithTimeout() {
57
- const sentryClient = core.getClient();
58
- const isDebug = sentryClient ? sentryClient.getOptions().debug : false;
59
-
60
- try {
61
- isDebug && core.logger.log('Flushing events...');
62
- await core.flush(2000);
63
- isDebug && core.logger.log('Done flushing events');
64
- } catch (e) {
65
- isDebug && core.logger.log('Error while flushing events:\n', e);
66
- }
67
- }
68
-
69
- module.exports = sentry_server;
70
- //# sourceMappingURL=sentry.server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry.server.js","sources":["../../../../../../../src/runtime/plugins/sentry.server.ts"],"sourcesContent":["import { patchEventHandler } from '@sentry-internal/nitro-utils';\nimport { GLOBAL_OBJ, flush, getClient, logger, vercelWaitUntil } from '@sentry/core';\nimport * as Sentry from '@sentry/node';\nimport { H3Error } from 'h3';\nimport { defineNitroPlugin } from 'nitropack/runtime';\nimport type { NuxtRenderHTMLContext } from 'nuxt/app';\nimport { addSentryTracingMetaTags, extractErrorContext } from '../utils';\n\nexport default defineNitroPlugin(nitroApp => {\n nitroApp.h3App.handler = patchEventHandler(nitroApp.h3App.handler);\n\n nitroApp.hooks.hook('error', async (error, errorContext) => {\n // Do not handle 404 and 422\n if (error instanceof H3Error) {\n // Do not report if status code is 3xx or 4xx\n if (error.statusCode >= 300 && error.statusCode < 500) {\n return;\n }\n }\n\n const { method, path } = {\n method: errorContext.event && errorContext.event._method ? errorContext.event._method : '',\n path: errorContext.event && errorContext.event._path ? errorContext.event._path : null,\n };\n\n if (path) {\n Sentry.getCurrentScope().setTransactionName(`${method} ${path}`);\n }\n\n const structuredContext = extractErrorContext(errorContext);\n\n Sentry.captureException(error, {\n captureContext: { contexts: { nuxt: structuredContext } },\n mechanism: { handled: false },\n });\n\n await flushIfServerless();\n });\n\n // @ts-expect-error - 'render:html' is a valid hook name in the Nuxt context\n nitroApp.hooks.hook('render:html', (html: NuxtRenderHTMLContext) => {\n addSentryTracingMetaTags(html.head);\n });\n});\n\nasync function flushIfServerless(): Promise<void> {\n const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;\n\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n vercelWaitUntil(flushWithTimeout());\n } else if (isServerless) {\n await flushWithTimeout();\n }\n}\n\nasync function flushWithTimeout(): Promise<void> {\n const sentryClient = getClient();\n const isDebug = sentryClient ? sentryClient.getOptions().debug : false;\n\n try {\n isDebug && logger.log('Flushing events...');\n await flush(2000);\n isDebug && logger.log('Done flushing events');\n } catch (e) {\n isDebug && logger.log('Error while flushing events:\\n', e);\n }\n}\n"],"names":["defineNitroPlugin","patchEventHandler","H3Error","extractErrorContext","addSentryTracingMetaTags","GLOBAL_OBJ","vercelWaitUntil","getClient","logger","flush"],"mappings":";;;;;;;AAQA,sBAAeA,yBAAiB,CAAC,QAAA,IAAY;AAC7C,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAQ,GAAEC,mCAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;;AAEpE,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,EAAE,YAAY,KAAK;AAC9D;AACA,IAAI,IAAI,KAAM,YAAWC,UAAO,EAAE;AAClC;AACA,MAAM,IAAI,KAAK,CAAC,UAAW,IAAG,GAAI,IAAG,KAAK,CAAC,UAAW,GAAE,GAAG,EAAE;AAC7D,QAAQ;AACR;AACA;;AAEA,IAAI,MAAM,EAAE,MAAM,EAAE,IAAA,KAAS;AAC7B,MAAM,MAAM,EAAE,YAAY,CAAC,KAAM,IAAG,YAAY,CAAC,KAAK,CAAC,OAAA,GAAU,YAAY,CAAC,KAAK,CAAC,OAAA,GAAU,EAAE;AAChG,MAAM,IAAI,EAAE,YAAY,CAAC,KAAM,IAAG,YAAY,CAAC,KAAK,CAAC,KAAA,GAAQ,YAAY,CAAC,KAAK,CAAC,KAAA,GAAQ,IAAI;AAC5F,KAAK;;AAEL,IAAI,IAAI,IAAI,EAAE;AACd,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAA,MAAA,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA,IAAA,MAAA,iBAAA,GAAAC,yBAAA,CAAA,YAAA,CAAA;;AAEA,IAAA,MAAA,CAAA,gBAAA,CAAA,KAAA,EAAA;AACA,MAAA,cAAA,EAAA,EAAA,QAAA,EAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,EAAA;AACA,MAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA;AACA,KAAA,CAAA;;AAEA,IAAA,MAAA,iBAAA,EAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,QAAA,CAAA,KAAA,CAAA,IAAA,CAAA,aAAA,EAAA,CAAA,IAAA,KAAA;AACA,IAAAC,8BAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AACA,GAAA,CAAA;AACA,CAAA,CAAA;;AAEA,eAAA,iBAAA,GAAA;AACA,EAAA,MAAA,YAAA,GAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,gBAAA,IAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,IAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;AAEA;AACA,EAAA,IAAAC,eAAA,CAAA,MAAA,CAAA,GAAA,CAAA,yBAAA,CAAA,CAAA,EAAA;AACA,IAAAC,oBAAA,CAAA,gBAAA,EAAA,CAAA;AACA,GAAA,MAAA,IAAA,YAAA,EAAA;AACA,IAAA,MAAA,gBAAA,EAAA;AACA;AACA;;AAEA,eAAA,gBAAA,GAAA;AACA,EAAA,MAAA,YAAA,GAAAC,cAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,YAAA,GAAA,YAAA,CAAA,UAAA,EAAA,CAAA,KAAA,GAAA,KAAA;;AAEA,EAAA,IAAA;AACA,IAAA,OAAA,IAAAC,WAAA,CAAA,GAAA,CAAA,oBAAA,CAAA;AACA,IAAA,MAAAC,UAAA,CAAA,IAAA,CAAA;AACA,IAAA,OAAA,IAAAD,WAAA,CAAA,GAAA,CAAA,sBAAA,CAAA;AACA,GAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,IAAAA,WAAA,CAAA,GAAA,CAAA,gCAAA,EAAA,CAAA,CAAA;AACA;AACA;;;;"}
@@ -1,81 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const core = require('@sentry/core');
4
-
5
- /**
6
- * Extracts the relevant context information from the error context (H3Event in Nitro Error)
7
- * and created a structured context object.
8
- */
9
- function extractErrorContext(errorContext) {
10
- const structuredContext = {
11
- method: undefined,
12
- path: undefined,
13
- tags: undefined,
14
- };
15
-
16
- if (errorContext) {
17
- if (errorContext.event) {
18
- structuredContext.method = errorContext.event._method || undefined;
19
- structuredContext.path = errorContext.event._path || undefined;
20
- }
21
-
22
- if (Array.isArray(errorContext.tags)) {
23
- structuredContext.tags = errorContext.tags || undefined;
24
- }
25
- }
26
-
27
- return core.dropUndefinedKeys(structuredContext);
28
- }
29
-
30
- /**
31
- * Adds Sentry tracing <meta> tags to the returned html page.
32
- *
33
- * Exported only for testing
34
- */
35
- function addSentryTracingMetaTags(head) {
36
- const metaTags = core.getTraceMetaTags();
37
-
38
- if (metaTags) {
39
- head.push(metaTags);
40
- }
41
- }
42
-
43
- /**
44
- * Reports an error to Sentry. This function is similar to `attachErrorHandler` in `@sentry/vue`.
45
- * The Nuxt SDK does not register an error handler, but uses the Nuxt error hooks to report errors.
46
- *
47
- * We don't want to use the error handling from `@sentry/vue` as it wraps the existing error handler, which leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515
48
- */
49
- function reportNuxtError(options
50
-
51
- ) {
52
- const { error, instance, info } = options;
53
-
54
- const metadata = {
55
- info,
56
- // todo: add component name and trace (like in the vue integration)
57
- };
58
-
59
- if (instance && instance.$props) {
60
- const sentryClient = core.getClient();
61
- const sentryOptions = sentryClient ? (sentryClient.getOptions() ) : null;
62
-
63
- // `attachProps` is enabled by default and props should only not be attached if explicitly disabled (see DEFAULT_CONFIG in `vueIntegration`).
64
- if (sentryOptions && sentryOptions.attachProps && instance.$props !== false) {
65
- metadata.propsData = instance.$props;
66
- }
67
- }
68
-
69
- // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.
70
- setTimeout(() => {
71
- core.captureException(error, {
72
- captureContext: { contexts: { nuxt: metadata } },
73
- mechanism: { handled: false },
74
- });
75
- });
76
- }
77
-
78
- exports.addSentryTracingMetaTags = addSentryTracingMetaTags;
79
- exports.extractErrorContext = extractErrorContext;
80
- exports.reportNuxtError = reportNuxtError;
81
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/runtime/utils.ts"],"sourcesContent":["import type { ClientOptions, Context } from '@sentry/core';\nimport { captureException, dropUndefinedKeys, getClient, getTraceMetaTags } from '@sentry/core';\nimport type { VueOptions } from '@sentry/vue/src/types';\nimport type { CapturedErrorContext } from 'nitropack';\nimport type { NuxtRenderHTMLContext } from 'nuxt/app';\nimport type { ComponentPublicInstance } from 'vue';\n\n/**\n * Extracts the relevant context information from the error context (H3Event in Nitro Error)\n * and created a structured context object.\n */\nexport function extractErrorContext(errorContext: CapturedErrorContext): Context {\n const structuredContext: Context = {\n method: undefined,\n path: undefined,\n tags: undefined,\n };\n\n if (errorContext) {\n if (errorContext.event) {\n structuredContext.method = errorContext.event._method || undefined;\n structuredContext.path = errorContext.event._path || undefined;\n }\n\n if (Array.isArray(errorContext.tags)) {\n structuredContext.tags = errorContext.tags || undefined;\n }\n }\n\n return dropUndefinedKeys(structuredContext);\n}\n\n/**\n * Adds Sentry tracing <meta> tags to the returned html page.\n *\n * Exported only for testing\n */\nexport function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head']): void {\n const metaTags = getTraceMetaTags();\n\n if (metaTags) {\n head.push(metaTags);\n }\n}\n\n/**\n * Reports an error to Sentry. This function is similar to `attachErrorHandler` in `@sentry/vue`.\n * The Nuxt SDK does not register an error handler, but uses the Nuxt error hooks to report errors.\n *\n * We don't want to use the error handling from `@sentry/vue` as it wraps the existing error handler, which leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515\n */\nexport function reportNuxtError(options: {\n error: unknown;\n instance?: ComponentPublicInstance | null;\n info?: string;\n}): void {\n const { error, instance, info } = options;\n\n const metadata: Record<string, unknown> = {\n info,\n // todo: add component name and trace (like in the vue integration)\n };\n\n if (instance && instance.$props) {\n const sentryClient = getClient();\n const sentryOptions = sentryClient ? (sentryClient.getOptions() as ClientOptions & VueOptions) : null;\n\n // `attachProps` is enabled by default and props should only not be attached if explicitly disabled (see DEFAULT_CONFIG in `vueIntegration`).\n if (sentryOptions && sentryOptions.attachProps && instance.$props !== false) {\n metadata.propsData = instance.$props;\n }\n }\n\n // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.\n setTimeout(() => {\n captureException(error, {\n captureContext: { contexts: { nuxt: metadata } },\n mechanism: { handled: false },\n });\n });\n}\n"],"names":["dropUndefinedKeys","getTraceMetaTags","getClient","captureException"],"mappings":";;;;AAOA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,YAAY,EAAiC;AACjF,EAAE,MAAM,iBAAiB,GAAY;AACrC,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,IAAI,EAAE,SAAS;AACnB,IAAI,IAAI,EAAE,SAAS;AACnB,GAAG;;AAEH,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE;AAC5B,MAAM,iBAAiB,CAAC,MAAA,GAAS,YAAY,CAAC,KAAK,CAAC,OAAQ,IAAG,SAAS;AACxE,MAAM,iBAAiB,CAAC,IAAA,GAAO,YAAY,CAAC,KAAK,CAAC,KAAM,IAAG,SAAS;AACpE;;AAEA,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;AAC1C,MAAM,iBAAiB,CAAC,IAAK,GAAE,YAAY,CAAC,IAAA,IAAQ,SAAS;AAC7D;AACA;;AAEA,EAAE,OAAOA,sBAAiB,CAAC,iBAAiB,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,IAAI,EAAuC;AACpF,EAAE,MAAM,QAAA,GAAWC,qBAAgB,EAAE;;AAErC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACvB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC;;AAIhC,EAAS;AACT,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAA,EAAO,GAAE,OAAO;;AAE3C,EAAE,MAAM,QAAQ,GAA4B;AAC5C,IAAI,IAAI;AACR;AACA,GAAG;;AAEH,EAAE,IAAI,QAAA,IAAY,QAAQ,CAAC,MAAM,EAAE;AACnC,IAAI,MAAM,YAAA,GAAeC,cAAS,EAAE;AACpC,IAAI,MAAM,aAAA,GAAgB,YAAA,IAAgB,YAAY,CAAC,UAAU,EAAG,KAAiC,IAAI;;AAEzG;AACA,IAAI,IAAI,aAAc,IAAG,aAAa,CAAC,WAAY,IAAG,QAAQ,CAAC,MAAO,KAAI,KAAK,EAAE;AACjF,MAAM,QAAQ,CAAC,SAAA,GAAY,QAAQ,CAAC,MAAM;AAC1C;AACA;;AAEA;AACA,EAAE,UAAU,CAAC,MAAM;AACnB,IAAIC,qBAAgB,CAAC,KAAK,EAAE;AAC5B,MAAM,cAAc,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAS,EAAA,EAAG;AACtD,MAAM,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO;AACnC,KAAK,CAAC;AACN,GAAG,CAAC;AACJ;;;;;;"}
@@ -1,41 +0,0 @@
1
- import { getIsolationScope, getDefaultIsolationScope, logger, withIsolationScope } from '@sentry/core';
2
- import { flushIfServerless } from '../util/flush.js';
3
-
4
- /**
5
- * A helper to patch a given `h3` event handler, ensuring that
6
- * requests are properly isolated and data is flushed to Sentry.
7
- */
8
- function patchEventHandler(handler) {
9
- return new Proxy(handler, {
10
- async apply(handlerTarget, handlerThisArg, handlerArgs) {
11
- // In environments where we cannot make use of the OTel
12
- // http instrumentation (e.g. when using top level import
13
- // of the server instrumentation file instead of
14
- // `--import` or dynamic import, like on vercel)
15
- // we still need to ensure requests are properly isolated
16
- // by comparing the current isolation scope to the default
17
- // one.
18
- // Requests are properly isolated if they differ.
19
- // If that's not the case, we fork the isolation scope here.
20
- const isolationScope = getIsolationScope();
21
- const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
22
-
23
- logger.log(
24
- `Patched h3 event handler. ${
25
- isolationScope === newIsolationScope ? 'Using existing' : 'Created new'
26
- } isolation scope.`,
27
- );
28
-
29
- return withIsolationScope(newIsolationScope, async () => {
30
- try {
31
- return await handlerTarget.apply(handlerThisArg, handlerArgs);
32
- } finally {
33
- await flushIfServerless();
34
- }
35
- });
36
- },
37
- });
38
- }
39
-
40
- export { patchEventHandler };
41
- //# sourceMappingURL=patchEventHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"patchEventHandler.js","sources":["../../../../../../../../nitro-utils/build/esm/nitro/patchEventHandler.js"],"sourcesContent":["import { getIsolationScope, getDefaultIsolationScope, logger, withIsolationScope } from '@sentry/core';\nimport { flushIfServerless } from '../util/flush.js';\n\n/**\n * A helper to patch a given `h3` event handler, ensuring that\n * requests are properly isolated and data is flushed to Sentry.\n */\nfunction patchEventHandler(handler) {\n return new Proxy(handler, {\n async apply(handlerTarget, handlerThisArg, handlerArgs) {\n // In environments where we cannot make use of the OTel\n // http instrumentation (e.g. when using top level import\n // of the server instrumentation file instead of\n // `--import` or dynamic import, like on vercel)\n // we still need to ensure requests are properly isolated\n // by comparing the current isolation scope to the default\n // one.\n // Requests are properly isolated if they differ.\n // If that's not the case, we fork the isolation scope here.\n const isolationScope = getIsolationScope();\n const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;\n\n logger.log(\n `Patched h3 event handler. ${\n isolationScope === newIsolationScope ? 'Using existing' : 'Created new'\n } isolation scope.`,\n );\n\n return withIsolationScope(newIsolationScope, async () => {\n try {\n return await handlerTarget.apply(handlerThisArg, handlerArgs);\n } finally {\n await flushIfServerless();\n }\n });\n },\n });\n}\n\nexport { patchEventHandler };\n//# sourceMappingURL=patchEventHandler.js.map\n"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;AACA,SAAS,iBAAiB,CAAC,OAAO,EAAE;AACpC,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;AAC5B,IAAI,MAAM,KAAK,CAAC,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,MAAM,cAAA,GAAiB,iBAAiB,EAAE;AAChD,MAAM,MAAM,iBAAA,GAAoB,cAAA,KAAmB,wBAAwB,EAAG,GAAE,cAAc,CAAC,KAAK,EAAC,GAAI,cAAc;;AAEvH,MAAM,MAAM,CAAC,GAAG;AAChB,QAAQ,CAAC,0BAA0B;AACnC,UAAU,cAAe,KAAI,iBAAkB,GAAE,mBAAmB;AACpE,SAAS,iBAAiB,CAAC;AAC3B,OAAO;;AAEP,MAAM,OAAO,kBAAkB,CAAC,iBAAiB,EAAE,YAAY;AAC/D,QAAQ,IAAI;AACZ,UAAU,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;AACvE,kBAAkB;AAClB,UAAU,MAAM,iBAAiB,EAAE;AACnC;AACA,OAAO,CAAC;AACR,KAAK;AACL,GAAG,CAAC;AACJ;;;;"}
@@ -1,33 +0,0 @@
1
- import { GLOBAL_OBJ, vercelWaitUntil, _optionalChain, getClient, logger, flush } from '@sentry/core';
2
-
3
- /**
4
- * Flushes Sentry for serverless environments.
5
- */
6
- async function flushIfServerless() {
7
- const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;
8
-
9
- // @ts-expect-error - this is not typed
10
- if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {
11
- vercelWaitUntil(flushWithTimeout());
12
- } else if (isServerless) {
13
- await flushWithTimeout();
14
- }
15
- }
16
-
17
- /**
18
- * Flushes Sentry.
19
- */
20
- async function flushWithTimeout() {
21
- const isDebug = _optionalChain([getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'optionalAccess', _4 => _4.debug]);
22
-
23
- try {
24
- isDebug && logger.log('Flushing events...');
25
- await flush(2000);
26
- isDebug && logger.log('Done flushing events');
27
- } catch (e) {
28
- isDebug && logger.log('Error while flushing events:\n', e);
29
- }
30
- }
31
-
32
- export { flushIfServerless, flushWithTimeout };
33
- //# sourceMappingURL=flush.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flush.js","sources":["../../../../../../../../nitro-utils/build/esm/util/flush.js"],"sourcesContent":["import { _optionalChain } from '@sentry/core';\nimport { GLOBAL_OBJ, vercelWaitUntil, logger, flush, getClient } from '@sentry/core';\n\n/**\n * Flushes Sentry for serverless environments.\n */\nasync function flushIfServerless() {\n const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;\n\n // @ts-expect-error - this is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n vercelWaitUntil(flushWithTimeout());\n } else if (isServerless) {\n await flushWithTimeout();\n }\n}\n\n/**\n * Flushes Sentry.\n */\nasync function flushWithTimeout() {\n const isDebug = _optionalChain([getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'optionalAccess', _4 => _4.debug]);\n\n try {\n isDebug && logger.log('Flushing events...');\n await flush(2000);\n isDebug && logger.log('Done flushing events');\n } catch (e) {\n isDebug && logger.log('Error while flushing events:\\n', e);\n }\n}\n\nexport { flushIfServerless, flushWithTimeout };\n//# sourceMappingURL=flush.js.map\n"],"names":[],"mappings":";;AAGA;AACA;AACA;AACA,eAAe,iBAAiB,GAAG;AACnC,EAAE,MAAM,YAAa,GAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAA,IAAoB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAO,IAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO;;AAEtG;AACA,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,EAAE;AACzD,IAAI,eAAe,CAAC,gBAAgB,EAAE,CAAC;AACvC,GAAI,MAAK,IAAI,YAAY,EAAE;AAC3B,IAAI,MAAM,gBAAgB,EAAE;AAC5B;AACA;;AAEA;AACA;AACA;AACA,eAAe,gBAAgB,GAAG;AAClC,EAAE,MAAM,OAAQ,GAAE,cAAc,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,CAAA,IAAK,CAAC,EAAE,EAAE,gBAAgB,EAAE,EAAG,IAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,EAAG,IAAG,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAG,IAAG,EAAE,CAAC,KAAK,CAAC,CAAC;;AAE5J,EAAE,IAAI;AACN,IAAI,WAAW,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;AAC/C,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC;AACrB,IAAI,WAAW,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC;AACjD,GAAI,CAAA,OAAO,CAAC,EAAE;AACd,IAAI,OAAA,IAAW,MAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC;AAC9D;AACA;;;;"}
@@ -1,55 +0,0 @@
1
- import { getClient, GLOBAL_OBJ } from '@sentry/core';
2
- import { browserTracingIntegration, vueIntegration } from '@sentry/vue';
3
- import { defineNuxtPlugin } from 'nuxt/app';
4
- import { reportNuxtError } from '../utils.js';
5
-
6
- // --- Types are copied from @sentry/vue (so it does not need to be exported) ---
7
- // The following type is an intersection of the Route type from VueRouter v2, v3, and v4.
8
- // This is not great, but kinda necessary to make it work with all versions at the same time.
9
-
10
- const sentry_client = defineNuxtPlugin({
11
- name: 'sentry-client-integrations',
12
- dependsOn: ['sentry-client-config'],
13
- async setup(nuxtApp) {
14
- // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside
15
- // will get tree-shaken away
16
- if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
17
- const sentryClient = getClient();
18
-
19
- if (sentryClient && '$router' in nuxtApp) {
20
- sentryClient.addIntegration(
21
- browserTracingIntegration({ router: nuxtApp.$router , routeLabel: 'path' }),
22
- );
23
- }
24
- }
25
-
26
- nuxtApp.hook('app:created', vueApp => {
27
- const sentryClient = getClient();
28
-
29
- if (sentryClient) {
30
- // Adding the Vue integration without the Vue error handler
31
- // Nuxt is registering their own error handler, which is unset after hydration: https://github.com/nuxt/nuxt/blob/d3fdbcaac6cf66d21e25d259390d7824696f1a87/packages/nuxt/src/app/entry.ts#L64-L73
32
- // We don't want to wrap the existing error handler, as it leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515
33
- sentryClient.addIntegration(
34
- vueIntegration({
35
- // We pick up the options from the "fake" vueIntegration exported by the SDK.
36
- ...(GLOBAL_OBJ )._sentryNuxtVueIntegrationOptions,
37
- app: vueApp,
38
- attachErrorHandler: false,
39
- }),
40
- );
41
- }
42
- });
43
-
44
- nuxtApp.hook('app:error', error => {
45
- reportNuxtError({ error });
46
- });
47
-
48
- nuxtApp.hook('vue:error', (error, instance, info) => {
49
- reportNuxtError({ error, instance, info });
50
- });
51
- },
52
- });
53
-
54
- export { sentry_client as default };
55
- //# sourceMappingURL=sentry.client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry.client.js","sources":["../../../../../../../src/runtime/plugins/sentry.client.ts"],"sourcesContent":["import { GLOBAL_OBJ, getClient } from '@sentry/core';\nimport { browserTracingIntegration, vueIntegration } from '@sentry/vue';\nimport { defineNuxtPlugin } from 'nuxt/app';\nimport type { GlobalObjWithIntegrationOptions } from '../../client/vueIntegration';\nimport { reportNuxtError } from '../utils';\n\n// --- Types are copied from @sentry/vue (so it does not need to be exported) ---\n// The following type is an intersection of the Route type from VueRouter v2, v3, and v4.\n// This is not great, but kinda necessary to make it work with all versions at the same time.\ntype Route = {\n /** Unparameterized URL */\n path: string;\n /**\n * Query params (keys map to null when there is no value associated, e.g. \"?foo\" and to an array when there are\n * multiple query params that have the same key, e.g. \"?foo&foo=bar\")\n */\n query: Record<string, string | null | (string | null)[]>;\n /** Route name (VueRouter provides a way to give routes individual names) */\n name?: string | symbol | null | undefined;\n /** Evaluated parameters */\n params: Record<string, string | string[]>;\n /** All the matched route objects as defined in VueRouter constructor */\n matched: { path: string }[];\n};\n\ninterface VueRouter {\n onError: (fn: (err: Error) => void) => void;\n beforeEach: (fn: (to: Route, from: Route, next?: () => void) => void) => void;\n}\n\n// Tree-shakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean;\n\nexport default defineNuxtPlugin({\n name: 'sentry-client-integrations',\n dependsOn: ['sentry-client-config'],\n async setup(nuxtApp) {\n // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with \"false\", in which case everything inside\n // will get tree-shaken away\n if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {\n const sentryClient = getClient();\n\n if (sentryClient && '$router' in nuxtApp) {\n sentryClient.addIntegration(\n browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }),\n );\n }\n }\n\n nuxtApp.hook('app:created', vueApp => {\n const sentryClient = getClient();\n\n if (sentryClient) {\n // Adding the Vue integration without the Vue error handler\n // Nuxt is registering their own error handler, which is unset after hydration: https://github.com/nuxt/nuxt/blob/d3fdbcaac6cf66d21e25d259390d7824696f1a87/packages/nuxt/src/app/entry.ts#L64-L73\n // We don't want to wrap the existing error handler, as it leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515\n sentryClient.addIntegration(\n vueIntegration({\n // We pick up the options from the \"fake\" vueIntegration exported by the SDK.\n ...(GLOBAL_OBJ as GlobalObjWithIntegrationOptions)._sentryNuxtVueIntegrationOptions,\n app: vueApp,\n attachErrorHandler: false,\n }),\n );\n }\n });\n\n nuxtApp.hook('app:error', error => {\n reportNuxtError({ error });\n });\n\n nuxtApp.hook('vue:error', (error, instance, info) => {\n reportNuxtError({ error, instance, info });\n });\n },\n});\n"],"names":[],"mappings":";;;;;AAMA;AACA;AACA;;AAyBA,sBAAe,gBAAgB,CAAC;AAChC,EAAE,IAAI,EAAE,4BAA4B;AACpC,EAAE,SAAS,EAAE,CAAC,sBAAsB,CAAC;AACrC,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE;AACvB;AACA;AACA,IAAI,IAAI,OAAO,kBAAA,KAAuB,WAAY,IAAG,kBAAkB,EAAE;AACzE,MAAM,MAAM,YAAA,GAAe,SAAS,EAAE;;AAEtC,MAAM,IAAI,YAAA,IAAgB,SAAU,IAAG,OAAO,EAAE;AAChD,QAAQ,YAAY,CAAC,cAAc;AACnC,UAAU,yBAAyB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,OAAA,GAAsB,UAAU,EAAE,MAAA,EAAQ,CAAC;AACjG,SAAS;AACT;AACA;;AAEA,IAAI,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU;AAC1C,MAAM,MAAM,YAAA,GAAe,SAAS,EAAE;;AAEtC,MAAM,IAAI,YAAY,EAAE;AACxB;AACA;AACA;AACA,QAAQ,YAAY,CAAC,cAAc;AACnC,UAAU,cAAc,CAAC;AACzB;AACA,YAAY,GAAG,CAAC,UAAW,GAAoC,gCAAgC;AAC/F,YAAY,GAAG,EAAE,MAAM;AACvB,YAAY,kBAAkB,EAAE,KAAK;AACrC,WAAW,CAAC;AACZ,SAAS;AACT;AACA,KAAK,CAAC;;AAEN,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS;AACvC,MAAM,eAAe,CAAC,EAAE,KAAA,EAAO,CAAC;AAChC,KAAK,CAAC;;AAEN,IAAI,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,KAAK;AACzD,MAAM,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAK,EAAC,CAAC;AAChD,KAAK,CAAC;AACN,GAAG;AACH,CAAC,CAAC;;;;"}
@@ -1,70 +0,0 @@
1
- import { GLOBAL_OBJ, vercelWaitUntil, getClient, logger, flush } from '@sentry/core';
2
- import * as Sentry from '@sentry/node';
3
- import { H3Error } from 'h3';
4
- import { defineNitroPlugin } from 'nitropack/runtime';
5
- import { extractErrorContext, addSentryTracingMetaTags } from '../utils.js';
6
- import { patchEventHandler } from '../../../../nitro-utils/build/esm/nitro/patchEventHandler.js';
7
-
8
- const sentry_server = defineNitroPlugin(nitroApp => {
9
- nitroApp.h3App.handler = patchEventHandler(nitroApp.h3App.handler);
10
-
11
- nitroApp.hooks.hook('error', async (error, errorContext) => {
12
- // Do not handle 404 and 422
13
- if (error instanceof H3Error) {
14
- // Do not report if status code is 3xx or 4xx
15
- if (error.statusCode >= 300 && error.statusCode < 500) {
16
- return;
17
- }
18
- }
19
-
20
- const { method, path } = {
21
- method: errorContext.event && errorContext.event._method ? errorContext.event._method : '',
22
- path: errorContext.event && errorContext.event._path ? errorContext.event._path : null,
23
- };
24
-
25
- if (path) {
26
- Sentry.getCurrentScope().setTransactionName(`${method} ${path}`);
27
- }
28
-
29
- const structuredContext = extractErrorContext(errorContext);
30
-
31
- Sentry.captureException(error, {
32
- captureContext: { contexts: { nuxt: structuredContext } },
33
- mechanism: { handled: false },
34
- });
35
-
36
- await flushIfServerless();
37
- });
38
-
39
- // @ts-expect-error - 'render:html' is a valid hook name in the Nuxt context
40
- nitroApp.hooks.hook('render:html', (html) => {
41
- addSentryTracingMetaTags(html.head);
42
- });
43
- });
44
-
45
- async function flushIfServerless() {
46
- const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;
47
-
48
- // @ts-expect-error This is not typed
49
- if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {
50
- vercelWaitUntil(flushWithTimeout());
51
- } else if (isServerless) {
52
- await flushWithTimeout();
53
- }
54
- }
55
-
56
- async function flushWithTimeout() {
57
- const sentryClient = getClient();
58
- const isDebug = sentryClient ? sentryClient.getOptions().debug : false;
59
-
60
- try {
61
- isDebug && logger.log('Flushing events...');
62
- await flush(2000);
63
- isDebug && logger.log('Done flushing events');
64
- } catch (e) {
65
- isDebug && logger.log('Error while flushing events:\n', e);
66
- }
67
- }
68
-
69
- export { sentry_server as default };
70
- //# sourceMappingURL=sentry.server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentry.server.js","sources":["../../../../../../../src/runtime/plugins/sentry.server.ts"],"sourcesContent":["import { patchEventHandler } from '@sentry-internal/nitro-utils';\nimport { GLOBAL_OBJ, flush, getClient, logger, vercelWaitUntil } from '@sentry/core';\nimport * as Sentry from '@sentry/node';\nimport { H3Error } from 'h3';\nimport { defineNitroPlugin } from 'nitropack/runtime';\nimport type { NuxtRenderHTMLContext } from 'nuxt/app';\nimport { addSentryTracingMetaTags, extractErrorContext } from '../utils';\n\nexport default defineNitroPlugin(nitroApp => {\n nitroApp.h3App.handler = patchEventHandler(nitroApp.h3App.handler);\n\n nitroApp.hooks.hook('error', async (error, errorContext) => {\n // Do not handle 404 and 422\n if (error instanceof H3Error) {\n // Do not report if status code is 3xx or 4xx\n if (error.statusCode >= 300 && error.statusCode < 500) {\n return;\n }\n }\n\n const { method, path } = {\n method: errorContext.event && errorContext.event._method ? errorContext.event._method : '',\n path: errorContext.event && errorContext.event._path ? errorContext.event._path : null,\n };\n\n if (path) {\n Sentry.getCurrentScope().setTransactionName(`${method} ${path}`);\n }\n\n const structuredContext = extractErrorContext(errorContext);\n\n Sentry.captureException(error, {\n captureContext: { contexts: { nuxt: structuredContext } },\n mechanism: { handled: false },\n });\n\n await flushIfServerless();\n });\n\n // @ts-expect-error - 'render:html' is a valid hook name in the Nuxt context\n nitroApp.hooks.hook('render:html', (html: NuxtRenderHTMLContext) => {\n addSentryTracingMetaTags(html.head);\n });\n});\n\nasync function flushIfServerless(): Promise<void> {\n const isServerless = !!process.env.LAMBDA_TASK_ROOT || !!process.env.VERCEL || !!process.env.NETLIFY;\n\n // @ts-expect-error This is not typed\n if (GLOBAL_OBJ[Symbol.for('@vercel/request-context')]) {\n vercelWaitUntil(flushWithTimeout());\n } else if (isServerless) {\n await flushWithTimeout();\n }\n}\n\nasync function flushWithTimeout(): Promise<void> {\n const sentryClient = getClient();\n const isDebug = sentryClient ? sentryClient.getOptions().debug : false;\n\n try {\n isDebug && logger.log('Flushing events...');\n await flush(2000);\n isDebug && logger.log('Done flushing events');\n } catch (e) {\n isDebug && logger.log('Error while flushing events:\\n', e);\n }\n}\n"],"names":[],"mappings":";;;;;;;AAQA,sBAAe,iBAAiB,CAAC,QAAA,IAAY;AAC7C,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAQ,GAAE,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;;AAEpE,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,EAAE,YAAY,KAAK;AAC9D;AACA,IAAI,IAAI,KAAM,YAAW,OAAO,EAAE;AAClC;AACA,MAAM,IAAI,KAAK,CAAC,UAAW,IAAG,GAAI,IAAG,KAAK,CAAC,UAAW,GAAE,GAAG,EAAE;AAC7D,QAAQ;AACR;AACA;;AAEA,IAAI,MAAM,EAAE,MAAM,EAAE,IAAA,KAAS;AAC7B,MAAM,MAAM,EAAE,YAAY,CAAC,KAAM,IAAG,YAAY,CAAC,KAAK,CAAC,OAAA,GAAU,YAAY,CAAC,KAAK,CAAC,OAAA,GAAU,EAAE;AAChG,MAAM,IAAI,EAAE,YAAY,CAAC,KAAM,IAAG,YAAY,CAAC,KAAK,CAAC,KAAA,GAAQ,YAAY,CAAC,KAAK,CAAC,KAAA,GAAQ,IAAI;AAC5F,KAAK;;AAEL,IAAI,IAAI,IAAI,EAAE;AACd,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAA,MAAA,CAAA,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA;AACA;;AAEA,IAAA,MAAA,iBAAA,GAAA,mBAAA,CAAA,YAAA,CAAA;;AAEA,IAAA,MAAA,CAAA,gBAAA,CAAA,KAAA,EAAA;AACA,MAAA,cAAA,EAAA,EAAA,QAAA,EAAA,EAAA,IAAA,EAAA,iBAAA,EAAA,EAAA;AACA,MAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA;AACA,KAAA,CAAA;;AAEA,IAAA,MAAA,iBAAA,EAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,QAAA,CAAA,KAAA,CAAA,IAAA,CAAA,aAAA,EAAA,CAAA,IAAA,KAAA;AACA,IAAA,wBAAA,CAAA,IAAA,CAAA,IAAA,CAAA;AACA,GAAA,CAAA;AACA,CAAA,CAAA;;AAEA,eAAA,iBAAA,GAAA;AACA,EAAA,MAAA,YAAA,GAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,gBAAA,IAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,MAAA,IAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,OAAA;;AAEA;AACA,EAAA,IAAA,UAAA,CAAA,MAAA,CAAA,GAAA,CAAA,yBAAA,CAAA,CAAA,EAAA;AACA,IAAA,eAAA,CAAA,gBAAA,EAAA,CAAA;AACA,GAAA,MAAA,IAAA,YAAA,EAAA;AACA,IAAA,MAAA,gBAAA,EAAA;AACA;AACA;;AAEA,eAAA,gBAAA,GAAA;AACA,EAAA,MAAA,YAAA,GAAA,SAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,YAAA,GAAA,YAAA,CAAA,UAAA,EAAA,CAAA,KAAA,GAAA,KAAA;;AAEA,EAAA,IAAA;AACA,IAAA,OAAA,IAAA,MAAA,CAAA,GAAA,CAAA,oBAAA,CAAA;AACA,IAAA,MAAA,KAAA,CAAA,IAAA,CAAA;AACA,IAAA,OAAA,IAAA,MAAA,CAAA,GAAA,CAAA,sBAAA,CAAA;AACA,GAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,IAAA,MAAA,CAAA,GAAA,CAAA,gCAAA,EAAA,CAAA,CAAA;AACA;AACA;;;;"}
@@ -1,77 +0,0 @@
1
- import { dropUndefinedKeys, getTraceMetaTags, getClient, captureException } from '@sentry/core';
2
-
3
- /**
4
- * Extracts the relevant context information from the error context (H3Event in Nitro Error)
5
- * and created a structured context object.
6
- */
7
- function extractErrorContext(errorContext) {
8
- const structuredContext = {
9
- method: undefined,
10
- path: undefined,
11
- tags: undefined,
12
- };
13
-
14
- if (errorContext) {
15
- if (errorContext.event) {
16
- structuredContext.method = errorContext.event._method || undefined;
17
- structuredContext.path = errorContext.event._path || undefined;
18
- }
19
-
20
- if (Array.isArray(errorContext.tags)) {
21
- structuredContext.tags = errorContext.tags || undefined;
22
- }
23
- }
24
-
25
- return dropUndefinedKeys(structuredContext);
26
- }
27
-
28
- /**
29
- * Adds Sentry tracing <meta> tags to the returned html page.
30
- *
31
- * Exported only for testing
32
- */
33
- function addSentryTracingMetaTags(head) {
34
- const metaTags = getTraceMetaTags();
35
-
36
- if (metaTags) {
37
- head.push(metaTags);
38
- }
39
- }
40
-
41
- /**
42
- * Reports an error to Sentry. This function is similar to `attachErrorHandler` in `@sentry/vue`.
43
- * The Nuxt SDK does not register an error handler, but uses the Nuxt error hooks to report errors.
44
- *
45
- * We don't want to use the error handling from `@sentry/vue` as it wraps the existing error handler, which leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515
46
- */
47
- function reportNuxtError(options
48
-
49
- ) {
50
- const { error, instance, info } = options;
51
-
52
- const metadata = {
53
- info,
54
- // todo: add component name and trace (like in the vue integration)
55
- };
56
-
57
- if (instance && instance.$props) {
58
- const sentryClient = getClient();
59
- const sentryOptions = sentryClient ? (sentryClient.getOptions() ) : null;
60
-
61
- // `attachProps` is enabled by default and props should only not be attached if explicitly disabled (see DEFAULT_CONFIG in `vueIntegration`).
62
- if (sentryOptions && sentryOptions.attachProps && instance.$props !== false) {
63
- metadata.propsData = instance.$props;
64
- }
65
- }
66
-
67
- // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.
68
- setTimeout(() => {
69
- captureException(error, {
70
- captureContext: { contexts: { nuxt: metadata } },
71
- mechanism: { handled: false },
72
- });
73
- });
74
- }
75
-
76
- export { addSentryTracingMetaTags, extractErrorContext, reportNuxtError };
77
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../../src/runtime/utils.ts"],"sourcesContent":["import type { ClientOptions, Context } from '@sentry/core';\nimport { captureException, dropUndefinedKeys, getClient, getTraceMetaTags } from '@sentry/core';\nimport type { VueOptions } from '@sentry/vue/src/types';\nimport type { CapturedErrorContext } from 'nitropack';\nimport type { NuxtRenderHTMLContext } from 'nuxt/app';\nimport type { ComponentPublicInstance } from 'vue';\n\n/**\n * Extracts the relevant context information from the error context (H3Event in Nitro Error)\n * and created a structured context object.\n */\nexport function extractErrorContext(errorContext: CapturedErrorContext): Context {\n const structuredContext: Context = {\n method: undefined,\n path: undefined,\n tags: undefined,\n };\n\n if (errorContext) {\n if (errorContext.event) {\n structuredContext.method = errorContext.event._method || undefined;\n structuredContext.path = errorContext.event._path || undefined;\n }\n\n if (Array.isArray(errorContext.tags)) {\n structuredContext.tags = errorContext.tags || undefined;\n }\n }\n\n return dropUndefinedKeys(structuredContext);\n}\n\n/**\n * Adds Sentry tracing <meta> tags to the returned html page.\n *\n * Exported only for testing\n */\nexport function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head']): void {\n const metaTags = getTraceMetaTags();\n\n if (metaTags) {\n head.push(metaTags);\n }\n}\n\n/**\n * Reports an error to Sentry. This function is similar to `attachErrorHandler` in `@sentry/vue`.\n * The Nuxt SDK does not register an error handler, but uses the Nuxt error hooks to report errors.\n *\n * We don't want to use the error handling from `@sentry/vue` as it wraps the existing error handler, which leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515\n */\nexport function reportNuxtError(options: {\n error: unknown;\n instance?: ComponentPublicInstance | null;\n info?: string;\n}): void {\n const { error, instance, info } = options;\n\n const metadata: Record<string, unknown> = {\n info,\n // todo: add component name and trace (like in the vue integration)\n };\n\n if (instance && instance.$props) {\n const sentryClient = getClient();\n const sentryOptions = sentryClient ? (sentryClient.getOptions() as ClientOptions & VueOptions) : null;\n\n // `attachProps` is enabled by default and props should only not be attached if explicitly disabled (see DEFAULT_CONFIG in `vueIntegration`).\n if (sentryOptions && sentryOptions.attachProps && instance.$props !== false) {\n metadata.propsData = instance.$props;\n }\n }\n\n // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.\n setTimeout(() => {\n captureException(error, {\n captureContext: { contexts: { nuxt: metadata } },\n mechanism: { handled: false },\n });\n });\n}\n"],"names":[],"mappings":";;AAOA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,YAAY,EAAiC;AACjF,EAAE,MAAM,iBAAiB,GAAY;AACrC,IAAI,MAAM,EAAE,SAAS;AACrB,IAAI,IAAI,EAAE,SAAS;AACnB,IAAI,IAAI,EAAE,SAAS;AACnB,GAAG;;AAEH,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE;AAC5B,MAAM,iBAAiB,CAAC,MAAA,GAAS,YAAY,CAAC,KAAK,CAAC,OAAQ,IAAG,SAAS;AACxE,MAAM,iBAAiB,CAAC,IAAA,GAAO,YAAY,CAAC,KAAK,CAAC,KAAM,IAAG,SAAS;AACpE;;AAEA,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;AAC1C,MAAM,iBAAiB,CAAC,IAAK,GAAE,YAAY,CAAC,IAAA,IAAQ,SAAS;AAC7D;AACA;;AAEA,EAAE,OAAO,iBAAiB,CAAC,iBAAiB,CAAC;AAC7C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,IAAI,EAAuC;AACpF,EAAE,MAAM,QAAA,GAAW,gBAAgB,EAAE;;AAErC,EAAE,IAAI,QAAQ,EAAE;AAChB,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AACvB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC;;AAIhC,EAAS;AACT,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAA,EAAO,GAAE,OAAO;;AAE3C,EAAE,MAAM,QAAQ,GAA4B;AAC5C,IAAI,IAAI;AACR;AACA,GAAG;;AAEH,EAAE,IAAI,QAAA,IAAY,QAAQ,CAAC,MAAM,EAAE;AACnC,IAAI,MAAM,YAAA,GAAe,SAAS,EAAE;AACpC,IAAI,MAAM,aAAA,GAAgB,YAAA,IAAgB,YAAY,CAAC,UAAU,EAAG,KAAiC,IAAI;;AAEzG;AACA,IAAI,IAAI,aAAc,IAAG,aAAa,CAAC,WAAY,IAAG,QAAQ,CAAC,MAAO,KAAI,KAAK,EAAE;AACjF,MAAM,QAAQ,CAAC,SAAA,GAAY,QAAQ,CAAC,MAAM;AAC1C;AACA;;AAEA;AACA,EAAE,UAAU,CAAC,MAAM;AACnB,IAAI,gBAAgB,CAAC,KAAK,EAAE;AAC5B,MAAM,cAAc,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAS,EAAA,EAAG;AACtD,MAAM,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO;AACnC,KAAK,CAAC;AACN,GAAG,CAAC;AACJ;;;;"}