@sentry/react-router 9.38.0 → 9.40.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.
Files changed (45) hide show
  1. package/build/cjs/client/hydratedRouter.js +39 -26
  2. package/build/cjs/client/hydratedRouter.js.map +1 -1
  3. package/build/cjs/server/instrumentation/reactRouter.js +11 -6
  4. package/build/cjs/server/instrumentation/reactRouter.js.map +1 -1
  5. package/build/cjs/server/instrumentation/util.js +0 -3
  6. package/build/cjs/server/instrumentation/util.js.map +1 -1
  7. package/build/cjs/server/integration/lowQualityTransactionsFilterIntegration.js +1 -1
  8. package/build/cjs/server/integration/lowQualityTransactionsFilterIntegration.js.map +1 -1
  9. package/build/cjs/server/integration/reactRouterServer.js +24 -1
  10. package/build/cjs/server/integration/reactRouterServer.js.map +1 -1
  11. package/build/cjs/server/sdk.js +7 -39
  12. package/build/cjs/server/sdk.js.map +1 -1
  13. package/build/cjs/server/wrapSentryHandleRequest.js +15 -16
  14. package/build/cjs/server/wrapSentryHandleRequest.js.map +1 -1
  15. package/build/cjs/server/wrapServerAction.js +12 -7
  16. package/build/cjs/server/wrapServerAction.js.map +1 -1
  17. package/build/cjs/server/wrapServerLoader.js +12 -7
  18. package/build/cjs/server/wrapServerLoader.js.map +1 -1
  19. package/build/esm/client/hydratedRouter.js +40 -27
  20. package/build/esm/client/hydratedRouter.js.map +1 -1
  21. package/build/esm/package.json +1 -1
  22. package/build/esm/server/instrumentation/reactRouter.js +13 -8
  23. package/build/esm/server/instrumentation/reactRouter.js.map +1 -1
  24. package/build/esm/server/instrumentation/util.js +1 -3
  25. package/build/esm/server/instrumentation/util.js.map +1 -1
  26. package/build/esm/server/integration/lowQualityTransactionsFilterIntegration.js +2 -2
  27. package/build/esm/server/integration/lowQualityTransactionsFilterIntegration.js.map +1 -1
  28. package/build/esm/server/integration/reactRouterServer.js +25 -2
  29. package/build/esm/server/integration/reactRouterServer.js.map +1 -1
  30. package/build/esm/server/sdk.js +9 -41
  31. package/build/esm/server/sdk.js.map +1 -1
  32. package/build/esm/server/wrapSentryHandleRequest.js +16 -17
  33. package/build/esm/server/wrapSentryHandleRequest.js.map +1 -1
  34. package/build/esm/server/wrapServerAction.js +13 -8
  35. package/build/esm/server/wrapServerAction.js.map +1 -1
  36. package/build/esm/server/wrapServerLoader.js +13 -8
  37. package/build/esm/server/wrapServerLoader.js.map +1 -1
  38. package/build/types/client/hydratedRouter.d.ts.map +1 -1
  39. package/build/types/server/instrumentation/reactRouter.d.ts.map +1 -1
  40. package/build/types/server/integration/reactRouterServer.d.ts.map +1 -1
  41. package/build/types/server/sdk.d.ts.map +1 -1
  42. package/build/types/server/wrapSentryHandleRequest.d.ts.map +1 -1
  43. package/build/types/server/wrapServerAction.d.ts.map +1 -1
  44. package/build/types/server/wrapServerLoader.d.ts.map +1 -1
  45. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- import { getActiveSpan, getRootSpan, spanToJSON, parseStringToURLObject, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2
- import { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util.js';
1
+ import { SEMATTRS_HTTP_TARGET } from '@opentelemetry/semantic-conventions';
2
+ import { getActiveSpan, getRootSpan, spanToJSON, updateSpanName, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
3
3
 
4
4
  /**
5
5
  * Wraps a React Router server action function with Sentry performance monitoring.
@@ -26,13 +26,18 @@ function wrapServerAction(options = {}, actionFn) {
26
26
  const active = getActiveSpan();
27
27
  if (active) {
28
28
  const root = getRootSpan(active);
29
- // coming from auto.http.otel.http
30
- if (spanToJSON(root).description === 'POST') {
31
- const url = parseStringToURLObject(args.request.url);
32
- if (url?.pathname) {
29
+ const spanData = spanToJSON(root);
30
+ if (spanData.origin === 'auto.http.otel.http') {
31
+ // eslint-disable-next-line deprecation/deprecation
32
+ const target = spanData.data[SEMATTRS_HTTP_TARGET];
33
+
34
+ if (target) {
35
+ // We cannot rely on the regular span name inferral here, as the express instrumentation sets `*` as the route
36
+ // So we force this to be a more sensible name here
37
+ updateSpanName(root, `${args.request.method} ${target}`);
33
38
  root.setAttributes({
34
39
  [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
35
- [SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]: `${args.request.method} ${url.pathname}`,
40
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.action',
36
41
  });
37
42
  }
38
43
  }
@@ -43,7 +48,7 @@ function wrapServerAction(options = {}, actionFn) {
43
48
  name,
44
49
  ...options,
45
50
  attributes: {
46
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router',
51
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.action',
47
52
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.action',
48
53
  ...options.attributes,
49
54
  },
@@ -1 +1 @@
1
- {"version":3,"file":"wrapServerAction.js","sources":["../../../src/server/wrapServerAction.ts"],"sourcesContent":["import type { SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n getRootSpan,\n parseStringToURLObject,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n startSpan,\n} from '@sentry/core';\nimport type { ActionFunctionArgs } from 'react-router';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util';\n\ntype SpanOptions = {\n name?: string;\n attributes?: SpanAttributes;\n};\n\n/**\n * Wraps a React Router server action function with Sentry performance monitoring.\n * @param options - Optional span configuration options including name, operation, description and attributes\n * @param actionFn - The server action function to wrap\n *\n * @example\n * ```ts\n * // Wrap an action function with custom span options\n * export const action = wrapServerAction(\n * {\n * name: 'Submit Form Data',\n * description: 'Processes form submission data',\n * },\n * async ({ request }) => {\n * // ... your action logic\n * }\n * );\n * ```\n */\nexport function wrapServerAction<T>(options: SpanOptions = {}, actionFn: (args: ActionFunctionArgs) => Promise<T>) {\n return async function (args: ActionFunctionArgs) {\n const name = options.name || 'Executing Server Action';\n const active = getActiveSpan();\n if (active) {\n const root = getRootSpan(active);\n // coming from auto.http.otel.http\n if (spanToJSON(root).description === 'POST') {\n const url = parseStringToURLObject(args.request.url);\n if (url?.pathname) {\n root.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]: `${args.request.method} ${url.pathname}`,\n });\n }\n }\n }\n\n return startSpan(\n {\n name,\n ...options,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.action',\n ...options.attributes,\n },\n },\n () => actionFn(args),\n );\n };\n}\n"],"names":[],"mappings":";;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAI,OAAO,GAAgB,EAAE,EAAE,QAAQ,EAA4C;AACnH,EAAE,OAAO,gBAAgB,IAAI,EAAsB;AACnD,IAAI,MAAM,IAAA,GAAO,OAAO,CAAC,IAAA,IAAQ,yBAAyB;AAC1D,IAAI,MAAM,MAAA,GAAS,aAAa,EAAE;AAClC,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,MAAM,IAAA,GAAO,WAAW,CAAC,MAAM,CAAC;AACtC;AACA,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,WAAA,KAAgB,MAAM,EAAE;AACnD,QAAQ,MAAM,GAAA,GAAM,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;AAC5D,QAAQ,IAAI,GAAG,EAAE,QAAQ,EAAE;AAC3B,UAAU,IAAI,CAAC,aAAa,CAAC;AAC7B,YAAY,CAAC,gCAAgC,GAAG,KAAK;AACrD,YAAY,CAAC,mCAAmC,GAAG,CAAC,EAAA,IAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA,EAAA,GAAA,CAAA,QAAA,CAAA,CAAA;AACA,WAAA,CAAA;AACA;AACA;AACA;;AAEA,IAAA,OAAA,SAAA;AACA,MAAA;AACA,QAAA,IAAA;AACA,QAAA,GAAA,OAAA;AACA,QAAA,UAAA,EAAA;AACA,UAAA,CAAA,gCAAA,GAAA,wBAAA;AACA,UAAA,CAAA,4BAAA,GAAA,8BAAA;AACA,UAAA,GAAA,OAAA,CAAA,UAAA;AACA,SAAA;AACA,OAAA;AACA,MAAA,MAAA,QAAA,CAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
1
+ {"version":3,"file":"wrapServerAction.js","sources":["../../../src/server/wrapServerAction.ts"],"sourcesContent":["import { SEMATTRS_HTTP_TARGET } from '@opentelemetry/semantic-conventions';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n startSpan,\n updateSpanName,\n} from '@sentry/core';\nimport type { ActionFunctionArgs } from 'react-router';\n\ntype SpanOptions = {\n name?: string;\n attributes?: SpanAttributes;\n};\n\n/**\n * Wraps a React Router server action function with Sentry performance monitoring.\n * @param options - Optional span configuration options including name, operation, description and attributes\n * @param actionFn - The server action function to wrap\n *\n * @example\n * ```ts\n * // Wrap an action function with custom span options\n * export const action = wrapServerAction(\n * {\n * name: 'Submit Form Data',\n * description: 'Processes form submission data',\n * },\n * async ({ request }) => {\n * // ... your action logic\n * }\n * );\n * ```\n */\nexport function wrapServerAction<T>(options: SpanOptions = {}, actionFn: (args: ActionFunctionArgs) => Promise<T>) {\n return async function (args: ActionFunctionArgs) {\n const name = options.name || 'Executing Server Action';\n const active = getActiveSpan();\n if (active) {\n const root = getRootSpan(active);\n const spanData = spanToJSON(root);\n if (spanData.origin === 'auto.http.otel.http') {\n // eslint-disable-next-line deprecation/deprecation\n const target = spanData.data[SEMATTRS_HTTP_TARGET];\n\n if (target) {\n // We cannot rely on the regular span name inferral here, as the express instrumentation sets `*` as the route\n // So we force this to be a more sensible name here\n updateSpanName(root, `${args.request.method} ${target}`);\n root.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.action',\n });\n }\n }\n }\n\n return startSpan(\n {\n name,\n ...options,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.action',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.action',\n ...options.attributes,\n },\n },\n () => actionFn(args),\n );\n };\n}\n"],"names":[],"mappings":";;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAI,OAAO,GAAgB,EAAE,EAAE,QAAQ,EAA4C;AACnH,EAAE,OAAO,gBAAgB,IAAI,EAAsB;AACnD,IAAI,MAAM,IAAA,GAAO,OAAO,CAAC,IAAA,IAAQ,yBAAyB;AAC1D,IAAI,MAAM,MAAA,GAAS,aAAa,EAAE;AAClC,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,MAAM,IAAA,GAAO,WAAW,CAAC,MAAM,CAAC;AACtC,MAAM,MAAM,QAAA,GAAW,UAAU,CAAC,IAAI,CAAC;AACvC,MAAM,IAAI,QAAQ,CAAC,MAAA,KAAW,qBAAqB,EAAE;AACrD;AACA,QAAQ,MAAM,SAAS,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC;;AAE1D,QAAQ,IAAI,MAAM,EAAE;AACpB;AACA;AACA,UAAU,cAAc,CAAC,IAAI,EAAE,CAAC,EAAA,IAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA,EAAA,MAAA,CAAA,CAAA,CAAA;AACA,UAAA,IAAA,CAAA,aAAA,CAAA;AACA,YAAA,CAAA,gCAAA,GAAA,KAAA;AACA,YAAA,CAAA,gCAAA,GAAA,+BAAA;AACA,WAAA,CAAA;AACA;AACA;AACA;;AAEA,IAAA,OAAA,SAAA;AACA,MAAA;AACA,QAAA,IAAA;AACA,QAAA,GAAA,OAAA;AACA,QAAA,UAAA,EAAA;AACA,UAAA,CAAA,gCAAA,GAAA,+BAAA;AACA,UAAA,CAAA,4BAAA,GAAA,8BAAA;AACA,UAAA,GAAA,OAAA,CAAA,UAAA;AACA,SAAA;AACA,OAAA;AACA,MAAA,MAAA,QAAA,CAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
@@ -1,5 +1,5 @@
1
- import { getActiveSpan, getRootSpan, spanToJSON, parseStringToURLObject, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2
- import { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util.js';
1
+ import { SEMATTRS_HTTP_TARGET } from '@opentelemetry/semantic-conventions';
2
+ import { getActiveSpan, getRootSpan, spanToJSON, updateSpanName, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
3
3
 
4
4
  /**
5
5
  * Wraps a React Router server loader function with Sentry performance monitoring.
@@ -24,16 +24,21 @@ function wrapServerLoader(options = {}, loaderFn) {
24
24
  return async function (args) {
25
25
  const name = options.name || 'Executing Server Loader';
26
26
  const active = getActiveSpan();
27
+
27
28
  if (active) {
28
29
  const root = getRootSpan(active);
29
- // coming from auto.http.otel.http
30
- if (spanToJSON(root).description === 'GET') {
31
- const url = parseStringToURLObject(args.request.url);
30
+ const spanData = spanToJSON(root);
31
+ if (spanData.origin === 'auto.http.otel.http') {
32
+ // eslint-disable-next-line deprecation/deprecation
33
+ const target = spanData.data[SEMATTRS_HTTP_TARGET];
32
34
 
33
- if (url?.pathname) {
35
+ if (target) {
36
+ // We cannot rely on the regular span name inferral here, as the express instrumentation sets `*` as the route
37
+ // So we force this to be a more sensible name here
38
+ updateSpanName(root, `${args.request.method} ${target}`);
34
39
  root.setAttributes({
35
40
  [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
36
- [SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]: `${args.request.method} ${url.pathname}`,
41
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.loader',
37
42
  });
38
43
  }
39
44
  }
@@ -43,7 +48,7 @@ function wrapServerLoader(options = {}, loaderFn) {
43
48
  name,
44
49
  ...options,
45
50
  attributes: {
46
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router',
51
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.loader',
47
52
  [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.loader',
48
53
  ...options.attributes,
49
54
  },
@@ -1 +1 @@
1
- {"version":3,"file":"wrapServerLoader.js","sources":["../../../src/server/wrapServerLoader.ts"],"sourcesContent":["import type { SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n getRootSpan,\n parseStringToURLObject,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n startSpan,\n} from '@sentry/core';\nimport type { LoaderFunctionArgs } from 'react-router';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE } from './instrumentation/util';\n\ntype SpanOptions = {\n name?: string;\n attributes?: SpanAttributes;\n};\n\n/**\n * Wraps a React Router server loader function with Sentry performance monitoring.\n * @param options - Optional span configuration options including name, operation, description and attributes\n * @param loaderFn - The server loader function to wrap\n *\n * @example\n * ```ts\n * // Wrap a loader function with custom span options\n * export const loader = wrapServerLoader(\n * {\n * name: 'Load Some Data',\n * description: 'Loads some data from the db',\n * },\n * async ({ params }) => {\n * // ... your loader logic\n * }\n * );\n * ```\n */\nexport function wrapServerLoader<T>(options: SpanOptions = {}, loaderFn: (args: LoaderFunctionArgs) => Promise<T>) {\n return async function (args: LoaderFunctionArgs) {\n const name = options.name || 'Executing Server Loader';\n const active = getActiveSpan();\n if (active) {\n const root = getRootSpan(active);\n // coming from auto.http.otel.http\n if (spanToJSON(root).description === 'GET') {\n const url = parseStringToURLObject(args.request.url);\n\n if (url?.pathname) {\n root.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_OVERWRITE]: `${args.request.method} ${url.pathname}`,\n });\n }\n }\n }\n return startSpan(\n {\n name,\n ...options,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.loader',\n ...options.attributes,\n },\n },\n () => loaderFn(args),\n );\n };\n}\n"],"names":[],"mappings":";;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAI,OAAO,GAAgB,EAAE,EAAE,QAAQ,EAA4C;AACnH,EAAE,OAAO,gBAAgB,IAAI,EAAsB;AACnD,IAAI,MAAM,IAAA,GAAO,OAAO,CAAC,IAAA,IAAQ,yBAAyB;AAC1D,IAAI,MAAM,MAAA,GAAS,aAAa,EAAE;AAClC,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,MAAM,IAAA,GAAO,WAAW,CAAC,MAAM,CAAC;AACtC;AACA,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,WAAA,KAAgB,KAAK,EAAE;AAClD,QAAQ,MAAM,GAAA,GAAM,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;;AAE5D,QAAQ,IAAI,GAAG,EAAE,QAAQ,EAAE;AAC3B,UAAU,IAAI,CAAC,aAAa,CAAC;AAC7B,YAAY,CAAC,gCAAgC,GAAG,KAAK;AACrD,YAAY,CAAC,mCAAmC,GAAG,CAAC,EAAA,IAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA,EAAA,GAAA,CAAA,QAAA,CAAA,CAAA;AACA,WAAA,CAAA;AACA;AACA;AACA;AACA,IAAA,OAAA,SAAA;AACA,MAAA;AACA,QAAA,IAAA;AACA,QAAA,GAAA,OAAA;AACA,QAAA,UAAA,EAAA;AACA,UAAA,CAAA,gCAAA,GAAA,wBAAA;AACA,UAAA,CAAA,4BAAA,GAAA,8BAAA;AACA,UAAA,GAAA,OAAA,CAAA,UAAA;AACA,SAAA;AACA,OAAA;AACA,MAAA,MAAA,QAAA,CAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
1
+ {"version":3,"file":"wrapServerLoader.js","sources":["../../../src/server/wrapServerLoader.ts"],"sourcesContent":["import { SEMATTRS_HTTP_TARGET } from '@opentelemetry/semantic-conventions';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n getRootSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n spanToJSON,\n startSpan,\n updateSpanName,\n} from '@sentry/core';\nimport type { LoaderFunctionArgs } from 'react-router';\n\ntype SpanOptions = {\n name?: string;\n attributes?: SpanAttributes;\n};\n\n/**\n * Wraps a React Router server loader function with Sentry performance monitoring.\n * @param options - Optional span configuration options including name, operation, description and attributes\n * @param loaderFn - The server loader function to wrap\n *\n * @example\n * ```ts\n * // Wrap a loader function with custom span options\n * export const loader = wrapServerLoader(\n * {\n * name: 'Load Some Data',\n * description: 'Loads some data from the db',\n * },\n * async ({ params }) => {\n * // ... your loader logic\n * }\n * );\n * ```\n */\nexport function wrapServerLoader<T>(options: SpanOptions = {}, loaderFn: (args: LoaderFunctionArgs) => Promise<T>) {\n return async function (args: LoaderFunctionArgs) {\n const name = options.name || 'Executing Server Loader';\n const active = getActiveSpan();\n\n if (active) {\n const root = getRootSpan(active);\n const spanData = spanToJSON(root);\n if (spanData.origin === 'auto.http.otel.http') {\n // eslint-disable-next-line deprecation/deprecation\n const target = spanData.data[SEMATTRS_HTTP_TARGET];\n\n if (target) {\n // We cannot rely on the regular span name inferral here, as the express instrumentation sets `*` as the route\n // So we force this to be a more sensible name here\n updateSpanName(root, `${args.request.method} ${target}`);\n root.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.loader',\n });\n }\n }\n }\n return startSpan(\n {\n name,\n ...options,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router.loader',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.loader',\n ...options.attributes,\n },\n },\n () => loaderFn(args),\n );\n };\n}\n"],"names":[],"mappings":";;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB,CAAI,OAAO,GAAgB,EAAE,EAAE,QAAQ,EAA4C;AACnH,EAAE,OAAO,gBAAgB,IAAI,EAAsB;AACnD,IAAI,MAAM,IAAA,GAAO,OAAO,CAAC,IAAA,IAAQ,yBAAyB;AAC1D,IAAI,MAAM,MAAA,GAAS,aAAa,EAAE;;AAElC,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,MAAM,IAAA,GAAO,WAAW,CAAC,MAAM,CAAC;AACtC,MAAM,MAAM,QAAA,GAAW,UAAU,CAAC,IAAI,CAAC;AACvC,MAAM,IAAI,QAAQ,CAAC,MAAA,KAAW,qBAAqB,EAAE;AACrD;AACA,QAAQ,MAAM,SAAS,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC;;AAE1D,QAAQ,IAAI,MAAM,EAAE;AACpB;AACA;AACA,UAAU,cAAc,CAAC,IAAI,EAAE,CAAC,EAAA,IAAA,CAAA,OAAA,CAAA,MAAA,CAAA,CAAA,EAAA,MAAA,CAAA,CAAA,CAAA;AACA,UAAA,IAAA,CAAA,aAAA,CAAA;AACA,YAAA,CAAA,gCAAA,GAAA,KAAA;AACA,YAAA,CAAA,gCAAA,GAAA,+BAAA;AACA,WAAA,CAAA;AACA;AACA;AACA;AACA,IAAA,OAAA,SAAA;AACA,MAAA;AACA,QAAA,IAAA;AACA,QAAA,GAAA,OAAA;AACA,QAAA,UAAA,EAAA;AACA,UAAA,CAAA,gCAAA,GAAA,+BAAA;AACA,UAAA,CAAA,4BAAA,GAAA,8BAAA;AACA,UAAA,GAAA,OAAA,CAAA,UAAA;AACA,SAAA;AACA,OAAA;AACA,MAAA,MAAA,QAAA,CAAA,IAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"hydratedRouter.d.ts","sourceRoot":"","sources":["../../../src/client/hydratedRouter.ts"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAsE/C"}
1
+ {"version":3,"file":"hydratedRouter.d.ts","sourceRoot":"","sources":["../../../src/client/hydratedRouter.ts"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAmF/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"reactRouter.d.ts","sourceRoot":"","sources":["../../../../src/server/instrumentation/reactRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAoB1G;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,qBAAqB,CAAC;gBACrE,MAAM,GAAE,qBAA0B;IAIrD;;OAEG;IAEH,SAAS,CAAC,IAAI,IAAI,mCAAmC;IAgBrD;;;OAGG;IACH,OAAO,CAAC,yBAAyB;CAwDlC"}
1
+ {"version":3,"file":"reactRouter.d.ts","sourceRoot":"","sources":["../../../../src/server/instrumentation/reactRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAuB1G;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,qBAAqB,CAAC;gBACrE,MAAM,GAAE,qBAA0B;IAIrD;;OAEG;IAEH,SAAS,CAAC,IAAI,IAAI,mCAAmC;IAgBrD;;;OAGG;IACH,OAAO,CAAC,yBAAyB;CA4DlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"reactRouterServer.d.ts","sourceRoot":"","sources":["../../../../src/server/integration/reactRouterServer.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,2BAA2B,SAClC,IAAI;;CAIT,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,0CAOvC,CAAC"}
1
+ {"version":3,"file":"reactRouterServer.d.ts","sourceRoot":"","sources":["../../../../src/server/integration/reactRouterServer.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,2BAA2B,SAClC,IAAI;;CAIT,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,0CA6BvC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/server/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO5D;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,EAAE,CAW3F;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CA0CjE"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/server/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAM5D;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,EAAE,CAM3F;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAiBjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrapSentryHandleRequest.d.ts","sourceRoot":"","sources":["../../../src/server/wrapSentryHandleRequest.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,KAAK,qBAAqB,GAAG,CAC3B,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,YAAY,EAC3B,WAAW,EAAE,cAAc,KACxB,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,qBAAqB,GAAG,qBAAqB,CAmCpG;AAED,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,gCAA0B,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAelE"}
1
+ {"version":3,"file":"wrapSentryHandleRequest.d.ts","sourceRoot":"","sources":["../../../src/server/wrapSentryHandleRequest.ts"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,KAAK,qBAAqB,GAAG,CAC3B,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,MAAM,EAC1B,eAAe,EAAE,OAAO,EACxB,aAAa,EAAE,YAAY,EAC3B,WAAW,EAAE,cAAc,KACxB,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,qBAAqB,GAAG,qBAAqB,CAkCpG;AAED,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,gCAA0B,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAelE"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrapServerAction.d.ts","sourceRoot":"","sources":["../../../src/server/wrapServerAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,yBAAkB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,UAClF,kBAAkB,gBA8BhD"}
1
+ {"version":3,"file":"wrapServerAction.d.ts","sourceRoot":"","sources":["../../../src/server/wrapServerAction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,yBAAkB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,UAClF,kBAAkB,gBAmChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"wrapServerLoader.d.ts","sourceRoot":"","sources":["../../../src/server/wrapServerLoader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,yBAAkB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,UAClF,kBAAkB,gBA8BhD"}
1
+ {"version":3,"file":"wrapServerLoader.d.ts","sourceRoot":"","sources":["../../../src/server/wrapServerLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,yBAAkB,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,UAClF,kBAAkB,gBAmChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/react-router",
3
- "version": "9.38.0",
3
+ "version": "9.40.0",
4
4
  "description": "Official Sentry SDK for React Router (Framework)",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react-router",
@@ -38,11 +38,11 @@
38
38
  "@opentelemetry/core": "^1.30.1",
39
39
  "@opentelemetry/instrumentation": "0.57.2",
40
40
  "@opentelemetry/semantic-conventions": "^1.34.0",
41
- "@sentry/browser": "9.38.0",
41
+ "@sentry/browser": "9.40.0",
42
42
  "@sentry/cli": "^2.46.0",
43
- "@sentry/core": "9.38.0",
44
- "@sentry/node": "9.38.0",
45
- "@sentry/react": "9.38.0",
43
+ "@sentry/core": "9.40.0",
44
+ "@sentry/node": "9.40.0",
45
+ "@sentry/react": "9.40.0",
46
46
  "@sentry/vite-plugin": "^3.5.0",
47
47
  "glob": "11.0.1"
48
48
  },