@sentry/nuxt 9.36.0-alpha.1 → 9.36.0

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.
@@ -1 +1 @@
1
- {"type":"module","version":"9.36.0-alpha.1"}
1
+ {"type":"module","version":"9.36.0"}
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.7.0"
6
6
  },
7
- "version": "9.36.0-alpha.1",
7
+ "version": "9.36.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -0,0 +1,5 @@
1
+ import type { H3Event } from 'h3';
2
+ /**
3
+ * Update the root span (transaction) name for routes with parameters based on the matched route.
4
+ */
5
+ export declare function updateRouteBeforeResponse(event: H3Event): void;
@@ -0,0 +1,37 @@
1
+ import { getActiveSpan, getCurrentScope, getRootSpan, logger, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from "@sentry/core";
2
+ export function updateRouteBeforeResponse(event) {
3
+ if (!event.context.matchedRoute) {
4
+ return;
5
+ }
6
+ const matchedRoutePath = event.context.matchedRoute.path;
7
+ if (matchedRoutePath && matchedRoutePath !== event._path) {
8
+ if (matchedRoutePath === "/**") {
9
+ return;
10
+ }
11
+ const method = event._method || "GET";
12
+ const parametrizedTransactionName = `${method.toUpperCase()} ${matchedRoutePath}`;
13
+ getCurrentScope().setTransactionName(parametrizedTransactionName);
14
+ const activeSpan = getActiveSpan();
15
+ if (!activeSpan) {
16
+ return;
17
+ }
18
+ const rootSpan = getRootSpan(activeSpan);
19
+ if (!rootSpan) {
20
+ return;
21
+ }
22
+ rootSpan.setAttributes({
23
+ [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "route",
24
+ "http.route": matchedRoutePath
25
+ });
26
+ const params = event.context?.params;
27
+ if (params && typeof params === "object") {
28
+ Object.entries(params).forEach(([key, value]) => {
29
+ rootSpan.setAttributes({
30
+ [`url.path.parameter.${key}`]: String(value),
31
+ [`params.${key}`]: String(value)
32
+ });
33
+ });
34
+ }
35
+ logger.log(`Updated transaction name for parametrized route: ${parametrizedTransactionName}`);
36
+ }
37
+ }
@@ -1,6 +1,7 @@
1
1
  import { setAsyncLocalStorageAsyncContextStrategy, wrapRequestHandler } from "@sentry/cloudflare";
2
2
  import { getDefaultIsolationScope, getIsolationScope, getTraceData, logger } from "@sentry/core";
3
3
  import { sentryCaptureErrorHook } from "../hooks/captureErrorHook.js";
4
+ import { updateRouteBeforeResponse } from "../hooks/updateRouteBeforeResponse.js";
4
5
  import { addSentryTracingMetaTags } from "../utils.js";
5
6
  function isEventType(event) {
6
7
  if (event === null || typeof event !== "object") return false;
@@ -51,6 +52,7 @@ export const sentryCloudflareNitroPlugin = (optionsOrFn) => (nitroApp) => {
51
52
  }
52
53
  }
53
54
  });
55
+ nitroApp.hooks.hook("beforeResponse", updateRouteBeforeResponse);
54
56
  nitroApp.hooks.hook("render:html", (html, { event }) => {
55
57
  const storedTraceData = event?.context?.cf ? traceDataMap.get(event.context.cf) : void 0;
56
58
  if (storedTraceData && Object.keys(storedTraceData).length > 0) {
@@ -1,9 +1,11 @@
1
1
  import { getDefaultIsolationScope, getIsolationScope, logger, withIsolationScope } from "@sentry/core";
2
2
  import { defineNitroPlugin } from "nitropack/runtime";
3
3
  import { sentryCaptureErrorHook } from "../hooks/captureErrorHook.js";
4
+ import { updateRouteBeforeResponse } from "../hooks/updateRouteBeforeResponse.js";
4
5
  import { addSentryTracingMetaTags, flushIfServerless } from "../utils.js";
5
6
  export default defineNitroPlugin((nitroApp) => {
6
7
  nitroApp.h3App.handler = patchEventHandler(nitroApp.h3App.handler);
8
+ nitroApp.hooks.hook("beforeResponse", updateRouteBeforeResponse);
7
9
  nitroApp.hooks.hook("error", sentryCaptureErrorHook);
8
10
  nitroApp.hooks.hook("render:html", (html) => {
9
11
  addSentryTracingMetaTags(html.head);
@@ -0,0 +1,6 @@
1
+ import type { H3Event } from 'h3';
2
+ /**
3
+ * Update the root span (transaction) name for routes with parameters based on the matched route.
4
+ */
5
+ export declare function updateRouteBeforeResponse(event: H3Event): void;
6
+ //# sourceMappingURL=updateRouteBeforeResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateRouteBeforeResponse.d.ts","sourceRoot":"","sources":["../../../../src/runtime/hooks/updateRouteBeforeResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAElC;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkD9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-cloudflare.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry-cloudflare.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAiD1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,2BAA2B,gDACQ,QAAQ,KAAK,iBAAiB,MAAI,cAmE/E,CAAC"}
1
+ {"version":3,"file":"sentry-cloudflare.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry-cloudflare.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAkD1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,2BAA2B,gDACQ,QAAQ,KAAK,iBAAiB,MAAI,cAqE/E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AASA,wBASG"}
1
+ {"version":3,"file":"sentry.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry.server.ts"],"names":[],"mappings":";AAUA,wBAWG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/nuxt",
3
- "version": "9.36.0-alpha.1",
3
+ "version": "9.36.0",
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",
@@ -53,16 +53,16 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@nuxt/kit": "^3.13.2",
56
- "@sentry/browser": "9.36.0-alpha.1",
57
- "@sentry/core": "9.36.0-alpha.1",
58
- "@sentry/node": "9.36.0-alpha.1",
56
+ "@sentry/browser": "9.36.0",
57
+ "@sentry/core": "9.36.0",
58
+ "@sentry/node": "9.36.0",
59
59
  "@sentry/rollup-plugin": "^3.5.0",
60
60
  "@sentry/vite-plugin": "^3.5.0",
61
- "@sentry/vue": "9.36.0-alpha.1"
61
+ "@sentry/vue": "9.36.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@nuxt/module-builder": "^0.8.4",
65
- "@sentry/cloudflare": "9.36.0-alpha.1",
65
+ "@sentry/cloudflare": "9.36.0",
66
66
  "nuxt": "^3.13.2"
67
67
  },
68
68
  "scripts": {