@sentry/react-router 9.10.1 → 9.12.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.
- package/build/cjs/common/debug-build.js +11 -0
- package/build/cjs/common/debug-build.js.map +1 -0
- package/build/cjs/index.server.js +2 -0
- package/build/cjs/index.server.js.map +1 -1
- package/build/cjs/server/sdk.js +4 -0
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/sentryHandleRequest.js +48 -0
- package/build/cjs/server/sentryHandleRequest.js.map +1 -0
- package/build/esm/common/debug-build.js +9 -0
- package/build/esm/common/debug-build.js.map +1 -0
- package/build/esm/index.server.js +1 -0
- package/build/esm/index.server.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/sdk.js +5 -1
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/sentryHandleRequest.js +46 -0
- package/build/esm/server/sentryHandleRequest.js.map +1 -0
- package/build/types/server/index.d.ts +1 -0
- package/build/types/server/index.d.ts.map +1 -1
- package/build/types/server/sdk.d.ts.map +1 -1
- package/build/types/server/sentryHandleRequest.d.ts +11 -0
- package/build/types/server/sentryHandleRequest.d.ts.map +1 -0
- package/package.json +9 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
|
|
5
|
+
*
|
|
6
|
+
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
|
|
7
|
+
*/
|
|
8
|
+
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
|
|
9
|
+
|
|
10
|
+
exports.DEBUG_BUILD = DEBUG_BUILD;
|
|
11
|
+
//# sourceMappingURL=debug-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-build.js","sources":["../../../src/common/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAiB,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
|
|
@@ -2,12 +2,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const node = require('@sentry/node');
|
|
4
4
|
const sdk = require('./server/sdk.js');
|
|
5
|
+
const sentryHandleRequest = require('./server/sentryHandleRequest.js');
|
|
5
6
|
const plugin = require('./vite/plugin.js');
|
|
6
7
|
const handleOnBuildEnd = require('./vite/buildEnd/handleOnBuildEnd.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
exports.init = sdk.init;
|
|
12
|
+
exports.sentryHandleRequest = sentryHandleRequest.sentryHandleRequest;
|
|
11
13
|
exports.sentryReactRouter = plugin.sentryReactRouter;
|
|
12
14
|
exports.sentryOnBuildEnd = handleOnBuildEnd.sentryOnBuildEnd;
|
|
13
15
|
Object.prototype.hasOwnProperty.call(node, '__proto__') &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/cjs/server/sdk.js
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
4
|
const node = require('@sentry/node');
|
|
5
|
+
const debugBuild = require('../common/debug-build.js');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Initializes the server side of the React Router SDK
|
|
@@ -11,12 +12,15 @@ function init(options) {
|
|
|
11
12
|
...options,
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
debugBuild.DEBUG_BUILD && core.logger.log('Initializing SDK...');
|
|
16
|
+
|
|
14
17
|
core.applySdkMetadata(opts, 'react-router', ['react-router', 'node']);
|
|
15
18
|
|
|
16
19
|
const client = node.init(opts);
|
|
17
20
|
|
|
18
21
|
core.setTag('runtime', 'node');
|
|
19
22
|
|
|
23
|
+
debugBuild.DEBUG_BUILD && core.logger.log('SDK successfully initialized');
|
|
20
24
|
return client;
|
|
21
25
|
}
|
|
22
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata, setTag } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\n\n/**\n * Initializes the server side of the React Router SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react-router', ['react-router', 'node']);\n\n const client = initNodeSdk(opts);\n\n setTag('runtime', 'node');\n\n return client;\n}\n"],"names":["applySdkMetadata","initNodeSdk","setTag"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata, logger, setTag } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\nimport { DEBUG_BUILD } from '../common/debug-build';\n\n/**\n * Initializes the server side of the React Router SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n DEBUG_BUILD && logger.log('Initializing SDK...');\n\n applySdkMetadata(opts, 'react-router', ['react-router', 'node']);\n\n const client = initNodeSdk(opts);\n\n setTag('runtime', 'node');\n\n DEBUG_BUILD && logger.log('SDK successfully initialized');\n return client;\n}\n"],"names":["DEBUG_BUILD","logger","applySdkMetadata","initNodeSdk","setTag"],"mappings":";;;;;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuC;AACnE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,0BAAeC,WAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC;;AAElD,EAAEC,qBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;;AAElE,EAAE,MAAM,MAAO,GAAEC,SAAW,CAAC,IAAI,CAAC;;AAElC,EAAEC,WAAM,CAAC,SAAS,EAAE,MAAM,CAAC;;AAE3B,EAAEJ,0BAAeC,WAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC;AAC3D,EAAE,OAAO,MAAM;AACf;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const api = require('@opentelemetry/api');
|
|
4
|
+
const core$1 = require('@opentelemetry/core');
|
|
5
|
+
const semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
6
|
+
const core = require('@sentry/core');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wraps the original handleRequest function to add Sentry instrumentation.
|
|
10
|
+
*
|
|
11
|
+
* @param originalHandle - The original handleRequest function to wrap
|
|
12
|
+
* @returns A wrapped version of the handle request function with Sentry instrumentation
|
|
13
|
+
*/
|
|
14
|
+
function sentryHandleRequest(originalHandle) {
|
|
15
|
+
return async function sentryInstrumentedHandleRequest(
|
|
16
|
+
request,
|
|
17
|
+
responseStatusCode,
|
|
18
|
+
responseHeaders,
|
|
19
|
+
routerContext,
|
|
20
|
+
loadContext,
|
|
21
|
+
) {
|
|
22
|
+
const parameterizedPath =
|
|
23
|
+
routerContext?.staticHandlerContext?.matches?.[routerContext.staticHandlerContext.matches.length - 1]?.route.path;
|
|
24
|
+
if (parameterizedPath) {
|
|
25
|
+
const activeSpan = core.getActiveSpan();
|
|
26
|
+
if (activeSpan) {
|
|
27
|
+
const rootSpan = core.getRootSpan(activeSpan);
|
|
28
|
+
const routeName = `/${parameterizedPath}`;
|
|
29
|
+
|
|
30
|
+
// The express instrumentation writes on the rpcMetadata and that ends up stomping on the `http.route` attribute.
|
|
31
|
+
const rpcMetadata = core$1.getRPCMetadata(api.context.active());
|
|
32
|
+
if (rpcMetadata?.type === core$1.RPCType.HTTP) {
|
|
33
|
+
rpcMetadata.route = routeName;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The span exporter picks up the `http.route` (ATTR_HTTP_ROUTE) attribute to set the transaction name
|
|
37
|
+
rootSpan.setAttributes({
|
|
38
|
+
[semanticConventions.ATTR_HTTP_ROUTE]: routeName,
|
|
39
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return originalHandle(request, responseStatusCode, responseHeaders, routerContext, loadContext);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.sentryHandleRequest = sentryHandleRequest;
|
|
48
|
+
//# sourceMappingURL=sentryHandleRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryHandleRequest.js","sources":["../../../src/server/sentryHandleRequest.ts"],"sourcesContent":["import { context } from '@opentelemetry/api';\nimport { RPCType, getRPCMetadata } from '@opentelemetry/core';\nimport { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getRootSpan } from '@sentry/core';\nimport type { AppLoadContext, EntryContext } from 'react-router';\n\ntype OriginalHandleRequest = (\n request: Request,\n responseStatusCode: number,\n responseHeaders: Headers,\n routerContext: EntryContext,\n loadContext: AppLoadContext,\n) => Promise<unknown>;\n\n/**\n * Wraps the original handleRequest function to add Sentry instrumentation.\n *\n * @param originalHandle - The original handleRequest function to wrap\n * @returns A wrapped version of the handle request function with Sentry instrumentation\n */\nexport function sentryHandleRequest(originalHandle: OriginalHandleRequest): OriginalHandleRequest {\n return async function sentryInstrumentedHandleRequest(\n request: Request,\n responseStatusCode: number,\n responseHeaders: Headers,\n routerContext: EntryContext,\n loadContext: AppLoadContext,\n ) {\n const parameterizedPath =\n routerContext?.staticHandlerContext?.matches?.[routerContext.staticHandlerContext.matches.length - 1]?.route.path;\n if (parameterizedPath) {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const rootSpan = getRootSpan(activeSpan);\n const routeName = `/${parameterizedPath}`;\n\n // The express instrumentation writes on the rpcMetadata and that ends up stomping on the `http.route` attribute.\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = routeName;\n }\n\n // The span exporter picks up the `http.route` (ATTR_HTTP_ROUTE) attribute to set the transaction name\n rootSpan.setAttributes({\n [ATTR_HTTP_ROUTE]: routeName,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n });\n }\n }\n return originalHandle(request, responseStatusCode, responseHeaders, routerContext, loadContext);\n };\n}\n"],"names":["getActiveSpan","getRootSpan","getRPCMetadata","context","RPCType","ATTR_HTTP_ROUTE","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE"],"mappings":";;;;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,cAAc,EAAgD;AAClG,EAAE,OAAO,eAAe,+BAA+B;AACvD,IAAI,OAAO;AACX,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,WAAW;AACf,IAAI;AACJ,IAAI,MAAM,iBAAkB;AAC5B,MAAM,aAAa,EAAE,oBAAoB,EAAE,OAAO,GAAG,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI;AACvH,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,MAAM,UAAA,GAAaA,kBAAa,EAAE;AACxC,MAAM,IAAI,UAAU,EAAE;AACtB,QAAQ,MAAM,QAAS,GAAEC,gBAAW,CAAC,UAAU,CAAC;AAChD,QAAQ,MAAM,YAAY,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;;AAEA;AACA,QAAA,MAAA,WAAA,GAAAC,qBAAA,CAAAC,WAAA,CAAA,MAAA,EAAA,CAAA;AACA,QAAA,IAAA,WAAA,EAAA,IAAA,KAAAC,cAAA,CAAA,IAAA,EAAA;AACA,UAAA,WAAA,CAAA,KAAA,GAAA,SAAA;AACA;;AAEA;AACA,QAAA,QAAA,CAAA,aAAA,CAAA;AACA,UAAA,CAAAC,mCAAA,GAAA,SAAA;AACA,UAAA,CAAAC,qCAAA,GAAA,OAAA;AACA,SAAA,CAAA;AACA;AACA;AACA,IAAA,OAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA,eAAA,EAAA,aAAA,EAAA,WAAA,CAAA;AACA,GAAA;AACA;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
|
|
3
|
+
*
|
|
4
|
+
* ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
|
|
5
|
+
*/
|
|
6
|
+
const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
|
|
7
|
+
|
|
8
|
+
export { DEBUG_BUILD };
|
|
9
|
+
//# sourceMappingURL=debug-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-build.js","sources":["../../../src/common/debug-build.ts"],"sourcesContent":["declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n"],"names":[],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAY,IAAiB,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from '@sentry/node';
|
|
2
2
|
export { init } from './server/sdk.js';
|
|
3
|
+
export { sentryHandleRequest } from './server/sentryHandleRequest.js';
|
|
3
4
|
export { sentryReactRouter } from './vite/plugin.js';
|
|
4
5
|
export { sentryOnBuildEnd } from './vite/buildEnd/handleOnBuildEnd.js';
|
|
5
6
|
//# sourceMappingURL=index.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"9.
|
|
1
|
+
{"type":"module","version":"9.12.0"}
|
package/build/esm/server/sdk.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { applySdkMetadata, setTag } from '@sentry/core';
|
|
1
|
+
import { logger, applySdkMetadata, setTag } from '@sentry/core';
|
|
2
2
|
import { init as init$1 } from '@sentry/node';
|
|
3
|
+
import { DEBUG_BUILD } from '../common/debug-build.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Initializes the server side of the React Router SDK
|
|
@@ -9,12 +10,15 @@ function init(options) {
|
|
|
9
10
|
...options,
|
|
10
11
|
};
|
|
11
12
|
|
|
13
|
+
DEBUG_BUILD && logger.log('Initializing SDK...');
|
|
14
|
+
|
|
12
15
|
applySdkMetadata(opts, 'react-router', ['react-router', 'node']);
|
|
13
16
|
|
|
14
17
|
const client = init$1(opts);
|
|
15
18
|
|
|
16
19
|
setTag('runtime', 'node');
|
|
17
20
|
|
|
21
|
+
DEBUG_BUILD && logger.log('SDK successfully initialized');
|
|
18
22
|
return client;
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata, setTag } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\n\n/**\n * Initializes the server side of the React Router SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react-router', ['react-router', 'node']);\n\n const client = initNodeSdk(opts);\n\n setTag('runtime', 'node');\n\n return client;\n}\n"],"names":["initNodeSdk"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata, logger, setTag } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\nimport { DEBUG_BUILD } from '../common/debug-build';\n\n/**\n * Initializes the server side of the React Router SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n DEBUG_BUILD && logger.log('Initializing SDK...');\n\n applySdkMetadata(opts, 'react-router', ['react-router', 'node']);\n\n const client = initNodeSdk(opts);\n\n setTag('runtime', 'node');\n\n DEBUG_BUILD && logger.log('SDK successfully initialized');\n return client;\n}\n"],"names":["initNodeSdk"],"mappings":";;;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuC;AACnE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,eAAe,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC;;AAElD,EAAE,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;;AAElE,EAAE,MAAM,MAAO,GAAEA,MAAW,CAAC,IAAI,CAAC;;AAElC,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;;AAE3B,EAAE,eAAe,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC;AAC3D,EAAE,OAAO,MAAM;AACf;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { context } from '@opentelemetry/api';
|
|
2
|
+
import { getRPCMetadata, RPCType } from '@opentelemetry/core';
|
|
3
|
+
import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
|
|
4
|
+
import { getActiveSpan, getRootSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wraps the original handleRequest function to add Sentry instrumentation.
|
|
8
|
+
*
|
|
9
|
+
* @param originalHandle - The original handleRequest function to wrap
|
|
10
|
+
* @returns A wrapped version of the handle request function with Sentry instrumentation
|
|
11
|
+
*/
|
|
12
|
+
function sentryHandleRequest(originalHandle) {
|
|
13
|
+
return async function sentryInstrumentedHandleRequest(
|
|
14
|
+
request,
|
|
15
|
+
responseStatusCode,
|
|
16
|
+
responseHeaders,
|
|
17
|
+
routerContext,
|
|
18
|
+
loadContext,
|
|
19
|
+
) {
|
|
20
|
+
const parameterizedPath =
|
|
21
|
+
routerContext?.staticHandlerContext?.matches?.[routerContext.staticHandlerContext.matches.length - 1]?.route.path;
|
|
22
|
+
if (parameterizedPath) {
|
|
23
|
+
const activeSpan = getActiveSpan();
|
|
24
|
+
if (activeSpan) {
|
|
25
|
+
const rootSpan = getRootSpan(activeSpan);
|
|
26
|
+
const routeName = `/${parameterizedPath}`;
|
|
27
|
+
|
|
28
|
+
// The express instrumentation writes on the rpcMetadata and that ends up stomping on the `http.route` attribute.
|
|
29
|
+
const rpcMetadata = getRPCMetadata(context.active());
|
|
30
|
+
if (rpcMetadata?.type === RPCType.HTTP) {
|
|
31
|
+
rpcMetadata.route = routeName;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// The span exporter picks up the `http.route` (ATTR_HTTP_ROUTE) attribute to set the transaction name
|
|
35
|
+
rootSpan.setAttributes({
|
|
36
|
+
[ATTR_HTTP_ROUTE]: routeName,
|
|
37
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return originalHandle(request, responseStatusCode, responseHeaders, routerContext, loadContext);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { sentryHandleRequest };
|
|
46
|
+
//# sourceMappingURL=sentryHandleRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryHandleRequest.js","sources":["../../../src/server/sentryHandleRequest.ts"],"sourcesContent":["import { context } from '@opentelemetry/api';\nimport { RPCType, getRPCMetadata } from '@opentelemetry/core';\nimport { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getRootSpan } from '@sentry/core';\nimport type { AppLoadContext, EntryContext } from 'react-router';\n\ntype OriginalHandleRequest = (\n request: Request,\n responseStatusCode: number,\n responseHeaders: Headers,\n routerContext: EntryContext,\n loadContext: AppLoadContext,\n) => Promise<unknown>;\n\n/**\n * Wraps the original handleRequest function to add Sentry instrumentation.\n *\n * @param originalHandle - The original handleRequest function to wrap\n * @returns A wrapped version of the handle request function with Sentry instrumentation\n */\nexport function sentryHandleRequest(originalHandle: OriginalHandleRequest): OriginalHandleRequest {\n return async function sentryInstrumentedHandleRequest(\n request: Request,\n responseStatusCode: number,\n responseHeaders: Headers,\n routerContext: EntryContext,\n loadContext: AppLoadContext,\n ) {\n const parameterizedPath =\n routerContext?.staticHandlerContext?.matches?.[routerContext.staticHandlerContext.matches.length - 1]?.route.path;\n if (parameterizedPath) {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const rootSpan = getRootSpan(activeSpan);\n const routeName = `/${parameterizedPath}`;\n\n // The express instrumentation writes on the rpcMetadata and that ends up stomping on the `http.route` attribute.\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = routeName;\n }\n\n // The span exporter picks up the `http.route` (ATTR_HTTP_ROUTE) attribute to set the transaction name\n rootSpan.setAttributes({\n [ATTR_HTTP_ROUTE]: routeName,\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',\n });\n }\n }\n return originalHandle(request, responseStatusCode, responseHeaders, routerContext, loadContext);\n };\n}\n"],"names":[],"mappings":";;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,cAAc,EAAgD;AAClG,EAAE,OAAO,eAAe,+BAA+B;AACvD,IAAI,OAAO;AACX,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,WAAW;AACf,IAAI;AACJ,IAAI,MAAM,iBAAkB;AAC5B,MAAM,aAAa,EAAE,oBAAoB,EAAE,OAAO,GAAG,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI;AACvH,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,MAAM,UAAA,GAAa,aAAa,EAAE;AACxC,MAAM,IAAI,UAAU,EAAE;AACtB,QAAQ,MAAM,QAAS,GAAE,WAAW,CAAC,UAAU,CAAC;AAChD,QAAQ,MAAM,YAAY,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;;AAEA;AACA,QAAA,MAAA,WAAA,GAAA,cAAA,CAAA,OAAA,CAAA,MAAA,EAAA,CAAA;AACA,QAAA,IAAA,WAAA,EAAA,IAAA,KAAA,OAAA,CAAA,IAAA,EAAA;AACA,UAAA,WAAA,CAAA,KAAA,GAAA,SAAA;AACA;;AAEA;AACA,QAAA,QAAA,CAAA,aAAA,CAAA;AACA,UAAA,CAAA,eAAA,GAAA,SAAA;AACA,UAAA,CAAA,gCAAA,GAAA,OAAA;AACA,SAAA,CAAA;AACA;AACA;AACA,IAAA,OAAA,cAAA,CAAA,OAAA,EAAA,kBAAA,EAAA,eAAA,EAAA,aAAA,EAAA,WAAA,CAAA;AACA,GAAA;AACA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/server/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/server/sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI5D;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAejE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AppLoadContext, EntryContext } from 'react-router';
|
|
2
|
+
type OriginalHandleRequest = (request: Request, responseStatusCode: number, responseHeaders: Headers, routerContext: EntryContext, loadContext: AppLoadContext) => Promise<unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Wraps the original handleRequest function to add Sentry instrumentation.
|
|
5
|
+
*
|
|
6
|
+
* @param originalHandle - The original handleRequest function to wrap
|
|
7
|
+
* @returns A wrapped version of the handle request function with Sentry instrumentation
|
|
8
|
+
*/
|
|
9
|
+
export declare function sentryHandleRequest(originalHandle: OriginalHandleRequest): OriginalHandleRequest;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=sentryHandleRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentryHandleRequest.d.ts","sourceRoot":"","sources":["../../../src/server/sentryHandleRequest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjE,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,mBAAmB,CAAC,cAAc,EAAE,qBAAqB,GAAG,qBAAqB,CA+BhG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/react-router",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.12.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",
|
|
@@ -34,10 +34,13 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@sentry/
|
|
37
|
+
"@opentelemetry/api": "^1.9.0",
|
|
38
|
+
"@opentelemetry/core": "^1.30.1",
|
|
39
|
+
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
40
|
+
"@sentry/browser": "9.12.0",
|
|
41
|
+
"@sentry/cli": "^2.43.0",
|
|
42
|
+
"@sentry/core": "9.12.0",
|
|
43
|
+
"@sentry/node": "9.12.0",
|
|
41
44
|
"@sentry/vite-plugin": "^3.2.4",
|
|
42
45
|
"glob": "11.0.1"
|
|
43
46
|
},
|
|
@@ -67,6 +70,7 @@
|
|
|
67
70
|
"clean": "rimraf build coverage sentry-react-router-*.tgz",
|
|
68
71
|
"fix": "eslint . --format stylish --fix",
|
|
69
72
|
"lint": "eslint . --format stylish",
|
|
73
|
+
"lint:es-compatibility": "es-check es2020 ./build/cjs/*.js && es-check es2020 ./build/esm/*.js --module",
|
|
70
74
|
"test": "yarn test:unit",
|
|
71
75
|
"test:unit": "vitest run",
|
|
72
76
|
"test:watch": "vitest --watch",
|