@depup/sentry__react 10.75.2-depup.0 → 11.1.0-depup.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/README.md +3 -9
- package/build/cjs/error.js +4 -10
- package/build/cjs/error.js.map +1 -1
- package/build/cjs/hoist-non-react-statics.js +1 -7
- package/build/cjs/hoist-non-react-statics.js.map +1 -1
- package/build/cjs/profiler.js +45 -19
- package/build/cjs/profiler.js.map +1 -1
- package/build/cjs/react-router.js +21 -0
- package/build/cjs/react-router.js.map +1 -0
- package/build/cjs/reactrouter-compat-utils/instrumentation.js +200 -192
- package/build/cjs/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/route-manifest.js +4 -4
- package/build/cjs/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/cjs/reactrouter-compat-utils/utils.js +34 -37
- package/build/cjs/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/cjs/reactrouter.compat.js +0 -3
- package/build/cjs/reactrouter.compat.js.map +1 -1
- package/build/cjs/reactrouter.js +14 -8
- package/build/cjs/reactrouter.js.map +1 -1
- package/build/cjs/reactrouterv3.js +12 -9
- package/build/cjs/reactrouterv3.js.map +1 -1
- package/build/cjs/reactrouterv6.js +0 -3
- package/build/cjs/reactrouterv6.js.map +1 -1
- package/build/cjs/reactrouterv7.js +0 -3
- package/build/cjs/reactrouterv7.js.map +1 -1
- package/build/cjs/redux.js +6 -6
- package/build/cjs/redux.js.map +1 -1
- package/build/cjs/sdk.js +7 -7
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/tanstackrouter.js +23 -13
- package/build/cjs/tanstackrouter.js.map +1 -1
- package/build/esm/error.js +3 -8
- package/build/esm/error.js.map +1 -1
- package/build/esm/hoist-non-react-statics.js +1 -7
- package/build/esm/hoist-non-react-statics.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/profiler.js +47 -21
- package/build/esm/profiler.js.map +1 -1
- package/build/esm/react-router.js +16 -0
- package/build/esm/react-router.js.map +1 -0
- package/build/esm/reactrouter-compat-utils/instrumentation.js +203 -195
- package/build/esm/reactrouter-compat-utils/instrumentation.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/route-manifest.js +1 -1
- package/build/esm/reactrouter-compat-utils/route-manifest.js.map +1 -1
- package/build/esm/reactrouter-compat-utils/utils.js +32 -34
- package/build/esm/reactrouter-compat-utils/utils.js.map +1 -1
- package/build/esm/reactrouter.compat.js +0 -3
- package/build/esm/reactrouter.compat.js.map +1 -1
- package/build/esm/reactrouter.js +16 -10
- package/build/esm/reactrouter.js.map +1 -1
- package/build/esm/reactrouterv3.js +11 -8
- package/build/esm/reactrouterv3.js.map +1 -1
- package/build/esm/reactrouterv6.js +0 -3
- package/build/esm/reactrouterv6.js.map +1 -1
- package/build/esm/reactrouterv7.js +0 -3
- package/build/esm/reactrouterv7.js.map +1 -1
- package/build/esm/redux.js +1 -1
- package/build/esm/redux.js.map +1 -1
- package/build/esm/sdk.js +1 -1
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/tanstackrouter.js +23 -13
- package/build/esm/tanstackrouter.js.map +1 -1
- package/build/types/error.d.ts +0 -4
- package/build/types/error.d.ts.map +1 -1
- package/build/types/errorboundary.d.ts.map +1 -1
- package/build/types/hoist-non-react-statics.d.ts.map +1 -1
- package/build/types/profiler.d.ts +0 -1
- package/build/types/profiler.d.ts.map +1 -1
- package/build/types/react-router.d.ts +26 -0
- package/build/types/react-router.d.ts.map +1 -0
- package/build/types/reactrouter-compat-utils/index.d.ts +1 -1
- package/build/types/reactrouter-compat-utils/index.d.ts.map +1 -1
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts +9 -5
- package/build/types/reactrouter-compat-utils/instrumentation.d.ts.map +1 -1
- package/build/types/reactrouter-compat-utils/utils.d.ts +6 -11
- package/build/types/reactrouter-compat-utils/utils.d.ts.map +1 -1
- package/build/types/reactrouter.d.ts +16 -0
- package/build/types/reactrouter.d.ts.map +1 -1
- package/build/types/reactrouterv3.d.ts +1 -1
- package/build/types/reactrouterv3.d.ts.map +1 -1
- package/build/types/redux.d.ts +1 -1
- package/build/types/redux.d.ts.map +1 -1
- package/build/types/sdk.d.ts +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/tanstackrouter.d.ts +1 -1
- package/build/types/tanstackrouter.d.ts.map +1 -1
- package/build/types/types.d.ts +16 -0
- package/build/types/types.d.ts.map +1 -1
- package/changes.json +3 -8
- package/package.json +39 -26
- package/build/cjs/constants.js +0 -10
- package/build/cjs/constants.js.map +0 -1
- package/build/esm/constants.js +0 -6
- package/build/esm/constants.js.map +0 -1
- package/build/types/constants.d.ts +0 -4
- package/build/types/constants.d.ts.map +0 -1
- package/build/types-ts3.8/constants.d.ts +0 -4
- package/build/types-ts3.8/debug-build.d.ts +0 -7
- package/build/types-ts3.8/error.d.ts +0 -41
- package/build/types-ts3.8/errorboundary.d.ts +0 -87
- package/build/types-ts3.8/hoist-non-react-statics.d.ts +0 -21
- package/build/types-ts3.8/index.d.ts +0 -14
- package/build/types-ts3.8/isSyntheticEvent.d.ts +0 -10
- package/build/types-ts3.8/profiler.d.ts +0 -56
- package/build/types-ts3.8/reactrouter-compat-utils/index.d.ts +0 -5
- package/build/types-ts3.8/reactrouter-compat-utils/instrumentation.d.ts +0 -117
- package/build/types-ts3.8/reactrouter-compat-utils/lazy-routes.d.ts +0 -18
- package/build/types-ts3.8/reactrouter-compat-utils/route-manifest.d.ts +0 -13
- package/build/types-ts3.8/reactrouter-compat-utils/utils.d.ts +0 -77
- package/build/types-ts3.8/reactrouter.compat.d.ts +0 -42
- package/build/types-ts3.8/reactrouter.d.ts +0 -41
- package/build/types-ts3.8/reactrouterv3.d.ts +0 -29
- package/build/types-ts3.8/reactrouterv6.d.ts +0 -42
- package/build/types-ts3.8/reactrouterv7.d.ts +0 -42
- package/build/types-ts3.8/redux.d.ts +0 -38
- package/build/types-ts3.8/sdk.d.ts +0 -7
- package/build/types-ts3.8/tanstackrouter.d.ts +0 -13
- package/build/types-ts3.8/types.d.ts +0 -163
- package/build/types-ts3.8/vendor/tanstackrouter-types.d.ts +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactrouterv7.js","sources":["../../src/reactrouterv7.tsx"],"sourcesContent":["// React Router v7 uses the same integration as v6\nimport type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v7 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n *\n * @deprecated Use `reactRouterBrowserTracingIntegration` instead.\n */\nexport function reactRouterV7BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '7');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v7 Route component.\n * This is used to automatically capture route changes as transactions.\n *\n * @deprecated Use `wrapReactRouterRouting` instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV7Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n *\n * @deprecated Use `wrapCreateBrowserRouter` instead.\n */\nexport function wrapCreateBrowserRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n *\n * @deprecated Use `wrapCreateMemoryRouter` instead.\n */\nexport function wrapCreateMemoryRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n *\n * @deprecated Use `wrapUseRoutes` instead.\n */\nexport function wrapUseRoutesV7(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '7');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWithSentryReactRouterRouting","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWrapUseRoutes"],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactrouterv7.js","sources":["../../src/reactrouterv7.tsx"],"sourcesContent":["// React Router v7 uses the same integration as v6\nimport type { browserTracingIntegration } from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport type { ReactRouterOptions } from './reactrouter-compat-utils';\nimport {\n createReactRouterV6CompatibleTracingIntegration,\n createV6CompatibleWithSentryReactRouterRouting,\n createV6CompatibleWrapCreateBrowserRouter,\n createV6CompatibleWrapCreateMemoryRouter,\n createV6CompatibleWrapUseRoutes,\n} from './reactrouter-compat-utils';\nimport type { CreateRouterFunction, Router, RouterState, UseRoutes } from './types';\n\n/**\n * A browser tracing integration that uses React Router v7 to instrument navigations.\n * Expects `useEffect`, `useLocation`, `useNavigationType`, `createRoutesFromChildren` and `matchRoutes` to be passed as options.\n *\n * @deprecated Use `reactRouterBrowserTracingIntegration` instead.\n */\nexport function reactRouterV7BrowserTracingIntegration(\n options: Parameters<typeof browserTracingIntegration>[0] & ReactRouterOptions,\n): Integration {\n return createReactRouterV6CompatibleTracingIntegration(options, '7');\n}\n\n/**\n * A higher-order component that adds Sentry routing instrumentation to a React Router v7 Route component.\n * This is used to automatically capture route changes as transactions.\n *\n * @deprecated Use `wrapReactRouterRouting` instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withSentryReactRouterV7Routing<P extends Record<string, any>, R extends React.FC<P>>(routes: R): R {\n return createV6CompatibleWithSentryReactRouterRouting<P, R>(routes, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createBrowserRouter function.\n * This is used to automatically capture route changes as transactions when using the createBrowserRouter API.\n *\n * @deprecated Use `wrapCreateBrowserRouter` instead.\n */\nexport function wrapCreateBrowserRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateBrowserRouter(createRouterFunction, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 createMemoryRouter function.\n * This is used to automatically capture route changes as transactions when using the createMemoryRouter API.\n * The difference between createBrowserRouter and createMemoryRouter is that with createMemoryRouter,\n * optional `initialEntries` are also taken into account.\n *\n * @deprecated Use `wrapCreateMemoryRouter` instead.\n */\nexport function wrapCreateMemoryRouterV7<\n TState extends RouterState = RouterState,\n TRouter extends Router<TState> = Router<TState>,\n>(createMemoryRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {\n return createV6CompatibleWrapCreateMemoryRouter(createMemoryRouterFunction, '7');\n}\n\n/**\n * A wrapper function that adds Sentry routing instrumentation to a React Router v7 useRoutes hook.\n * This is used to automatically capture route changes as transactions when using the useRoutes hook.\n *\n * @deprecated Use `wrapUseRoutes` instead.\n */\nexport function wrapUseRoutesV7(origUseRoutes: UseRoutes): UseRoutes {\n return createV6CompatibleWrapUseRoutes(origUseRoutes, '7');\n}\n"],"names":["createReactRouterV6CompatibleTracingIntegration","createV6CompatibleWithSentryReactRouterRouting","createV6CompatibleWrapCreateBrowserRouter","createV6CompatibleWrapCreateMemoryRouter","createV6CompatibleWrapUseRoutes"],"mappings":";;;;AAmBO,SAAS,uCACd,OAAA,EACa;AACb,EAAA,OAAOA,+DAAA,CAAgD,SAAS,GAAG,CAAA;AACrE;AASO,SAAS,+BAAqF,MAAA,EAAc;AACjH,EAAA,OAAOC,8DAAA,CAAqD,QAAQ,GAAG,CAAA;AACzE;AAQO,SAAS,0BAGd,oBAAA,EAAoG;AACpG,EAAA,OAAOC,yDAAA,CAA0C,sBAAsB,GAAG,CAAA;AAC5E;AAUO,SAAS,yBAGd,0BAAA,EAA0G;AAC1G,EAAA,OAAOC,wDAAA,CAAyC,4BAA4B,GAAG,CAAA;AACjF;AAQO,SAAS,gBAAgB,aAAA,EAAqC;AACnE,EAAA,OAAOC,+CAAA,CAAgC,eAAe,GAAG,CAAA;AAC3D;;;;;;;;"}
|
package/build/cjs/redux.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
4
|
|
|
5
5
|
const ACTION_BREADCRUMB_CATEGORY = "redux.action";
|
|
6
6
|
const ACTION_BREADCRUMB_TYPE = "info";
|
|
@@ -15,7 +15,7 @@ function createReduxEnhancer(enhancerOptions) {
|
|
|
15
15
|
...enhancerOptions
|
|
16
16
|
};
|
|
17
17
|
return (next) => (reducer, initialState) => {
|
|
18
|
-
options.attachReduxState &&
|
|
18
|
+
options.attachReduxState && core.getGlobalScope().addEventProcessor((event, hint) => {
|
|
19
19
|
try {
|
|
20
20
|
if (event.type === void 0 && event.contexts.state.state.type === "redux") {
|
|
21
21
|
hint.attachments = [
|
|
@@ -31,10 +31,10 @@ function createReduxEnhancer(enhancerOptions) {
|
|
|
31
31
|
function sentryWrapReducer(reducer2) {
|
|
32
32
|
return (state, action) => {
|
|
33
33
|
const newState = reducer2(state, action);
|
|
34
|
-
const scope =
|
|
34
|
+
const scope = core.getCurrentScope();
|
|
35
35
|
const transformedAction = options.actionTransformer(action);
|
|
36
36
|
if (typeof transformedAction !== "undefined" && transformedAction !== null) {
|
|
37
|
-
|
|
37
|
+
core.addBreadcrumb({
|
|
38
38
|
category: ACTION_BREADCRUMB_CATEGORY,
|
|
39
39
|
data: transformedAction,
|
|
40
40
|
type: ACTION_BREADCRUMB_TYPE
|
|
@@ -42,11 +42,11 @@ function createReduxEnhancer(enhancerOptions) {
|
|
|
42
42
|
}
|
|
43
43
|
const transformedState = options.stateTransformer(newState);
|
|
44
44
|
if (typeof transformedState !== "undefined" && transformedState !== null) {
|
|
45
|
-
const client =
|
|
45
|
+
const client = core.getClient();
|
|
46
46
|
const options2 = client?.getOptions();
|
|
47
47
|
const normalizationDepth = options2?.normalizeDepth || 3;
|
|
48
48
|
const newStateContext = { state: { type: "redux", value: transformedState } };
|
|
49
|
-
|
|
49
|
+
core.setNormalizationDepthOverrideHint(
|
|
50
50
|
newStateContext,
|
|
51
51
|
3 + // 3 layers for `state.value.transformedState`
|
|
52
52
|
normalizationDepth
|
package/build/cjs/redux.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Scope } from '@sentry/core
|
|
1
|
+
{"version":3,"file":"redux.js","sources":["../../src/redux.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Scope } from '@sentry/core';\nimport {\n addBreadcrumb,\n getClient,\n getCurrentScope,\n getGlobalScope,\n setNormalizationDepthOverrideHint,\n} from '@sentry/core';\n\ninterface Action<T = any> {\n type: T;\n}\n\ninterface AnyAction extends Action {\n [extraProps: string]: any;\n}\n\ntype Reducer<S = any, A extends Action = AnyAction> = (state: S | undefined, action: A) => S;\n\ntype Dispatch<A extends Action = AnyAction> = <T extends A>(action: T, ...extraArgs: any[]) => T;\n\ntype ExtendState<State, Extension> = [Extension] extends [never] ? State : State & Extension;\n\ntype Unsubscribe = () => void;\n\ninterface Store<S = any, A extends Action = AnyAction, StateExt = never, Ext = Record<string, unknown>> {\n dispatch: Dispatch<A>;\n getState(): S;\n subscribe(listener: () => void): Unsubscribe;\n replaceReducer<NewState, NewActions extends Action>(\n nextReducer: Reducer<NewState, NewActions>,\n ): Store<ExtendState<NewState, StateExt>, NewActions, StateExt, Ext> & Ext;\n}\n\ndeclare const $CombinedState: unique symbol;\n\ntype CombinedState<S> = { readonly [$CombinedState]?: undefined } & S;\n\ntype PreloadedState<S> =\n Required<S> extends {\n [$CombinedState]: undefined;\n }\n ? S extends CombinedState<infer S1>\n ? { [K in keyof S1]?: S1[K] extends Record<string, unknown> ? PreloadedState<S1[K]> : S1[K] }\n : never\n : { [K in keyof S]: S[K] extends string | number | boolean | symbol ? S[K] : PreloadedState<S[K]> };\n\ntype StoreEnhancerStoreCreator<Ext = Record<string, unknown>, StateExt = never> = <\n S = any,\n A extends Action = AnyAction,\n>(\n reducer: Reducer<S, A>,\n preloadedState?: PreloadedState<S>,\n) => Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext;\n\nexport interface SentryEnhancerOptions<S = any> {\n /**\n * Redux state in attachments or not.\n * @default true\n */\n attachReduxState?: boolean;\n\n /**\n * Transforms the state before attaching it to an event.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not attach the state.\n */\n stateTransformer(state: S | undefined): (S & any) | null;\n /**\n * Transforms the action before sending it as a breadcrumb.\n * Use this to remove any private data before sending it to Sentry.\n * Return null to not send the breadcrumb.\n */\n actionTransformer(action: AnyAction): AnyAction | null;\n /**\n * Called on every state update, configure the Sentry Scope with the redux state.\n */\n configureScopeWithState?(scope: Scope, state: S): void;\n}\n\nconst ACTION_BREADCRUMB_CATEGORY = 'redux.action';\nconst ACTION_BREADCRUMB_TYPE = 'info';\n\nconst defaultOptions: SentryEnhancerOptions = {\n attachReduxState: true,\n actionTransformer: action => action,\n stateTransformer: state => state || null,\n};\n\n/**\n * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.\n *\n * @param enhancerOptions Options to pass to the enhancer\n */\nfunction createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any {\n // Note: We return an any type as to not have type conflicts.\n const options = {\n ...defaultOptions,\n ...enhancerOptions,\n };\n\n return (next: StoreEnhancerStoreCreator): StoreEnhancerStoreCreator =>\n <S = any, A extends Action = AnyAction>(reducer: Reducer<S, A>, initialState?: PreloadedState<S>) => {\n options.attachReduxState &&\n getGlobalScope().addEventProcessor((event, hint) => {\n try {\n // @ts-expect-error try catch to reduce bundle size\n if (event.type === undefined && event.contexts.state.state.type === 'redux') {\n hint.attachments = [\n ...(hint.attachments || []),\n // @ts-expect-error try catch to reduce bundle size\n { filename: 'redux_state.json', data: JSON.stringify(event.contexts.state.state.value) },\n ];\n }\n } catch {\n // empty\n }\n return event;\n });\n\n function sentryWrapReducer(reducer: Reducer<S, A>): Reducer<S, A> {\n return (state, action): S => {\n const newState = reducer(state, action);\n\n const scope = getCurrentScope();\n\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n addBreadcrumb({\n category: ACTION_BREADCRUMB_CATEGORY,\n data: transformedAction,\n type: ACTION_BREADCRUMB_TYPE,\n });\n }\n\n /* Set latest state to scope */\n const transformedState = options.stateTransformer(newState);\n if (typeof transformedState !== 'undefined' && transformedState !== null) {\n const client = getClient();\n const options = client?.getOptions();\n const normalizationDepth = options?.normalizeDepth || 3; // default state normalization depth to 3\n\n // Set the normalization depth of the redux state to the configured `normalizeDepth` option or a sane number as a fallback\n const newStateContext = { state: { type: 'redux', value: transformedState } };\n setNormalizationDepthOverrideHint(\n newStateContext,\n 3 + // 3 layers for `state.value.transformedState`\n normalizationDepth, // rest for the actual state\n );\n\n scope.setContext('state', newStateContext);\n } else {\n scope.setContext('state', null);\n }\n\n /* Allow user to configure scope with latest state */\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n\n return newState;\n };\n }\n\n const store = next(sentryWrapReducer(reducer), initialState);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n store.replaceReducer = new Proxy(store.replaceReducer, {\n apply: function (target, thisArg, args) {\n target.apply(thisArg, [sentryWrapReducer(args[0])]);\n },\n });\n\n return store;\n };\n}\n\nexport { createReduxEnhancer };\n"],"names":["getGlobalScope","reducer","getCurrentScope","addBreadcrumb","getClient","options","setNormalizationDepthOverrideHint"],"mappings":";;;;AAiFA,MAAM,0BAAA,GAA6B,cAAA;AACnC,MAAM,sBAAA,GAAyB,MAAA;AAE/B,MAAM,cAAA,GAAwC;AAAA,EAC5C,gBAAA,EAAkB,IAAA;AAAA,EAClB,mBAAmB,CAAA,MAAA,KAAU,MAAA;AAAA,EAC7B,gBAAA,EAAkB,WAAS,KAAA,IAAS;AACtC,CAAA;AAOA,SAAS,oBAAoB,eAAA,EAAuD;AAElF,EAAA,MAAM,OAAA,GAAU;AAAA,IACd,GAAG,cAAA;AAAA,IACH,GAAG;AAAA,GACL;AAEA,EAAA,OAAO,CAAC,IAAA,KACN,CAAwC,OAAA,EAAwB,YAAA,KAAqC;AACnG,IAAA,OAAA,CAAQ,oBACNA,mBAAA,EAAe,CAAE,iBAAA,CAAkB,CAAC,OAAO,IAAA,KAAS;AAClD,MAAA,IAAI;AAEF,QAAA,IAAI,KA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AA,MAAM,eAAA,GAAkB,EAAE,KAAA,EAAO,EAAE,MAAM,OAAA,EAAS,KAAA,EAAO,kBAAiB,EAAE;AAC5E,UAAAC,sCAAA;AAAA,YACE,eAAA;AAAA,YACA,CAAA;AAAA,YACE;AAAA;AAAA,WACJ;AAEA,UAAA,KAAA,CAAM,UAAA,CAAW,SAAS,eAAe,CAAA;AAAA,QAC3C,CAAA,MAAO;AACL,UAAA,KAAA,CAAM,UAAA,CAAW,SAAS,IAAI,CAAA;AAAA,QAChC;AAGA,QAAA,MAAM,EAAE,yBAAwB,GAAI,OAAA;AACpC,QAAA,IAAI,OAAO,4BAA4B,UAAA,EAAY;AACjD,UAAA,uBAAA,CAAwB,OAAO,QAAQ,CAAA;AAAA,QACzC;AAEA,QAAA,OAAO,QAAA;AAAA,MACT,CAAA;AAAA,IACF;AAEA,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,iBAAA,CAAkB,OAAO,GAAG,YAAY,CAAA;AAG3D,IAAA,KAAA,CAAM,cAAA,GAAiB,IAAI,KAAA,CAAM,KAAA,CAAM,cAAA,EAAgB;AAAA,MACrD,KAAA,EAAO,SAAU,MAAA,EAAQ,OAAA,EAAS,IAAA,EAAM;AACtC,QAAA,MAAA,CAAO,KAAA,CAAM,SAAS,CAAC,iBAAA,CAAkB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAAA,MACpD;AAAA,KACD,CAAA;AAED,IAAA,OAAO,KAAA;AAAA,EACT,CAAA;AACJ;;;;"}
|
package/build/cjs/sdk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const browser
|
|
4
|
-
const
|
|
3
|
+
const browser = require('@sentry/browser');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
5
|
const React = require('react');
|
|
6
6
|
const isSyntheticEvent = require('./isSyntheticEvent.js');
|
|
7
7
|
|
|
@@ -9,17 +9,17 @@ function init(options) {
|
|
|
9
9
|
const opts = {
|
|
10
10
|
...options
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
browser
|
|
14
|
-
const client = browser
|
|
15
|
-
|
|
12
|
+
core.applySdkMetadata(opts, "react");
|
|
13
|
+
browser.setContext("react", { version: React.version });
|
|
14
|
+
const client = browser.init(opts);
|
|
15
|
+
core.setNormalizeStringifier(normalizeStringifyValue);
|
|
16
16
|
return client;
|
|
17
17
|
}
|
|
18
18
|
function normalizeStringifyValue(value) {
|
|
19
19
|
if (isSyntheticEvent.isSyntheticEvent(value)) {
|
|
20
20
|
return "[SyntheticEvent]";
|
|
21
21
|
}
|
|
22
|
-
return browser
|
|
22
|
+
return browser.normalizeStringifyValue(value);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
exports.init = init;
|
package/build/cjs/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {\n init as browserInit,\n normalizeStringifyValue as browserNormalizeStringifyValue,\n setContext,\n} from '@sentry/browser';\nimport type { Client } from '@sentry/core
|
|
1
|
+
{"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport {\n init as browserInit,\n normalizeStringifyValue as browserNormalizeStringifyValue,\n setContext,\n} from '@sentry/browser';\nimport type { Client } from '@sentry/core';\nimport { applySdkMetadata, setNormalizeStringifier } from '@sentry/core';\nimport { version } from 'react';\nimport { isSyntheticEvent } from './isSyntheticEvent';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'react');\n setContext('react', { version });\n const client = browserInit(opts);\n\n // Add react-specific stringification\n setNormalizeStringifier(normalizeStringifyValue);\n\n return client;\n}\n\nfunction normalizeStringifyValue(value: Exclude<unknown, string | number | boolean | null>): string | undefined {\n if (isSyntheticEvent(value)) {\n return '[SyntheticEvent]';\n }\n return browserNormalizeStringifyValue(value);\n}\n"],"names":["applySdkMetadata","setContext","version","browserInit","setNormalizeStringifier","isSyntheticEvent","browserNormalizeStringifyValue"],"mappings":";;;;;;;AAcO,SAAS,KAAK,OAAA,EAA6C;AAChE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,MAAM,OAAO,CAAA;AAC9B,EAAAC,kBAAA,CAAW,OAAA,EAAS,WAAEC,aAAA,EAAS,CAAA;AAC/B,EAAA,MAAM,MAAA,GAASC,aAAY,IAAI,CAAA;AAG/B,EAAAC,4BAAA,CAAwB,uBAAuB,CAAA;AAE/C,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,wBAAwB,KAAA,EAA+E;AAC9G,EAAA,IAAIC,iCAAA,CAAiB,KAAK,CAAA,EAAG;AAC3B,IAAA,OAAO,kBAAA;AAAA,EACT;AACA,EAAA,OAAOC,gCAA+B,KAAK,CAAA;AAC7C;;;;"}
|
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const browser = require('@sentry/browser');
|
|
4
4
|
const core = require('@sentry/core');
|
|
5
|
-
const browser$1 = require('@sentry/core/browser');
|
|
6
5
|
const attributes = require('@sentry/conventions/attributes');
|
|
6
|
+
const op = require('@sentry/conventions/op');
|
|
7
7
|
|
|
8
8
|
function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
9
9
|
const castRouterInstance = router;
|
|
@@ -27,7 +27,7 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
27
27
|
};
|
|
28
28
|
const applyRouteMatch = (span, match, toLocation, fallbackName) => {
|
|
29
29
|
span.updateName(match ? match.routeId : fallbackName);
|
|
30
|
-
span.setAttribute(
|
|
30
|
+
span.setAttribute(attributes.SENTRY_SEGMENT_NAME_SOURCE, match ? "route" : "url");
|
|
31
31
|
span.setAttributes({
|
|
32
32
|
...match && { [attributes.URL_TEMPLATE]: match.routeId },
|
|
33
33
|
...locationToSpanUrlAttributes(castRouterInstance, toLocation),
|
|
@@ -42,11 +42,12 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
42
42
|
castRouterInstance.options.parseSearch(initialWindowLocation.search)
|
|
43
43
|
);
|
|
44
44
|
const pageloadSpan = browser.startBrowserTracingPageLoadSpan(client, {
|
|
45
|
-
|
|
45
|
+
// With span streaming, span names have to be low cardinality, so we can't fall back to the URL.
|
|
46
|
+
name: routeMatch ? routeMatch.routeId : core.hasSpanStreamingEnabled(client) ? core.PAGELOAD_SPAN_NAME_FALLBACK : initialWindowLocation.pathname,
|
|
46
47
|
attributes: {
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
48
|
+
[attributes.SENTRY_OP]: op.PAGELOAD,
|
|
49
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.pageload.react.tanstack_router",
|
|
50
|
+
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: routeMatch ? "route" : "url",
|
|
50
51
|
...routeMatch && { [attributes.URL_TEMPLATE]: routeMatch.routeId },
|
|
51
52
|
...routeMatchToParamSpanAttributes(routeMatch)
|
|
52
53
|
}
|
|
@@ -58,7 +59,12 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
58
59
|
}
|
|
59
60
|
const { toLocation } = onResolvedArgs;
|
|
60
61
|
const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);
|
|
61
|
-
applyRouteMatch(
|
|
62
|
+
applyRouteMatch(
|
|
63
|
+
pageloadSpan,
|
|
64
|
+
resolvedMatch,
|
|
65
|
+
toLocation,
|
|
66
|
+
core.hasSpanStreamingEnabled(client) ? core.PAGELOAD_SPAN_NAME_FALLBACK : toLocation.pathname
|
|
67
|
+
);
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
70
|
if (instrumentNavigation) {
|
|
@@ -69,7 +75,7 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
77
|
const routeMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);
|
|
72
|
-
const fallbackName = browser.WINDOW.location?.pathname || toLocation.pathname;
|
|
78
|
+
const fallbackName = core.hasSpanStreamingEnabled(client) ? core.NAVIGATION_SPAN_NAME_FALLBACK : browser.WINDOW.location?.pathname || toLocation.pathname;
|
|
73
79
|
if (inFlightNavigationSpan) {
|
|
74
80
|
applyRouteMatch(inFlightNavigationSpan, routeMatch, toLocation, fallbackName);
|
|
75
81
|
return;
|
|
@@ -79,9 +85,9 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
79
85
|
{
|
|
80
86
|
name: routeMatch ? routeMatch.routeId : fallbackName,
|
|
81
87
|
attributes: {
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
88
|
+
[attributes.SENTRY_OP]: op.NAVIGATION,
|
|
89
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.navigation.react.tanstack_router",
|
|
90
|
+
[attributes.SENTRY_SEGMENT_NAME_SOURCE]: routeMatch ? "route" : "url",
|
|
85
91
|
...routeMatch && { [attributes.URL_TEMPLATE]: routeMatch.routeId },
|
|
86
92
|
...routeMatchToParamSpanAttributes(routeMatch)
|
|
87
93
|
}
|
|
@@ -98,7 +104,12 @@ function tanstackRouterBrowserTracingIntegration(router, options = {}) {
|
|
|
98
104
|
const { toLocation } = onResolvedArgs;
|
|
99
105
|
const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);
|
|
100
106
|
if (resolvedMatch) {
|
|
101
|
-
applyRouteMatch(
|
|
107
|
+
applyRouteMatch(
|
|
108
|
+
span,
|
|
109
|
+
resolvedMatch,
|
|
110
|
+
toLocation,
|
|
111
|
+
core.hasSpanStreamingEnabled(client) ? core.NAVIGATION_SPAN_NAME_FALLBACK : browser.WINDOW.location?.pathname || toLocation.pathname
|
|
112
|
+
);
|
|
102
113
|
}
|
|
103
114
|
});
|
|
104
115
|
}
|
|
@@ -123,7 +134,6 @@ function routeMatchToParamSpanAttributes(match) {
|
|
|
123
134
|
}
|
|
124
135
|
const paramAttributes = {};
|
|
125
136
|
Object.entries(match.params).forEach(([key, value]) => {
|
|
126
|
-
paramAttributes[`url.path.params.${key}`] = value;
|
|
127
137
|
paramAttributes[`${attributes.URL_PATH_PARAMETER_KEY_BASE}.${key}`] = value;
|
|
128
138
|
paramAttributes[`${attributes.PARAMS_KEY_BASE}.${key}`] = value;
|
|
129
139
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import {\n browserTracingIntegration as originalBrowserTracingIntegration,\n getAbsoluteUrl,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n WINDOW,\n} from '@sentry/browser';\nimport type { Integration } from '@sentry/core/browser';\nimport { filterCollectedUrl } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n} from '@sentry/core/browser';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\nimport {\n PARAMS_KEY_BASE,\n URL_FULL,\n URL_PATH,\n URL_PATH_PARAMETER_KEY_BASE,\n URL_TEMPLATE,\n} from '@sentry/conventions/attributes';\n\ninterface TanstackRouterLocation {\n pathname: string;\n search: Record<string, unknown>;\n state?: unknown;\n}\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/react-router` is `1.64.0`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const resolveRouteMatch = (pathname: string, search: unknown): VendoredTanstackRouterRouteMatch | undefined => {\n const matchedRoutes = castRouterInstance.matchRoutes(pathname, search as {}, {\n preload: false,\n throwOnError: false,\n });\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n // If we only match __root__, we ended up not matching any route at all, so\n // we fall back to the pathname.\n return lastMatch?.routeId !== '__root__' ? lastMatch : undefined;\n };\n\n const applyRouteMatch = (\n span: NonNullable<ReturnType<typeof startBrowserTracingPageLoadSpan>>,\n match: VendoredTanstackRouterRouteMatch | undefined,\n toLocation: TanstackRouterLocation,\n fallbackName: string,\n ): void => {\n span.updateName(match ? match.routeId : fallbackName);\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, match ? 'route' : 'url');\n span.setAttributes({\n ...(match && { [URL_TEMPLATE]: match.routeId }),\n ...locationToSpanUrlAttributes(castRouterInstance, toLocation),\n ...routeMatchToParamSpanAttributes(match),\n });\n };\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const initialRouterLocation = castRouterInstance.state?.location;\n const routeMatch = initialRouterLocation\n ? resolveRouteMatch(initialRouterLocation.pathname, initialRouterLocation.search)\n : resolveRouteMatch(\n initialWindowLocation.pathname,\n castRouterInstance.options.parseSearch(initialWindowLocation.search),\n );\n\n const pageloadSpan = startBrowserTracingPageLoadSpan(client, {\n name: routeMatch ? routeMatch.routeId : initialWindowLocation.pathname,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'pageload',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ? 'route' : 'url',\n ...(routeMatch && { [URL_TEMPLATE]: routeMatch.routeId }),\n ...routeMatchToParamSpanAttributes(routeMatch),\n },\n });\n\n // A redirect thrown during the initial pageload leaves the span named after the pre-redirect\n // route, so correct it to the resolved route once.\n const unsubscribePageloadResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribePageloadResolved();\n if (!pageloadSpan) {\n return;\n }\n const { toLocation } = onResolvedArgs;\n const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n applyRouteMatch(pageloadSpan, resolvedMatch, toLocation, toLocation.pathname);\n });\n }\n\n if (instrumentNavigation) {\n // Navigation is driven by `onBeforeLoad` (accurate start) + `onResolved` (final route), not\n // `onBeforeNavigate`, which TanStack stops firing after any loader redirect (TanStack/router#3920).\n // A redirect chain emits one `onBeforeLoad` per load but a single `onResolved`, so we start the\n // span on the first `onBeforeLoad`, rename it on later ones, and clear it on `onResolved`.\n let inFlightNavigationSpan: ReturnType<typeof startBrowserTracingNavigationSpan> | undefined;\n\n castRouterInstance.subscribe('onBeforeLoad', onBeforeLoadArgs => {\n const { toLocation, fromLocation } = onBeforeLoadArgs;\n // Skip the initial pageload (no fromLocation) and no-op reloads (same state).\n if (!fromLocation || toLocation.state === fromLocation.state) {\n return;\n }\n\n const routeMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n const fallbackName = WINDOW.location?.pathname || toLocation.pathname;\n\n if (inFlightNavigationSpan) {\n // Redirect continuation within the same navigation: keep the span, update the target.\n applyRouteMatch(inFlightNavigationSpan, routeMatch, toLocation, fallbackName);\n return;\n }\n\n inFlightNavigationSpan = startBrowserTracingNavigationSpan(\n client,\n {\n name: routeMatch ? routeMatch.routeId : fallbackName,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: routeMatch ? 'route' : 'url',\n ...(routeMatch && { [URL_TEMPLATE]: routeMatch.routeId }),\n ...routeMatchToParamSpanAttributes(routeMatch),\n },\n },\n { url: locationToAbsoluteUrl(castRouterInstance, toLocation) },\n );\n });\n\n castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n const span = inFlightNavigationSpan;\n inFlightNavigationSpan = undefined;\n if (!span) {\n return;\n }\n const { toLocation } = onResolvedArgs;\n const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n if (resolvedMatch) {\n applyRouteMatch(span, resolvedMatch, toLocation, WINDOW.location?.pathname || toLocation.pathname);\n }\n });\n }\n },\n };\n}\n\nfunction locationToAbsoluteUrl(router: VendoredTanstackRouter, location: TanstackRouterLocation): string {\n const search = router.options.stringifySearch?.(location.search) ?? '';\n const pathWithSearch = `${location.pathname}${search && search !== '?' ? search : ''}`;\n\n return getAbsoluteUrl(pathWithSearch);\n}\n\nfunction locationToSpanUrlAttributes(\n router: VendoredTanstackRouter,\n location: TanstackRouterLocation,\n): Record<string, string> {\n const absoluteUrl = locationToAbsoluteUrl(router, location);\n\n return {\n [URL_PATH]: location.pathname,\n [URL_FULL]: filterCollectedUrl(absoluteUrl),\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n Object.entries(match.params).forEach(([key, value]) => {\n paramAttributes[`url.path.params.${key}`] = value; // TODO(v11): remove attribute which does not adhere to Sentry's semantic convention\n paramAttributes[`${URL_PATH_PARAMETER_KEY_BASE}.${key}`] = value;\n paramAttributes[`${PARAMS_KEY_BASE}.${key}`] = value; // params.[key] is an alias\n });\n\n return paramAttributes;\n}\n"],"names":["originalBrowserTracingIntegration","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","URL_TEMPLATE","WINDOW","startBrowserTracingPageLoadSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startBrowserTracingNavigationSpan","getAbsoluteUrl","URL_PATH","URL_FULL","filterCollectedUrl","URL_PATH_PARAMETER_KEY_BASE","PARAMS_KEY_BASE"],"mappings":";;;;;;;AAqCO,SAAS,uCAAA,CAEd,MAAA,EACA,OAAA,GAAmE,EAAC,EACvD;AACb,EAAA,MAAM,kBAAA,GAA6C,MAAA;AAEnD,EAAA,MAAM,oCAAoCA,iCAAA,CAAkC;AAAA,IAC1E,GAAG,OAAA;AAAA,IACH,oBAAA,EAAsB,KAAA;AAAA,IACtB,kBAAA,EAAoB;AAAA,GACrB,CAAA;AAED,EAAA,MAAM,EAAE,kBAAA,GAAqB,IAAA,EAAM,oBAAA,GAAuB,MAAK,GAAI,OAAA;AAEnE,EAAA,OAAO;AAAA,IACL,GAAG,iCAAA;AAAA,IACH,cAAc,MAAA,EAAQ;AACpB,MAAA,iCAAA,CAAkC,cAAc,MAAM,CAAA;AAEtD,MAAA,MAAM,iBAAA,GAAoB,CAAC,QAAA,EAAkB,MAAA,KAAkE;AAC7G,QAAA,MAAM,aAAA,GAAgB,kBAAA,CAAmB,WAAA,CAAY,QAAA,EAAU,MAAA,EAAc;AAAA,UAC3E,OAAA,EAAS,KAAA;AAAA,UACT,YAAA,EAAc;AAAA,SACf,CAAA;AACD,QAAA,MAAM,SAAA,GAAY,aAAA,CAAc,aAAA,CAAc,MAAA,GAAS,CAAC,CAAA;AAGxD,QAAA,OAAO,SAAA,EAAW,OAAA,KAAY,UAAA,GAAa,SAAA,GAAY,MAAA;AAAA,MACzD,CAAA;AAEA,MAAA,MAAM,eAAA,GAAkB,CACtB,IAAA,EACA,KAAA,EACA,YACA,YAA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,WAAA,GAAc,qBAAA,CAAsB,MAAA,EAAQ,QAAQ,CAAA;AAE1D,EAAA,OAAO;AAAA,IACL,CAACC,mBAAQ,GAAG,QAAA,CAAS,QAAA;AAAA,IACrB,CAACC,mBAAQ,GAAGC,uBAAA,CAAmB,WAAW;AAAA,GAC5C;AACF;AAEA,SAAS,gCAAgC,KAAA,EAA6E;AACpH,EAAA,IAAI,CAAC,KAAA,EAAO;AACV,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,MAAM,kBAA0C,EAAC;AACjD,EAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,MAAM,CAAA,CAAE,QAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrD,IAAA,eAAA,CAAgB,CAAA,gBAAA,EAAmB,GAAG,CAAA,CAAE,CAAA,GAAI,KAAA;AAC5C,IAAA,eAAA,CAAgB,CAAA,EAAGC,sCAA2B,CAAA,CAAA,EAAI,GAAG,EAAE,CAAA,GAAI,KAAA;AAC3D,IAAA,eAAA,CAAgB,CAAA,EAAGC,0BAAe,CAAA,CAAA,EAAI,GAAG,EAAE,CAAA,GAAI,KAAA;AAAA,EACjD,CAAC,CAAA;AAED,EAAA,OAAO,eAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"tanstackrouter.js","sources":["../../src/tanstackrouter.ts"],"sourcesContent":["import {\n browserTracingIntegration as originalBrowserTracingIntegration,\n getAbsoluteUrl,\n startBrowserTracingNavigationSpan,\n startBrowserTracingPageLoadSpan,\n WINDOW,\n} from '@sentry/browser';\nimport type { Integration } from '@sentry/core';\nimport {\n filterCollectedUrl,\n hasSpanStreamingEnabled,\n NAVIGATION_SPAN_NAME_FALLBACK,\n PAGELOAD_SPAN_NAME_FALLBACK,\n} from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport type { VendoredTanstackRouter, VendoredTanstackRouterRouteMatch } from './vendor/tanstackrouter-types';\nimport {\n PARAMS_KEY_BASE,\n SENTRY_OP,\n SENTRY_SEGMENT_NAME_SOURCE,\n URL_FULL,\n URL_PATH,\n URL_PATH_PARAMETER_KEY_BASE,\n URL_TEMPLATE,\n} from '@sentry/conventions/attributes';\nimport { NAVIGATION, PAGELOAD } from '@sentry/conventions/op';\n\ninterface TanstackRouterLocation {\n pathname: string;\n search: Record<string, unknown>;\n state?: unknown;\n}\n\n/**\n * A custom browser tracing integration for TanStack Router.\n *\n * The minimum compatible version of `@tanstack/react-router` is `1.64.0`.\n *\n * @param router A TanStack Router `Router` instance that should be used for routing instrumentation.\n * @param options Sentry browser tracing configuration.\n */\nexport function tanstackRouterBrowserTracingIntegration(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n router: any, // This is `any` because we don't want any type mismatches if TanStack Router changes their types\n options: Parameters<typeof originalBrowserTracingIntegration>[0] = {},\n): Integration {\n const castRouterInstance: VendoredTanstackRouter = router;\n\n const browserTracingIntegrationInstance = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n instrumentPageLoad: false,\n });\n\n const { instrumentPageLoad = true, instrumentNavigation = true } = options;\n\n return {\n ...browserTracingIntegrationInstance,\n afterAllSetup(client) {\n browserTracingIntegrationInstance.afterAllSetup(client);\n\n const resolveRouteMatch = (pathname: string, search: unknown): VendoredTanstackRouterRouteMatch | undefined => {\n const matchedRoutes = castRouterInstance.matchRoutes(pathname, search as {}, {\n preload: false,\n throwOnError: false,\n });\n const lastMatch = matchedRoutes[matchedRoutes.length - 1];\n // If we only match __root__, we ended up not matching any route at all, so\n // we fall back to the pathname.\n return lastMatch?.routeId !== '__root__' ? lastMatch : undefined;\n };\n\n const applyRouteMatch = (\n span: NonNullable<ReturnType<typeof startBrowserTracingPageLoadSpan>>,\n match: VendoredTanstackRouterRouteMatch | undefined,\n toLocation: TanstackRouterLocation,\n fallbackName: string,\n ): void => {\n span.updateName(match ? match.routeId : fallbackName);\n span.setAttribute(SENTRY_SEGMENT_NAME_SOURCE, match ? 'route' : 'url');\n span.setAttributes({\n ...(match && { [URL_TEMPLATE]: match.routeId }),\n ...locationToSpanUrlAttributes(castRouterInstance, toLocation),\n ...routeMatchToParamSpanAttributes(match),\n });\n };\n\n const initialWindowLocation = WINDOW.location;\n if (instrumentPageLoad && initialWindowLocation) {\n const initialRouterLocation = castRouterInstance.state?.location;\n const routeMatch = initialRouterLocation\n ? resolveRouteMatch(initialRouterLocation.pathname, initialRouterLocation.search)\n : resolveRouteMatch(\n initialWindowLocation.pathname,\n castRouterInstance.options.parseSearch(initialWindowLocation.search),\n );\n\n const pageloadSpan = startBrowserTracingPageLoadSpan(client, {\n // With span streaming, span names have to be low cardinality, so we can't fall back to the URL.\n name: routeMatch\n ? routeMatch.routeId\n : hasSpanStreamingEnabled(client)\n ? PAGELOAD_SPAN_NAME_FALLBACK\n : initialWindowLocation.pathname,\n attributes: {\n [SENTRY_OP]: PAGELOAD,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.pageload.react.tanstack_router',\n [SENTRY_SEGMENT_NAME_SOURCE]: routeMatch ? 'route' : 'url',\n ...(routeMatch && { [URL_TEMPLATE]: routeMatch.routeId }),\n ...routeMatchToParamSpanAttributes(routeMatch),\n },\n });\n\n // A redirect thrown during the initial pageload leaves the span named after the pre-redirect\n // route, so correct it to the resolved route once.\n const unsubscribePageloadResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n unsubscribePageloadResolved();\n if (!pageloadSpan) {\n return;\n }\n const { toLocation } = onResolvedArgs;\n const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n applyRouteMatch(\n pageloadSpan,\n resolvedMatch,\n toLocation,\n hasSpanStreamingEnabled(client) ? PAGELOAD_SPAN_NAME_FALLBACK : toLocation.pathname,\n );\n });\n }\n\n if (instrumentNavigation) {\n // Navigation is driven by `onBeforeLoad` (accurate start) + `onResolved` (final route), not\n // `onBeforeNavigate`, which TanStack stops firing after any loader redirect (TanStack/router#3920).\n // A redirect chain emits one `onBeforeLoad` per load but a single `onResolved`, so we start the\n // span on the first `onBeforeLoad`, rename it on later ones, and clear it on `onResolved`.\n let inFlightNavigationSpan: ReturnType<typeof startBrowserTracingNavigationSpan> | undefined;\n\n castRouterInstance.subscribe('onBeforeLoad', onBeforeLoadArgs => {\n const { toLocation, fromLocation } = onBeforeLoadArgs;\n // Skip the initial pageload (no fromLocation) and no-op reloads (same state).\n if (!fromLocation || toLocation.state === fromLocation.state) {\n return;\n }\n\n const routeMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n // With span streaming, span names have to be low cardinality, so we can't fall back to the URL.\n const fallbackName = hasSpanStreamingEnabled(client)\n ? NAVIGATION_SPAN_NAME_FALLBACK\n : WINDOW.location?.pathname || toLocation.pathname;\n\n if (inFlightNavigationSpan) {\n // Redirect continuation within the same navigation: keep the span, update the target.\n applyRouteMatch(inFlightNavigationSpan, routeMatch, toLocation, fallbackName);\n return;\n }\n\n inFlightNavigationSpan = startBrowserTracingNavigationSpan(\n client,\n {\n name: routeMatch ? routeMatch.routeId : fallbackName,\n attributes: {\n [SENTRY_OP]: NAVIGATION,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.navigation.react.tanstack_router',\n [SENTRY_SEGMENT_NAME_SOURCE]: routeMatch ? 'route' : 'url',\n ...(routeMatch && { [URL_TEMPLATE]: routeMatch.routeId }),\n ...routeMatchToParamSpanAttributes(routeMatch),\n },\n },\n { url: locationToAbsoluteUrl(castRouterInstance, toLocation) },\n );\n });\n\n castRouterInstance.subscribe('onResolved', onResolvedArgs => {\n const span = inFlightNavigationSpan;\n inFlightNavigationSpan = undefined;\n if (!span) {\n return;\n }\n const { toLocation } = onResolvedArgs;\n const resolvedMatch = resolveRouteMatch(toLocation.pathname, toLocation.search);\n if (resolvedMatch) {\n applyRouteMatch(\n span,\n resolvedMatch,\n toLocation,\n hasSpanStreamingEnabled(client)\n ? NAVIGATION_SPAN_NAME_FALLBACK\n : WINDOW.location?.pathname || toLocation.pathname,\n );\n }\n });\n }\n },\n };\n}\n\nfunction locationToAbsoluteUrl(router: VendoredTanstackRouter, location: TanstackRouterLocation): string {\n const search = router.options.stringifySearch?.(location.search) ?? '';\n const pathWithSearch = `${location.pathname}${search && search !== '?' ? search : ''}`;\n\n return getAbsoluteUrl(pathWithSearch);\n}\n\nfunction locationToSpanUrlAttributes(\n router: VendoredTanstackRouter,\n location: TanstackRouterLocation,\n): Record<string, string> {\n const absoluteUrl = locationToAbsoluteUrl(router, location);\n\n return {\n [URL_PATH]: location.pathname,\n [URL_FULL]: filterCollectedUrl(absoluteUrl),\n };\n}\n\nfunction routeMatchToParamSpanAttributes(match: VendoredTanstackRouterRouteMatch | undefined): Record<string, string> {\n if (!match) {\n return {};\n }\n\n const paramAttributes: Record<string, string> = {};\n Object.entries(match.params).forEach(([key, value]) => {\n paramAttributes[`${URL_PATH_PARAMETER_KEY_BASE}.${key}`] = value;\n paramAttributes[`${PARAMS_KEY_BASE}.${key}`] = value; // params.[key] is an alias\n });\n\n return paramAttributes;\n}\n"],"names":["originalBrowserTracingIntegration","SENTRY_SEGMENT_NAME_SOURCE","URL_TEMPLATE","WINDOW","startBrowserTracingPageLoadSpan","hasSpanStreamingEnabled","PAGELOAD_SPAN_NAME_FALLBACK","SENTRY_OP","PAGELOAD","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","NAVIGATION_SPAN_NAME_FALLBACK","startBrowserTracingNavigationSpan","NAVIGATION","getAbsoluteUrl","URL_PATH","URL_FULL","filterCollectedUrl","URL_PATH_PARAMETER_KEY_BASE","PARAMS_KEY_BASE"],"mappings":";;;;;;;AAyCO,SAAS,uCAAA,CAEd,MAAA,EACA,OAAA,GAAmE,EAAC,EACvD;AACb,EAAA,MAAM,kBAAA,GAA6C,MAAA;AAEnD,EAAA,MAAM,oCAAoCA,iCAAA,CAAkC;AAAA,IAC1E,GAAG,OAAA;AAAA,IACH,oBAAA,EAAsB,KAAA;AAAA,IACtB,kBAAA,EAAoB;AA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AM,MAAM,CAAA,CAAE,QAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAA,KAAM;AACrD,IAAA,eAAA,CAAgB,CAAA,EAAGC,sCAA2B,CAAA,CAAA,EAAI,GAAG,EAAE,CAAA,GAAI,KAAA;AAC3D,IAAA,eAAA,CAAgB,CAAA,EAAGC,0BAAe,CAAA,CAAA,EAAI,GAAG,EAAE,CAAA,GAAI,KAAA;AAAA,EACjD,CAAC,CAAA;AAED,EAAA,OAAO,eAAA;AACT;;;;"}
|
package/build/esm/error.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { captureException } from '@sentry/browser';
|
|
2
|
-
import { isError } from '@sentry/core
|
|
3
|
-
import { version } from 'react';
|
|
2
|
+
import { isError } from '@sentry/core';
|
|
4
3
|
|
|
5
|
-
function isAtLeastReact17(reactVersion) {
|
|
6
|
-
const reactMajor = reactVersion.match(/^([^.]+)/);
|
|
7
|
-
return reactMajor !== null && parseInt(reactMajor[0]) >= 17;
|
|
8
|
-
}
|
|
9
4
|
function setCause(error, cause) {
|
|
10
5
|
const seenErrors = /* @__PURE__ */ new WeakSet();
|
|
11
6
|
function recurse(error2, cause2) {
|
|
@@ -21,7 +16,7 @@ function setCause(error, cause) {
|
|
|
21
16
|
recurse(error, cause);
|
|
22
17
|
}
|
|
23
18
|
function captureReactException(error, { componentStack }, hint) {
|
|
24
|
-
if (
|
|
19
|
+
if (isError(error) && componentStack) {
|
|
25
20
|
const errorBoundaryError = new Error(error.message);
|
|
26
21
|
errorBoundaryError.name = `React ErrorBoundary ${error.name}`;
|
|
27
22
|
errorBoundaryError.stack = componentStack;
|
|
@@ -41,5 +36,5 @@ function reactErrorHandler(callback) {
|
|
|
41
36
|
};
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
export { captureReactException,
|
|
39
|
+
export { captureReactException, reactErrorHandler, setCause };
|
|
45
40
|
//# sourceMappingURL=error.js.map
|
package/build/esm/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sources":["../../src/error.ts"],"sourcesContent":["import { captureException } from '@sentry/browser';\nimport { isError } from '@sentry/core
|
|
1
|
+
{"version":3,"file":"error.js","sources":["../../src/error.ts"],"sourcesContent":["import { captureException } from '@sentry/browser';\nimport { isError } from '@sentry/core';\nimport type { ErrorInfo } from 'react';\n\n/**\n * Recurse through `error.cause` chain to set cause on an error.\n */\nexport function setCause(error: Error & { cause?: Error }, cause: Error): void {\n const seenErrors = new WeakSet();\n\n function recurse(error: Error & { cause?: Error }, cause: Error): void {\n // If we've already seen the error, there is a recursive loop somewhere in the error's\n // cause chain. Let's just bail out then to prevent a stack overflow.\n if (seenErrors.has(error)) {\n return;\n }\n if (error.cause) {\n seenErrors.add(error);\n return recurse(error.cause, cause);\n }\n error.cause = cause;\n }\n\n recurse(error, cause);\n}\n\n/**\n * Captures an error that was thrown by a React ErrorBoundary or React root.\n *\n * @param error The error to capture.\n * @param errorInfo The errorInfo provided by React.\n * @param hint Optional additional data to attach to the Sentry event.\n * @returns the id of the captured Sentry event.\n */\nexport function captureReactException(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error: any,\n { componentStack }: ErrorInfo,\n hint?: Parameters<typeof captureException>[1],\n): string {\n // Create a stack trace from the componentStack param and link it to the original error\n // using `error.cause`. Linking errors requires the `LinkedErrors` integration be enabled.\n // See: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#native-component-stacks\n //\n // Although `componentDidCatch` is typed to accept an `Error` object, it can also be invoked\n // with non-error objects. This is why we need to check if the error is an error-like object.\n // See: https://github.com/getsentry/sentry-javascript/issues/6167\n if (isError(error) && componentStack) {\n const errorBoundaryError = new Error(error.message);\n errorBoundaryError.name = `React ErrorBoundary ${error.name}`;\n errorBoundaryError.stack = componentStack;\n\n // Using the `LinkedErrors` integration to link the errors together.\n setCause(error, errorBoundaryError);\n }\n\n return captureException(error, hint);\n}\n\n/**\n * Creates an error handler that can be used with the `onCaughtError`, `onUncaughtError`,\n * and `onRecoverableError` options in `createRoot` and `hydrateRoot` React DOM methods.\n *\n * @param callback An optional callback that will be called after the error is captured.\n * Use this to add custom handling for errors.\n *\n * @example\n *\n * ```JavaScript\n * const root = createRoot(container, {\n * onCaughtError: Sentry.reactErrorHandler(),\n * onUncaughtError: Sentry.reactErrorHandler((error, errorInfo) => {\n * console.warn('Caught error', error, errorInfo.componentStack);\n * });\n * });\n * ```\n */\nexport function reactErrorHandler(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callback?: (error: any, errorInfo: ErrorInfo, eventId: string) => void,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (error: any, errorInfo: ErrorInfo) => void {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (error: any, errorInfo: ErrorInfo) => {\n const hasCallback = !!callback;\n const eventId = captureReactException(error, errorInfo, {\n mechanism: { handled: hasCallback, type: 'auto.function.react.error_handler' },\n });\n if (hasCallback) {\n callback(error, errorInfo, eventId);\n }\n };\n}\n"],"names":["error","cause"],"mappings":";;;AAOO,SAAS,QAAA,CAAS,OAAkC,KAAA,EAAoB;AAC7E,EAAA,MAAM,UAAA,uBAAiB,OAAA,EAAQ;AAE/B,EAAA,SAAS,OAAA,CAAQA,QAAkCC,MAAAA,EAAoB;AAGrE,IAAA,IAAI,UAAA,CAAW,GAAA,CAAID,MAAK,CAAA,EAAG;AACzB,MAAA;AAAA,IACF;AACA,IAAA,IAAIA,OAAM,KAAA,EAAO;AACf,MAAA,UAAA,CAAW,IAAIA,MAAK,CAAA;AACpB,MAAA,OAAO,OAAA,CAAQA,MAAAA,CAAM,KAAA,EAAOC,MAAK,CAAA;AAAA,IACnC;AACA,IAAAD,OAAM,KAAA,GAAQC,MAAAA;AAAA,EAChB;AAEA,EAAA,OAAA,CAAQ,OAAO,KAAK,CAAA;AACtB;AAUO,SAAS,qBAAA,CAEd,KAAA,EACA,EAAE,cAAA,IACF,IAAA,EACQ;AAQR,EAAA,IAAI,OAAA,CAAQ,KAAK,CAAA,IAAK,cAAA,EAAgB;AACpC,IAAA,MAAM,kBAAA,GAAqB,IAAI,KAAA,CAAM,KAAA,CAAM,OAAO,CAAA;AAClD,IAAA,kBAAA,CAAmB,IAAA,GAAO,CAAA,oBAAA,EAAuB,KAAA,CAAM,IAAI,CAAA,CAAA;AAC3D,IAAA,kBAAA,CAAmB,KAAA,GAAQ,cAAA;AAG3B,IAAA,QAAA,CAAS,OAAO,kBAAkB,CAAA;AAAA,EACpC;AAEA,EAAA,OAAO,gBAAA,CAAiB,OAAO,IAAI,CAAA;AACrC;AAoBO,SAAS,kBAEd,QAAA,EAE4C;AAE5C,EAAA,OAAO,CAAC,OAAY,SAAA,KAAyB;AAC3C,IAAA,MAAM,WAAA,GAAc,CAAC,CAAC,QAAA;AACtB,IAAA,MAAM,OAAA,GAAU,qBAAA,CAAsB,KAAA,EAAO,SAAA,EAAW;AAAA,MACtD,SAAA,EAAW,EAAE,OAAA,EAAS,WAAA,EAAa,MAAM,mCAAA;AAAoC,KAC9E,CAAA;AACD,IAAA,IAAI,WAAA,EAAa;AACf,MAAA,QAAA,CAAS,KAAA,EAAO,WAAW,OAAO,CAAA;AAAA,IACpC;AAAA,EACF,CAAA;AACF;;;;"}
|
|
@@ -37,16 +37,10 @@ const MEMO_STATICS = {
|
|
|
37
37
|
};
|
|
38
38
|
const ForwardRefType = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
39
39
|
const MemoType = /* @__PURE__ */ Symbol.for("react.memo");
|
|
40
|
-
function isMemo(component) {
|
|
41
|
-
return typeof component === "object" && component !== null && component.$$typeof === MemoType;
|
|
42
|
-
}
|
|
43
40
|
const TYPE_STATICS = {};
|
|
44
41
|
TYPE_STATICS[ForwardRefType] = FORWARD_REF_STATICS;
|
|
45
42
|
TYPE_STATICS[MemoType] = MEMO_STATICS;
|
|
46
43
|
function getStatics(component) {
|
|
47
|
-
if (isMemo(component)) {
|
|
48
|
-
return MEMO_STATICS;
|
|
49
|
-
}
|
|
50
44
|
const componentType = component.$$typeof;
|
|
51
45
|
return componentType && TYPE_STATICS[componentType] || REACT_STATICS;
|
|
52
46
|
}
|
|
@@ -76,7 +70,7 @@ function hoistNonReactStatics(targetComponent, sourceComponent, excludelist) {
|
|
|
76
70
|
if (descriptor) {
|
|
77
71
|
try {
|
|
78
72
|
defineProperty(targetComponent, key, descriptor);
|
|
79
|
-
} catch
|
|
73
|
+
} catch {
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hoist-non-react-statics.js","sources":["../../src/hoist-non-react-statics.ts"],"sourcesContent":["/**\n * Inlined implementation of hoist-non-react-statics\n * Original library: https://github.com/mridgway/hoist-non-react-statics\n * License: BSD-3-Clause\n * Copyright 2015, Yahoo! Inc.\n *\n * This is an inlined version to avoid ESM compatibility issues with the original package.\n */\n\nimport type * as React from 'react';\n\n/**\n * React statics that should not be hoisted\n */\nconst REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Known JavaScript function statics that should not be hoisted\n */\nconst KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true,\n} as const;\n\n/**\n * Statics specific to ForwardRef components\n */\nconst FORWARD_REF_STATICS = {\n $$typeof: true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n} as const;\n\n/**\n * Statics specific to Memo components\n */\nconst MEMO_STATICS = {\n $$typeof: true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Inlined react-is utilities\n * We only need to detect ForwardRef and Memo types\n */\nconst ForwardRefType = Symbol.for('react.forward_ref');\nconst MemoType = Symbol.for('react.memo');\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"hoist-non-react-statics.js","sources":["../../src/hoist-non-react-statics.ts"],"sourcesContent":["/**\n * Inlined implementation of hoist-non-react-statics\n * Original library: https://github.com/mridgway/hoist-non-react-statics\n * License: BSD-3-Clause\n * Copyright 2015, Yahoo! Inc.\n *\n * This is an inlined version to avoid ESM compatibility issues with the original package.\n */\n\nimport type * as React from 'react';\n\n/**\n * React statics that should not be hoisted\n */\nconst REACT_STATICS = {\n childContextTypes: true,\n contextType: true,\n contextTypes: true,\n defaultProps: true,\n displayName: true,\n getDefaultProps: true,\n getDerivedStateFromError: true,\n getDerivedStateFromProps: true,\n mixins: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Known JavaScript function statics that should not be hoisted\n */\nconst KNOWN_STATICS = {\n name: true,\n length: true,\n prototype: true,\n caller: true,\n callee: true,\n arguments: true,\n arity: true,\n} as const;\n\n/**\n * Statics specific to ForwardRef components\n */\nconst FORWARD_REF_STATICS = {\n $$typeof: true,\n render: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n} as const;\n\n/**\n * Statics specific to Memo components\n */\nconst MEMO_STATICS = {\n $$typeof: true,\n compare: true,\n defaultProps: true,\n displayName: true,\n propTypes: true,\n type: true,\n} as const;\n\n/**\n * Inlined react-is utilities\n * We only need to detect ForwardRef and Memo types\n */\nconst ForwardRefType = Symbol.for('react.forward_ref');\nconst MemoType = Symbol.for('react.memo');\n\n/**\n * Map of React component types to their specific statics\n */\nconst TYPE_STATICS: Record<symbol, Record<string, boolean>> = {};\nTYPE_STATICS[ForwardRefType] = FORWARD_REF_STATICS;\nTYPE_STATICS[MemoType] = MEMO_STATICS;\n\n/**\n * Get the appropriate statics object for a given component\n */\nfunction getStatics(component: React.ComponentType<unknown>): Record<string, boolean> {\n const componentType = (component as { $$typeof?: symbol }).$$typeof;\n return (componentType && TYPE_STATICS[componentType]) || REACT_STATICS;\n}\n\nconst defineProperty = Object.defineProperty.bind(Object);\nconst getOwnPropertyNames = Object.getOwnPropertyNames.bind(Object);\nconst getOwnPropertySymbols = Object.getOwnPropertySymbols?.bind(Object);\nconst getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor.bind(Object);\nconst getPrototypeOf = Object.getPrototypeOf.bind(Object);\nconst objectPrototype = Object.prototype;\n\n/**\n * Copies non-react specific statics from a child component to a parent component.\n * Similar to Object.assign, but copies all static properties from source to target,\n * excluding React-specific statics and known JavaScript statics.\n *\n * @param targetComponent - The component to copy statics to\n * @param sourceComponent - The component to copy statics from\n * @param excludelist - An optional object of keys to exclude from hoisting\n * @returns The target component with hoisted statics\n */\nexport function hoistNonReactStatics<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends React.ComponentType<any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n S extends React.ComponentType<any>,\n C extends Record<string, boolean> = Record<string, never>,\n>(targetComponent: T, sourceComponent: S, excludelist?: C): T {\n if (typeof sourceComponent !== 'string') {\n // Don't hoist over string (html) components\n if (objectPrototype) {\n const inheritedComponent = getPrototypeOf(sourceComponent);\n\n if (inheritedComponent && inheritedComponent !== objectPrototype) {\n hoistNonReactStatics(targetComponent, inheritedComponent, excludelist);\n }\n }\n\n let keys: (string | symbol)[] = getOwnPropertyNames(sourceComponent);\n\n if (getOwnPropertySymbols) {\n keys = keys.concat(getOwnPropertySymbols(sourceComponent));\n }\n\n const targetStatics = getStatics(targetComponent);\n const sourceStatics = getStatics(sourceComponent);\n\n for (const key of keys) {\n // Use key directly - String(key) throws for Symbols if minified to '' + key (#18966)\n if (\n !KNOWN_STATICS[key as keyof typeof KNOWN_STATICS] &&\n !excludelist?.[key as keyof C] &&\n !sourceStatics?.[key as string] &&\n !targetStatics?.[key as string] &&\n !getOwnPropertyDescriptor(targetComponent, key) // Don't overwrite existing properties\n ) {\n const descriptor = getOwnPropertyDescriptor(sourceComponent, key);\n\n if (descriptor) {\n try {\n // Avoid failures from read-only properties\n defineProperty(targetComponent, key, descriptor);\n } catch {\n // Silently ignore errors\n }\n }\n }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A,MAAW,OAAO,IAAA,EAAM;AAEtB,MAAA,IACE,CAAC,cAAc,GAAiC,CAAA,IAChD,QACA,CAAC,aAAA,GAAgB,GAAa,CAAA,IAC9B,CAAC,gBAAgB,GAAa,CAAA,IAC9B,CAAC,wBAAA,CAAyB,eAAA,EAAiB,GAAG,CAAA,EAC9C;AACA,QAAA,MAAM,UAAA,GAAa,wBAAA,CAAyB,eAAA,EAAiB,GAAG,CAAA;AAEhE,QAAA,IAAI,UAAA,EAAY;AACd,UAAA,IAAI;AAEF,YAAA,cAAA,CAAe,eAAA,EAAiB,KAAK,UAAU,CAAA;AAAA,UACjD,CAAA,CAAA,MAAQ;AAAA,UAER;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,eAAA;AACT;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"
|
|
1
|
+
{"type":"module","version":"11.1.0","sideEffects":false}
|
package/build/esm/profiler.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { startInactiveSpan } from '@sentry/browser';
|
|
2
|
-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, timestampInSeconds, withActiveSpan, spanToJSON } from '@sentry/core';
|
|
1
|
+
import { getClient, startInactiveSpan } from '@sentry/browser';
|
|
2
|
+
import { hasSpanStreamingEnabled, UI_MOUNT_SPAN_NAME_FALLBACK, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, timestampInSeconds, withActiveSpan, UI_UPDATE_SPAN_NAME_FALLBACK, spanToJSON, UI_RENDER_SPAN_NAME_FALLBACK } from '@sentry/core';
|
|
3
|
+
import { SENTRY_DESCRIPTION, UI_COMPONENT_NAME, SENTRY_OP } from '@sentry/conventions/attributes';
|
|
4
|
+
import { UI_MOUNT, UI_UPDATE, UI_RENDER } from '@sentry/conventions/op';
|
|
3
5
|
import * as React from 'react';
|
|
4
|
-
import { REACT_MOUNT_OP, REACT_UPDATE_OP, REACT_RENDER_OP } from './constants.js';
|
|
5
6
|
import { hoistNonReactStatics } from './hoist-non-react-statics.js';
|
|
6
7
|
|
|
7
8
|
const UNKNOWN_COMPONENT = "unknown";
|
|
@@ -12,13 +13,18 @@ class Profiler extends React.Component {
|
|
|
12
13
|
if (disabled) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
16
|
+
const client = getClient();
|
|
17
|
+
const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);
|
|
18
|
+
const description = `<${name}>`;
|
|
19
|
+
const componentName = name === UNKNOWN_COMPONENT ? void 0 : name;
|
|
15
20
|
this._mountSpan = startInactiveSpan({
|
|
16
|
-
name:
|
|
21
|
+
name: hasSpanStreaming ? componentName || UI_MOUNT_SPAN_NAME_FALLBACK : description,
|
|
17
22
|
onlyIfParent: true,
|
|
18
|
-
op: REACT_MOUNT_OP,
|
|
19
23
|
attributes: {
|
|
24
|
+
[SENTRY_OP]: UI_MOUNT,
|
|
20
25
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.react.profiler",
|
|
21
|
-
|
|
26
|
+
...componentName && { [UI_COMPONENT_NAME]: componentName },
|
|
27
|
+
...hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
30
|
}
|
|
@@ -34,15 +40,20 @@ class Profiler extends React.Component {
|
|
|
34
40
|
if (changedProps.length > 0) {
|
|
35
41
|
const now = timestampInSeconds();
|
|
36
42
|
this._updateSpan = withActiveSpan(this._mountSpan, () => {
|
|
43
|
+
const client = getClient();
|
|
44
|
+
const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);
|
|
45
|
+
const description = `<${this.props.name}>`;
|
|
46
|
+
const componentName = this.props.name === UNKNOWN_COMPONENT ? void 0 : this.props.name;
|
|
37
47
|
return startInactiveSpan({
|
|
38
|
-
name:
|
|
48
|
+
name: hasSpanStreaming ? componentName || UI_UPDATE_SPAN_NAME_FALLBACK : description,
|
|
39
49
|
onlyIfParent: true,
|
|
40
|
-
op: REACT_UPDATE_OP,
|
|
41
50
|
startTime: now,
|
|
42
51
|
attributes: {
|
|
52
|
+
[SENTRY_OP]: UI_UPDATE,
|
|
43
53
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.react.profiler",
|
|
44
|
-
|
|
45
|
-
"ui.react.changed_props": changedProps
|
|
54
|
+
...componentName && { [UI_COMPONENT_NAME]: componentName },
|
|
55
|
+
"ui.react.changed_props": changedProps,
|
|
56
|
+
...hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }
|
|
46
57
|
}
|
|
47
58
|
});
|
|
48
59
|
});
|
|
@@ -62,16 +73,21 @@ class Profiler extends React.Component {
|
|
|
62
73
|
const endTimestamp = timestampInSeconds();
|
|
63
74
|
const { name, includeRender = true } = this.props;
|
|
64
75
|
if (this._mountSpan && includeRender) {
|
|
65
|
-
const startTime = spanToJSON(this._mountSpan).
|
|
76
|
+
const startTime = spanToJSON(this._mountSpan).end_timestamp;
|
|
66
77
|
withActiveSpan(this._mountSpan, () => {
|
|
78
|
+
const client = getClient();
|
|
79
|
+
const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);
|
|
80
|
+
const description = `<${name}>`;
|
|
81
|
+
const componentName = name === UNKNOWN_COMPONENT ? void 0 : name;
|
|
67
82
|
const renderSpan = startInactiveSpan({
|
|
68
83
|
onlyIfParent: true,
|
|
69
|
-
name:
|
|
70
|
-
op: REACT_RENDER_OP,
|
|
84
|
+
name: hasSpanStreaming ? componentName || UI_RENDER_SPAN_NAME_FALLBACK : description,
|
|
71
85
|
startTime,
|
|
72
86
|
attributes: {
|
|
87
|
+
[SENTRY_OP]: UI_RENDER,
|
|
73
88
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.react.profiler",
|
|
74
|
-
|
|
89
|
+
...componentName && { [UI_COMPONENT_NAME]: componentName },
|
|
90
|
+
...hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }
|
|
75
91
|
}
|
|
76
92
|
});
|
|
77
93
|
if (renderSpan) {
|
|
@@ -106,13 +122,18 @@ function useProfiler(name, options = {
|
|
|
106
122
|
if (options?.disabled) {
|
|
107
123
|
return void 0;
|
|
108
124
|
}
|
|
125
|
+
const client = getClient();
|
|
126
|
+
const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);
|
|
127
|
+
const description = `<${name}>`;
|
|
128
|
+
const componentName = name === UNKNOWN_COMPONENT ? void 0 : name;
|
|
109
129
|
return startInactiveSpan({
|
|
110
|
-
name:
|
|
130
|
+
name: hasSpanStreaming ? componentName || UI_MOUNT_SPAN_NAME_FALLBACK : description,
|
|
111
131
|
onlyIfParent: true,
|
|
112
|
-
op: REACT_MOUNT_OP,
|
|
113
132
|
attributes: {
|
|
133
|
+
[SENTRY_OP]: UI_MOUNT,
|
|
114
134
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.react.profiler",
|
|
115
|
-
|
|
135
|
+
...componentName && { [UI_COMPONENT_NAME]: componentName },
|
|
136
|
+
...hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }
|
|
116
137
|
}
|
|
117
138
|
});
|
|
118
139
|
});
|
|
@@ -122,16 +143,21 @@ function useProfiler(name, options = {
|
|
|
122
143
|
}
|
|
123
144
|
return () => {
|
|
124
145
|
if (mountSpan && options.hasRenderSpan) {
|
|
125
|
-
const startTime = spanToJSON(mountSpan).
|
|
146
|
+
const startTime = spanToJSON(mountSpan).end_timestamp;
|
|
126
147
|
const endTimestamp = timestampInSeconds();
|
|
148
|
+
const client = getClient();
|
|
149
|
+
const hasSpanStreaming = !!client && hasSpanStreamingEnabled(client);
|
|
150
|
+
const description = `<${name}>`;
|
|
151
|
+
const componentName = name === UNKNOWN_COMPONENT ? void 0 : name;
|
|
127
152
|
const renderSpan = startInactiveSpan({
|
|
128
|
-
name:
|
|
153
|
+
name: hasSpanStreaming ? componentName || UI_RENDER_SPAN_NAME_FALLBACK : description,
|
|
129
154
|
onlyIfParent: true,
|
|
130
|
-
op: REACT_RENDER_OP,
|
|
131
155
|
startTime,
|
|
132
156
|
attributes: {
|
|
157
|
+
[SENTRY_OP]: UI_RENDER,
|
|
133
158
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.ui.react.profiler",
|
|
134
|
-
|
|
159
|
+
...componentName && { [UI_COMPONENT_NAME]: componentName },
|
|
160
|
+
...hasSpanStreaming && { [SENTRY_DESCRIPTION]: description }
|
|
135
161
|
}
|
|
136
162
|
});
|
|
137
163
|
if (renderSpan) {
|