@sentry/react 6.13.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +92 -0
  3. package/dist/errorboundary.d.ts +59 -0
  4. package/dist/errorboundary.d.ts.map +1 -0
  5. package/dist/errorboundary.js +138 -0
  6. package/dist/errorboundary.js.map +1 -0
  7. package/dist/index.d.ts +8 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +21 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/profiler.d.ts +55 -0
  12. package/dist/profiler.d.ts.map +1 -0
  13. package/dist/profiler.js +239 -0
  14. package/dist/profiler.js.map +1 -0
  15. package/dist/reactrouter.d.ts +25 -0
  16. package/dist/reactrouter.d.ts.map +1 -0
  17. package/dist/reactrouter.js +119 -0
  18. package/dist/reactrouter.js.map +1 -0
  19. package/dist/reactrouterv3.d.ts +26 -0
  20. package/dist/reactrouterv3.d.ts.map +1 -0
  21. package/dist/reactrouterv3.js +105 -0
  22. package/dist/reactrouterv3.js.map +1 -0
  23. package/dist/redux.d.ts +33 -0
  24. package/dist/redux.d.ts.map +1 -0
  25. package/dist/redux.js +54 -0
  26. package/dist/redux.js.map +1 -0
  27. package/dist/sdk.d.ts +6 -0
  28. package/dist/sdk.d.ts.map +1 -0
  29. package/dist/sdk.js +21 -0
  30. package/dist/sdk.js.map +1 -0
  31. package/dist/types.d.ts +8 -0
  32. package/dist/types.d.ts.map +1 -0
  33. package/dist/types.js +2 -0
  34. package/dist/types.js.map +1 -0
  35. package/esm/errorboundary.d.ts +59 -0
  36. package/esm/errorboundary.d.ts.map +1 -0
  37. package/esm/errorboundary.js +136 -0
  38. package/esm/errorboundary.js.map +1 -0
  39. package/esm/index.d.ts +8 -0
  40. package/esm/index.d.ts.map +1 -0
  41. package/esm/index.js +8 -0
  42. package/esm/index.js.map +1 -0
  43. package/esm/profiler.d.ts +55 -0
  44. package/esm/profiler.d.ts.map +1 -0
  45. package/esm/profiler.js +235 -0
  46. package/esm/profiler.js.map +1 -0
  47. package/esm/reactrouter.d.ts +25 -0
  48. package/esm/reactrouter.d.ts.map +1 -0
  49. package/esm/reactrouter.js +115 -0
  50. package/esm/reactrouter.js.map +1 -0
  51. package/esm/reactrouterv3.d.ts +26 -0
  52. package/esm/reactrouterv3.d.ts.map +1 -0
  53. package/esm/reactrouterv3.js +103 -0
  54. package/esm/reactrouterv3.js.map +1 -0
  55. package/esm/redux.d.ts +33 -0
  56. package/esm/redux.d.ts.map +1 -0
  57. package/esm/redux.js +53 -0
  58. package/esm/redux.js.map +1 -0
  59. package/esm/sdk.d.ts +6 -0
  60. package/esm/sdk.d.ts.map +1 -0
  61. package/esm/sdk.js +19 -0
  62. package/esm/sdk.js.map +1 -0
  63. package/esm/types.d.ts +8 -0
  64. package/esm/types.d.ts.map +1 -0
  65. package/esm/types.js +1 -0
  66. package/esm/types.js.map +1 -0
  67. package/package.json +107 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiler.js","sourceRoot":"","sources":["../src/profiler.tsx"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,OAAO,EAAE,aAAa,EAAO,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,IAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,IAAM,cAAc,GAAI;IACtB,EAAE,EAAE,SAAS;CAC2B,CAAC;AAE3C,IAAI,wBAAwB,GAAuB,IAAI,CAAC;AACxD,yDAAyD;AACzD,IAAM,qBAAqB,GAAG;IAC5B,IAAI,wBAAwB,EAAE;QAC5B,OAAO,wBAAwB,CAAC;KACjC;IAED,wBAAwB,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IA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slint/no-explicit-any */\nimport { getCurrentHub, Hub } from '@sentry/browser';\nimport { Integration, IntegrationClass, Span, Transaction } from '@sentry/types';\nimport { timestampWithMs } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nexport const UNKNOWN_COMPONENT = 'unknown';\n\nconst TRACING_GETTER = ({\n id: 'Tracing',\n} as any) as IntegrationClass<Integration>;\n\nlet globalTracingIntegration: Integration | null = null;\n/** @deprecated remove when @sentry/apm no longer used */\nconst getTracingIntegration = (): Integration | null => {\n if (globalTracingIntegration) {\n return globalTracingIntegration;\n }\n\n globalTracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER);\n return globalTracingIntegration;\n};\n\n/**\n * pushActivity creates an new react activity.\n * Is a no-op if Tracing integration is not valid\n * @param name displayName of component that started activity\n * @deprecated remove when @sentry/apm no longer used\n */\nfunction pushActivity(name: string, op: string): number | null {\n if (globalTracingIntegration === null) {\n return null;\n }\n\n return (globalTracingIntegration as any).constructor.pushActivity(name, {\n description: `<${name}>`,\n op: `react.${op}`,\n });\n}\n\n/**\n * popActivity removes a React activity.\n * Is a no-op if Tracing integration is not valid.\n * @param activity id of activity that is being popped\n * @deprecated remove when @sentry/apm no longer used\n */\nfunction popActivity(activity: number | null): void {\n if (activity === null || globalTracingIntegration === null) {\n return;\n }\n\n (globalTracingIntegration as any).constructor.popActivity(activity);\n}\n\n/**\n * Obtain a span given an activity id.\n * Is a no-op if Tracing integration is not valid.\n * @param activity activity id associated with obtained span\n * @deprecated remove when @sentry/apm no longer used\n */\nfunction getActivitySpan(activity: number | null): Span | undefined {\n if (activity === null || globalTracingIntegration === null) {\n return undefined;\n }\n\n return (globalTracingIntegration as any).constructor.getActivitySpan(activity) as Span | undefined;\n}\n\nexport type ProfilerProps = {\n // The name of the component being profiled.\n name: string;\n // If the Profiler is disabled. False by default. This is useful if you want to disable profilers\n // in certain environments.\n disabled?: boolean;\n // If time component is on page should be displayed as spans. True by default.\n includeRender?: boolean;\n // If component updates should be displayed as spans. True by default.\n includeUpdates?: boolean;\n // props given to component being profiled.\n updateProps: { [key: string]: unknown };\n};\n\n/**\n * The Profiler component leverages Sentry's Tracing integration to generate\n * spans based on component lifecycles.\n */\nclass Profiler extends React.Component<ProfilerProps> {\n /**\n * The span of the mount activity\n * Made protected for the React Native SDK to access\n */\n protected _mountSpan: Span | undefined = undefined;\n\n // The activity representing how long it takes to mount a component.\n private _mountActivity: number | null = null;\n\n // eslint-disable-next-line @typescript-eslint/member-ordering\n public static defaultProps: Partial<ProfilerProps> = {\n disabled: false,\n includeRender: true,\n includeUpdates: true,\n };\n\n public constructor(props: ProfilerProps) {\n super(props);\n const { name, disabled = false } = this.props;\n\n if (disabled) {\n return;\n }\n\n // If they are using @sentry/apm, we need to push/pop activities\n // eslint-disable-next-line deprecation/deprecation\n if (getTracingIntegration()) {\n // eslint-disable-next-line deprecation/deprecation\n this._mountActivity = pushActivity(name, 'mount');\n } else {\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n this._mountSpan = activeTransaction.startChild({\n description: `<${name}>`,\n op: 'react.mount',\n });\n }\n }\n }\n\n // If a component mounted, we can finish the mount activity.\n public componentDidMount(): void {\n if (this._mountSpan) {\n this._mountSpan.finish();\n } else {\n // eslint-disable-next-line deprecation/deprecation\n this._mountSpan = getActivitySpan(this._mountActivity);\n // eslint-disable-next-line deprecation/deprecation\n popActivity(this._mountActivity);\n this._mountActivity = null;\n }\n }\n\n public componentDidUpdate({ updateProps, includeUpdates = true }: ProfilerProps): void {\n // Only generate an update span if hasUpdateSpan is true, if there is a valid mountSpan,\n // and if the updateProps have changed. It is ok to not do a deep equality check here as it is expensive.\n // We are just trying to give baseline clues for further investigation.\n if (includeUpdates && this._mountSpan && updateProps !== this.props.updateProps) {\n // See what props haved changed between the previous props, and the current props. This is\n // set as data on the span. We just store the prop keys as the values could be potenially very large.\n const changedProps = Object.keys(updateProps).filter(k => updateProps[k] !== this.props.updateProps[k]);\n if (changedProps.length > 0) {\n // The update span is a point in time span with 0 duration, just signifying that the component\n // has been updated.\n const now = timestampWithMs();\n this._mountSpan.startChild({\n data: {\n changedProps,\n },\n description: `<${this.props.name}>`,\n endTimestamp: now,\n op: `react.update`,\n startTimestamp: now,\n });\n }\n }\n }\n\n // If a component is unmounted, we can say it is no longer on the screen.\n // This means we can finish the span representing the component render.\n public componentWillUnmount(): void {\n const { name, includeRender = true } = this.props;\n\n if (this._mountSpan && includeRender) {\n // If we were able to obtain the spanId of the mount activity, we should set the\n // next activity as a child to the component mount activity.\n this._mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: `react.render`,\n startTimestamp: this._mountSpan.endTimestamp,\n });\n }\n }\n\n public render(): React.ReactNode {\n return this.props.children;\n }\n}\n\n/**\n * withProfiler is a higher order component that wraps a\n * component in a {@link Profiler} component. It is recommended that\n * the higher order component be used over the regular {@link Profiler} component.\n *\n * @param WrappedComponent component that is wrapped by Profiler\n * @param options the {@link ProfilerProps} you can pass into the Profiler\n */\nfunction withProfiler<P extends Record<string, any>>(\n WrappedComponent: React.ComponentType<P>,\n // We do not want to have `updateProps` given in options, it is instead filled through the HOC.\n options?: Pick<Partial<ProfilerProps>, Exclude<keyof ProfilerProps, 'updateProps'>>,\n): React.FC<P> {\n const componentDisplayName =\n (options && options.name) || WrappedComponent.displayName || WrappedComponent.name || UNKNOWN_COMPONENT;\n\n const Wrapped: React.FC<P> = (props: P) => (\n <Profiler {...options} name={componentDisplayName} updateProps={props}>\n <WrappedComponent {...props} />\n </Profiler>\n );\n\n Wrapped.displayName = `profiler(${componentDisplayName})`;\n\n // Copy over static methods from Wrapped component to Profiler HOC\n // See: https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(Wrapped, WrappedComponent);\n return Wrapped;\n}\n\n/**\n *\n * `useProfiler` is a React hook that profiles a React component.\n *\n * Requires React 16.8 or above.\n * @param name displayName of component being profiled\n */\nfunction useProfiler(\n name: string,\n options: { disabled?: boolean; hasRenderSpan?: boolean } = {\n disabled: false,\n hasRenderSpan: true,\n },\n): void {\n const [mountSpan] = React.useState(() => {\n if (options && options.disabled) {\n return undefined;\n }\n\n const activeTransaction = getActiveTransaction();\n if (activeTransaction) {\n return activeTransaction.startChild({\n description: `<${name}>`,\n op: 'react.mount',\n });\n }\n\n return undefined;\n });\n\n React.useEffect(() => {\n if (mountSpan) {\n mountSpan.finish();\n }\n\n return (): void => {\n if (mountSpan && options.hasRenderSpan) {\n mountSpan.startChild({\n description: `<${name}>`,\n endTimestamp: timestampWithMs(),\n op: `react.render`,\n startTimestamp: mountSpan.endTimestamp,\n });\n }\n };\n // We only want this to run once.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n}\n\nexport { withProfiler, Profiler, useProfiler };\n\n/** Grabs active transaction off scope */\nexport function getActiveTransaction<T extends Transaction>(hub: Hub = getCurrentHub()): T | undefined {\n if (hub) {\n const scope = hub.getScope();\n if (scope) {\n return scope.getTransaction() as T | undefined;\n }\n }\n\n return undefined;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { Action, Location, ReactRouterInstrumentation } from './types';
3
+ declare type Match = {
4
+ path: string;
5
+ url: string;
6
+ params: Record<string, any>;
7
+ isExact: boolean;
8
+ };
9
+ export declare type RouterHistory = {
10
+ location?: Location;
11
+ listen?(cb: (location: Location, action: Action) => void): void;
12
+ } & Record<string, any>;
13
+ export declare type RouteConfig = {
14
+ [propName: string]: any;
15
+ path?: string | string[];
16
+ exact?: boolean;
17
+ component?: JSX.Element;
18
+ routes?: RouteConfig[];
19
+ };
20
+ declare type MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null;
21
+ export declare function reactRouterV4Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
22
+ export declare function reactRouterV5Instrumentation(history: RouterHistory, routes?: RouteConfig[], matchPath?: MatchPath): ReactRouterInstrumentation;
23
+ export declare function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R;
24
+ export {};
25
+ //# sourceMappingURL=reactrouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouter.d.ts","sourceRoot":"","sources":["../src/reactrouter.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAKvE,aAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,oBAAY,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;CACjE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,oBAAY,WAAW,GAAG;IACxB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,aAAK,SAAS,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,CAAC;AAO3G,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,EAAE,EACtB,SAAS,CAAC,EAAE,SAAS,GACpB,0BAA0B,CAE5B;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,EAAE,EACtB,SAAS,CAAC,EAAE,SAAS,GACpB,0BAA0B,CAE5B;AAyGD,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAoB9G"}
@@ -0,0 +1,115 @@
1
+ import { __assign } from "tslib";
2
+ import { getGlobalObject } from '@sentry/utils';
3
+ import hoistNonReactStatics from 'hoist-non-react-statics';
4
+ import * as React from 'react';
5
+ /* eslint-enable @typescript-eslint/no-explicit-any */
6
+ var global = getGlobalObject();
7
+ var activeTransaction;
8
+ export function reactRouterV4Instrumentation(history, routes, matchPath) {
9
+ return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);
10
+ }
11
+ export function reactRouterV5Instrumentation(history, routes, matchPath) {
12
+ return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);
13
+ }
14
+ function createReactRouterInstrumentation(history, name, allRoutes, matchPath) {
15
+ if (allRoutes === void 0) { allRoutes = []; }
16
+ function getInitPathName() {
17
+ if (history && history.location) {
18
+ return history.location.pathname;
19
+ }
20
+ if (global && global.location) {
21
+ return global.location.pathname;
22
+ }
23
+ return undefined;
24
+ }
25
+ function getTransactionName(pathname) {
26
+ if (allRoutes.length === 0 || !matchPath) {
27
+ return pathname;
28
+ }
29
+ var branches = matchRoutes(allRoutes, pathname, matchPath);
30
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
31
+ for (var x = 0; x < branches.length; x++) {
32
+ if (branches[x].match.isExact) {
33
+ return branches[x].match.path;
34
+ }
35
+ }
36
+ return pathname;
37
+ }
38
+ return function (customStartTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) {
39
+ if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; }
40
+ if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; }
41
+ var initPathName = getInitPathName();
42
+ if (startTransactionOnPageLoad && initPathName) {
43
+ activeTransaction = customStartTransaction({
44
+ name: getTransactionName(initPathName),
45
+ op: 'pageload',
46
+ tags: {
47
+ 'routing.instrumentation': name,
48
+ },
49
+ });
50
+ }
51
+ if (startTransactionOnLocationChange && history.listen) {
52
+ history.listen(function (location, action) {
53
+ if (action && (action === 'PUSH' || action === 'POP')) {
54
+ if (activeTransaction) {
55
+ activeTransaction.finish();
56
+ }
57
+ var tags = {
58
+ 'routing.instrumentation': name,
59
+ };
60
+ activeTransaction = customStartTransaction({
61
+ name: getTransactionName(location.pathname),
62
+ op: 'navigation',
63
+ tags: tags,
64
+ });
65
+ }
66
+ });
67
+ }
68
+ };
69
+ }
70
+ /**
71
+ * Matches a set of routes to a pathname
72
+ * Based on implementation from
73
+ */
74
+ function matchRoutes(routes, pathname, matchPath, branch) {
75
+ if (branch === void 0) { branch = []; }
76
+ routes.some(function (route) {
77
+ var match = route.path
78
+ ? matchPath(pathname, route)
79
+ : branch.length
80
+ ? branch[branch.length - 1].match // use parent match
81
+ : computeRootMatch(pathname); // use default "root" match
82
+ if (match) {
83
+ branch.push({ route: route, match: match });
84
+ if (route.routes) {
85
+ matchRoutes(route.routes, pathname, matchPath, branch);
86
+ }
87
+ }
88
+ return !!match;
89
+ });
90
+ return branch;
91
+ }
92
+ function computeRootMatch(pathname) {
93
+ return { path: '/', url: '/', params: {}, isExact: pathname === '/' };
94
+ }
95
+ /* eslint-disable @typescript-eslint/no-explicit-any */
96
+ export function withSentryRouting(Route) {
97
+ var componentDisplayName = Route.displayName || Route.name;
98
+ var WrappedRoute = function (props) {
99
+ if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {
100
+ activeTransaction.setName(props.computedMatch.path);
101
+ }
102
+ // @ts-ignore Setting more specific React Component typing for `R` generic above
103
+ // will break advanced type inference done by react router params:
104
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
105
+ return React.createElement(Route, __assign({}, props));
106
+ };
107
+ WrappedRoute.displayName = "sentryRoute(" + componentDisplayName + ")";
108
+ hoistNonReactStatics(WrappedRoute, Route);
109
+ // @ts-ignore Setting more specific React Component typing for `R` generic above
110
+ // will break advanced type inference done by react router params:
111
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164
112
+ return WrappedRoute;
113
+ }
114
+ /* eslint-enable @typescript-eslint/no-explicit-any */
115
+ //# sourceMappingURL=reactrouter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouter.js","sourceRoot":"","sources":["../src/reactrouter.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAuB/B,sDAAsD;AAEtD,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC,IAAI,iBAA0C,CAAC;AAE/C,MAAM,UAAU,4BAA4B,CAC1C,OAAsB,EACtB,MAAsB,EACtB,SAAqB;IAErB,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,OAAsB,EACtB,MAAsB,EACtB,SAAqB;IAErB,OAAO,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,gCAAgC,CACvC,OAAsB,EACtB,IAAY,EACZ,SAA6B,EAC7B,SAAq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B,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,KAAK,GAAG,EAAE,CAAC;AACxE,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,iBAAiB,CAAkE,KAAQ;IACzG,IAAM,oBAAoB,GAAI,KAAa,CAAC,WAAW,IAAK,KAAa,CAAC,IAAI,CAAC;IAE/E,IAAM,YAAY,GAAgB,UAAC,KAAQ;QACzC,IAAI,iBAAiB,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE;YACpF,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SACrD;QAED,gFAAgF;QAChF,kEAAkE;QAClE,2IAA2I;QAC3I,OAAO,oBAAC,KAAK,eAAK,KAAK,EAAI,CAAC;IAC9B,CAAC,CAAC;IAEF,YAAY,CAAC,WAAW,GAAG,iBAAe,oBAAoB,MAAG,CAAC;IAClE,oBAAoB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC1C,gFAAgF;IAChF,kEAAkE;IAClE,2IAA2I;IAC3I,OAAO,YAAY,CAAC;AACtB,CAAC;AACD,sDAAsD","sourcesContent":["import { Transaction } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport * as React from 'react';\n\nimport { Action, Location, ReactRouterInstrumentation } from './types';\n\n// We need to disable eslint no-explict-any because any is required for the\n// react-router typings.\n/* eslint-disable @typescript-eslint/no-explicit-any */\ntype Match = { path: string; url: string; params: Record<string, any>; isExact: boolean };\n\nexport type RouterHistory = {\n location?: Location;\n listen?(cb: (location: Location, action: Action) => void): void;\n} & Record<string, any>;\n\nexport type RouteConfig = {\n [propName: string]: any;\n path?: string | string[];\n exact?: boolean;\n component?: JSX.Element;\n routes?: RouteConfig[];\n};\n\ntype MatchPath = (pathname: string, props: string | string[] | any, parent?: Match | null) => Match | null;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\nconst global = getGlobalObject<Window>();\n\nlet activeTransaction: Transaction | undefined;\n\nexport function reactRouterV4Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'react-router-v4', routes, matchPath);\n}\n\nexport function reactRouterV5Instrumentation(\n history: RouterHistory,\n routes?: RouteConfig[],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n return createReactRouterInstrumentation(history, 'react-router-v5', routes, matchPath);\n}\n\nfunction createReactRouterInstrumentation(\n history: RouterHistory,\n name: string,\n allRoutes: RouteConfig[] = [],\n matchPath?: MatchPath,\n): ReactRouterInstrumentation {\n function getInitPathName(): string | undefined {\n if (history && history.location) {\n return history.location.pathname;\n }\n\n if (global && global.location) {\n return global.location.pathname;\n }\n\n return undefined;\n }\n\n function getTransactionName(pathname: string): string {\n if (allRoutes.length === 0 || !matchPath) {\n return pathname;\n }\n\n const branches = matchRoutes(allRoutes, pathname, matchPath);\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let x = 0; x < branches.length; x++) {\n if (branches[x].match.isExact) {\n return branches[x].match.path;\n }\n }\n\n return pathname;\n }\n\n return (customStartTransaction, startTransactionOnPageLoad = true, startTransactionOnLocationChange = true): void => {\n const initPathName = getInitPathName();\n if (startTransactionOnPageLoad && initPathName) {\n activeTransaction = customStartTransaction({\n name: getTransactionName(initPathName),\n op: 'pageload',\n tags: {\n 'routing.instrumentation': name,\n },\n });\n }\n\n if (startTransactionOnLocationChange && history.listen) {\n history.listen((location, action) => {\n if (action && (action === 'PUSH' || action === 'POP')) {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n const tags = {\n 'routing.instrumentation': name,\n };\n\n activeTransaction = customStartTransaction({\n name: getTransactionName(location.pathname),\n op: 'navigation',\n tags,\n });\n }\n });\n }\n };\n}\n\n/**\n * Matches a set of routes to a pathname\n * Based on implementation from\n */\nfunction matchRoutes(\n routes: RouteConfig[],\n pathname: string,\n matchPath: MatchPath,\n branch: Array<{ route: RouteConfig; match: Match }> = [],\n): Array<{ route: RouteConfig; match: Match }> {\n routes.some(route => {\n const match = route.path\n ? matchPath(pathname, route)\n : branch.length\n ? branch[branch.length - 1].match // use parent match\n : computeRootMatch(pathname); // use default \"root\" match\n\n if (match) {\n branch.push({ route, match });\n\n if (route.routes) {\n matchRoutes(route.routes, pathname, matchPath, branch);\n }\n }\n\n return !!match;\n });\n\n return branch;\n}\n\nfunction computeRootMatch(pathname: string): Match {\n return { path: '/', url: '/', params: {}, isExact: pathname === '/' };\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport function withSentryRouting<P extends Record<string, any>, R extends React.ComponentType<P>>(Route: R): R {\n const componentDisplayName = (Route as any).displayName || (Route as any).name;\n\n const WrappedRoute: React.FC<P> = (props: P) => {\n if (activeTransaction && props && props.computedMatch && props.computedMatch.isExact) {\n activeTransaction.setName(props.computedMatch.path);\n }\n\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params:\n // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return <Route {...props} />;\n };\n\n WrappedRoute.displayName = `sentryRoute(${componentDisplayName})`;\n hoistNonReactStatics(WrappedRoute, Route);\n // @ts-ignore Setting more specific React Component typing for `R` generic above\n // will break advanced type inference done by react router params:\n // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/13dc4235c069e25fe7ee16e11f529d909f9f3ff8/types/react-router/index.d.ts#L154-L164\n return WrappedRoute;\n}\n/* eslint-enable @typescript-eslint/no-explicit-any */\n"]}
@@ -0,0 +1,26 @@
1
+ import { Location, ReactRouterInstrumentation } from './types';
2
+ declare type HistoryV3 = {
3
+ location?: Location;
4
+ listen?(cb: (location: Location) => void): void;
5
+ } & Record<string, any>;
6
+ export declare type Route = {
7
+ path?: string;
8
+ childRoutes?: Route[];
9
+ };
10
+ export declare type Match = (props: {
11
+ location: Location;
12
+ routes: Route[];
13
+ }, cb: (error?: Error, _redirectLocation?: Location, renderProps?: {
14
+ routes?: Route[];
15
+ }) => void) => void;
16
+ /**
17
+ * Creates routing instrumentation for React Router v3
18
+ * Works for React Router >= 3.2.0 and < 4.0.0
19
+ *
20
+ * @param history object from the `history` library
21
+ * @param routes a list of all routes, should be
22
+ * @param match `Router.match` utility
23
+ */
24
+ export declare function reactRouterV3Instrumentation(history: HistoryV3, routes: Route[], match: Match): ReactRouterInstrumentation;
25
+ export {};
26
+ //# sourceMappingURL=reactrouterv3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouterv3.d.ts","sourceRoot":"","sources":["../src/reactrouterv3.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAK/D,aAAK,SAAS,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC;CAEjD,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,oBAAY,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC;AAE7D,oBAAY,KAAK,GAAG,CAClB,KAAK,EAAE;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,EAC9C,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,IAAI,KAC1F,IAAI,CAAC;AAIV;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,KAAK,EAAE,EACf,KAAK,EAAE,KAAK,GACX,0BAA0B,CA+C5B"}
@@ -0,0 +1,103 @@
1
+ import { getGlobalObject } from '@sentry/utils';
2
+ var global = getGlobalObject();
3
+ /**
4
+ * Creates routing instrumentation for React Router v3
5
+ * Works for React Router >= 3.2.0 and < 4.0.0
6
+ *
7
+ * @param history object from the `history` library
8
+ * @param routes a list of all routes, should be
9
+ * @param match `Router.match` utility
10
+ */
11
+ export function reactRouterV3Instrumentation(history, routes, match) {
12
+ return function (startTransaction, startTransactionOnPageLoad, startTransactionOnLocationChange) {
13
+ if (startTransactionOnPageLoad === void 0) { startTransactionOnPageLoad = true; }
14
+ if (startTransactionOnLocationChange === void 0) { startTransactionOnLocationChange = true; }
15
+ var activeTransaction;
16
+ var prevName;
17
+ // Have to use global.location because history.location might not be defined.
18
+ if (startTransactionOnPageLoad && global && global.location) {
19
+ normalizeTransactionName(routes, global.location, match, function (localName) {
20
+ prevName = localName;
21
+ activeTransaction = startTransaction({
22
+ name: prevName,
23
+ op: 'pageload',
24
+ tags: {
25
+ 'routing.instrumentation': 'react-router-v3',
26
+ },
27
+ });
28
+ });
29
+ }
30
+ if (startTransactionOnLocationChange && history.listen) {
31
+ history.listen(function (location) {
32
+ if (location.action === 'PUSH' || location.action === 'POP') {
33
+ if (activeTransaction) {
34
+ activeTransaction.finish();
35
+ }
36
+ var tags_1 = {
37
+ 'routing.instrumentation': 'react-router-v3',
38
+ };
39
+ if (prevName) {
40
+ tags_1.from = prevName;
41
+ }
42
+ normalizeTransactionName(routes, location, match, function (localName) {
43
+ prevName = localName;
44
+ activeTransaction = startTransaction({
45
+ name: prevName,
46
+ op: 'navigation',
47
+ tags: tags_1,
48
+ });
49
+ });
50
+ }
51
+ });
52
+ }
53
+ };
54
+ }
55
+ /**
56
+ * Normalize transaction names using `Router.match`
57
+ */
58
+ function normalizeTransactionName(appRoutes, location, match, callback) {
59
+ var name = location.pathname;
60
+ match({
61
+ location: location,
62
+ routes: appRoutes,
63
+ }, function (error, _redirectLocation, renderProps) {
64
+ if (error || !renderProps) {
65
+ return callback(name);
66
+ }
67
+ var routePath = getRouteStringFromRoutes(renderProps.routes || []);
68
+ if (routePath.length === 0 || routePath === '/*') {
69
+ return callback(name);
70
+ }
71
+ name = routePath;
72
+ return callback(name);
73
+ });
74
+ }
75
+ /**
76
+ * Generate route name from array of routes
77
+ */
78
+ function getRouteStringFromRoutes(routes) {
79
+ if (!Array.isArray(routes) || routes.length === 0) {
80
+ return '';
81
+ }
82
+ var routesWithPaths = routes.filter(function (route) { return !!route.path; });
83
+ var index = -1;
84
+ for (var x = routesWithPaths.length - 1; x >= 0; x--) {
85
+ var route = routesWithPaths[x];
86
+ if (route.path && route.path.startsWith('/')) {
87
+ index = x;
88
+ break;
89
+ }
90
+ }
91
+ return routesWithPaths
92
+ .slice(index)
93
+ .filter(function (_a) {
94
+ var path = _a.path;
95
+ return !!path;
96
+ })
97
+ .map(function (_a) {
98
+ var path = _a.path;
99
+ return path;
100
+ })
101
+ .join('');
102
+ }
103
+ //# sourceMappingURL=reactrouterv3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactrouterv3.js","sourceRoot":"","sources":["../src/reactrouterv3.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAoBhD,IAAM,MAAM,GAAG,eAAe,EAAU,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAkB,EAClB,MAAe,EACf,KAAY;IAEZ,OAAO,UACL,gBAA0E,EAC1E,0BAA0C,EAC1C,gCAAgD;QADhD,2CAAA,EAAA,iCAA0C;QAC1C,iDAAA,EAAA,uC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,eAAe;SACnB,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,UAAC,EAAQ;YAAN,cAAI;QAAO,OAAA,CAAC,CAAC,IAAI;IAAN,CAAM,CAAC;SAC5B,GAAG,CAAC,UAAC,EAAQ;YAAN,cAAI;QAAO,OAAA,IAAI;IAAJ,CAAI,CAAC;SACvB,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { Primitive, Transaction, TransactionContext } from '@sentry/types';\nimport { getGlobalObject } from '@sentry/utils';\n\nimport { Location, ReactRouterInstrumentation } from './types';\n\n// Many of the types below had to be mocked out to prevent typescript issues\n// these types are required for correct functionality.\n\ntype HistoryV3 = {\n location?: Location;\n listen?(cb: (location: Location) => void): void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type Route = { path?: string; childRoutes?: Route[] };\n\nexport type Match = (\n props: { location: Location; routes: Route[] },\n cb: (error?: Error, _redirectLocation?: Location, renderProps?: { routes?: Route[] }) => void,\n) => void;\n\nconst global = getGlobalObject<Window>();\n\n/**\n * Creates routing instrumentation for React Router v3\n * Works for React Router >= 3.2.0 and < 4.0.0\n *\n * @param history object from the `history` library\n * @param routes a list of all routes, should be\n * @param match `Router.match` utility\n */\nexport function reactRouterV3Instrumentation(\n history: HistoryV3,\n routes: Route[],\n match: Match,\n): ReactRouterInstrumentation {\n return (\n startTransaction: (context: TransactionContext) => Transaction | undefined,\n startTransactionOnPageLoad: boolean = true,\n startTransactionOnLocationChange: boolean = true,\n ) => {\n let activeTransaction: Transaction | undefined;\n let prevName: string | undefined;\n\n // Have to use global.location because history.location might not be defined.\n if (startTransactionOnPageLoad && global && global.location) {\n normalizeTransactionName(routes, (global.location as unknown) as Location, match, (localName: string) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'pageload',\n tags: {\n 'routing.instrumentation': 'react-router-v3',\n },\n });\n });\n }\n\n if (startTransactionOnLocationChange && history.listen) {\n history.listen(location => {\n if (location.action === 'PUSH' || location.action === 'POP') {\n if (activeTransaction) {\n activeTransaction.finish();\n }\n const tags: Record<string, Primitive> = {\n 'routing.instrumentation': 'react-router-v3',\n };\n if (prevName) {\n tags.from = prevName;\n }\n normalizeTransactionName(routes, location, match, (localName: string) => {\n prevName = localName;\n activeTransaction = startTransaction({\n name: prevName,\n op: 'navigation',\n tags,\n });\n });\n }\n });\n }\n };\n}\n\n/**\n * Normalize transaction names using `Router.match`\n */\nfunction normalizeTransactionName(\n appRoutes: Route[],\n location: Location,\n match: Match,\n callback: (pathname: string) => void,\n): void {\n let name = location.pathname;\n match(\n {\n location,\n routes: appRoutes,\n },\n (error, _redirectLocation, renderProps) => {\n if (error || !renderProps) {\n return callback(name);\n }\n\n const routePath = getRouteStringFromRoutes(renderProps.routes || []);\n if (routePath.length === 0 || routePath === '/*') {\n return callback(name);\n }\n\n name = routePath;\n return callback(name);\n },\n );\n}\n\n/**\n * Generate route name from array of routes\n */\nfunction getRouteStringFromRoutes(routes: Route[]): string {\n if (!Array.isArray(routes) || routes.length === 0) {\n return '';\n }\n\n const routesWithPaths: Route[] = routes.filter((route: Route) => !!route.path);\n\n let index = -1;\n for (let x = routesWithPaths.length - 1; x >= 0; x--) {\n const route = routesWithPaths[x];\n if (route.path && route.path.startsWith('/')) {\n index = x;\n break;\n }\n }\n\n return routesWithPaths\n .slice(index)\n .filter(({ path }) => !!path)\n .map(({ path }) => path)\n .join('');\n}\n"]}
package/esm/redux.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { Scope } from '@sentry/types';
2
+ interface Action<T = any> {
3
+ type: T;
4
+ }
5
+ interface AnyAction extends Action {
6
+ [extraProps: string]: any;
7
+ }
8
+ export interface SentryEnhancerOptions<S = any> {
9
+ /**
10
+ * Transforms the state before attaching it to an event.
11
+ * Use this to remove any private data before sending it to Sentry.
12
+ * Return null to not attach the state.
13
+ */
14
+ stateTransformer(state: S | undefined): (S & any) | null;
15
+ /**
16
+ * Transforms the action before sending it as a breadcrumb.
17
+ * Use this to remove any private data before sending it to Sentry.
18
+ * Return null to not send the breadcrumb.
19
+ */
20
+ actionTransformer(action: AnyAction): AnyAction | null;
21
+ /**
22
+ * Called on every state update, configure the Sentry Scope with the redux state.
23
+ */
24
+ configureScopeWithState?(scope: Scope, state: S): void;
25
+ }
26
+ /**
27
+ * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
28
+ *
29
+ * @param enhancerOptions Options to pass to the enhancer
30
+ */
31
+ declare function createReduxEnhancer(enhancerOptions?: Partial<SentryEnhancerOptions>): any;
32
+ export { createReduxEnhancer };
33
+ //# sourceMappingURL=redux.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redux.d.ts","sourceRoot":"","sources":["../src/redux.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,UAAU,MAAM,CAAC,CAAC,GAAG,GAAG;IACtB,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,SAAU,SAAQ,MAAM;IAChC,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC;CAC3B;AAuCD,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,GAAG;IAC5C;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACzD;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD;;OAEG;IACH,uBAAuB,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACxD;AAWD;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,GAAG,CA8ClF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
package/esm/redux.js ADDED
@@ -0,0 +1,53 @@
1
+ import { __assign } from "tslib";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { configureScope } from '@sentry/minimal';
4
+ var ACTION_BREADCRUMB_CATEGORY = 'redux.action';
5
+ var ACTION_BREADCRUMB_TYPE = 'info';
6
+ var STATE_CONTEXT_KEY = 'redux.state';
7
+ var defaultOptions = {
8
+ actionTransformer: function (action) { return action; },
9
+ stateTransformer: function (state) { return state || null; },
10
+ };
11
+ /**
12
+ * Creates an enhancer that would be passed to Redux's createStore to log actions and the latest state to Sentry.
13
+ *
14
+ * @param enhancerOptions Options to pass to the enhancer
15
+ */
16
+ function createReduxEnhancer(enhancerOptions) {
17
+ // Note: We return an any type as to not have type conflicts.
18
+ var options = __assign(__assign({}, defaultOptions), enhancerOptions);
19
+ return function (next) { return function (reducer, initialState) {
20
+ var sentryReducer = function (state, action) {
21
+ var newState = reducer(state, action);
22
+ configureScope(function (scope) {
23
+ /* Action breadcrumbs */
24
+ var transformedAction = options.actionTransformer(action);
25
+ if (typeof transformedAction !== 'undefined' && transformedAction !== null) {
26
+ scope.addBreadcrumb({
27
+ category: ACTION_BREADCRUMB_CATEGORY,
28
+ data: transformedAction,
29
+ type: ACTION_BREADCRUMB_TYPE,
30
+ });
31
+ }
32
+ /* Set latest state to scope */
33
+ var transformedState = options.stateTransformer(newState);
34
+ if (typeof transformedState !== 'undefined' && transformedState !== null) {
35
+ scope.setContext(STATE_CONTEXT_KEY, transformedState);
36
+ }
37
+ else {
38
+ scope.setContext(STATE_CONTEXT_KEY, null);
39
+ }
40
+ /* Allow user to configure scope with latest state */
41
+ // eslint-disable-next-line @typescript-eslint/unbound-method
42
+ var configureScopeWithState = options.configureScopeWithState;
43
+ if (typeof configureScopeWithState === 'function') {
44
+ configureScopeWithState(scope, newState);
45
+ }
46
+ });
47
+ return newState;
48
+ };
49
+ return next(sentryReducer, initialState);
50
+ }; };
51
+ }
52
+ export { createReduxEnhancer };
53
+ //# sourceMappingURL=redux.js.map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,EAAE;oBACxE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;iBACvD;qBAAM;oBACL,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;iBAC3C;gBAED,qDAAqD;gBACrD,6DAA6D;gBACrD,IAAA,yDAAuB,CAAa;gBAC5C,IAAI,OAAO,uBAAuB,KAAK,UAAU,EAAE;oBACjD,uBAAuB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;iBAC1C;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC;QAEF,OAAO,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC,EAtCsE,CAsCtE,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { configureScope } from '@sentry/minimal';\nimport { Scope } from '@sentry/types';\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> = 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 * 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';\nconst STATE_CONTEXT_KEY = 'redux.state';\n\nconst defaultOptions: SentryEnhancerOptions = {\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 => <S = any, A extends Action = AnyAction>(\n reducer: Reducer<S, A>,\n initialState?: PreloadedState<S>,\n ) => {\n const sentryReducer: Reducer<S, A> = (state, action): S => {\n const newState = reducer(state, action);\n\n configureScope(scope => {\n /* Action breadcrumbs */\n const transformedAction = options.actionTransformer(action);\n if (typeof transformedAction !== 'undefined' && transformedAction !== null) {\n scope.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 scope.setContext(STATE_CONTEXT_KEY, transformedState);\n } else {\n scope.setContext(STATE_CONTEXT_KEY, null);\n }\n\n /* Allow user to configure scope with latest state */\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { configureScopeWithState } = options;\n if (typeof configureScopeWithState === 'function') {\n configureScopeWithState(scope, newState);\n }\n });\n\n return newState;\n };\n\n return next(sentryReducer, initialState);\n };\n}\n\nexport { createReduxEnhancer };\n"]}
package/esm/sdk.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { BrowserOptions } from '@sentry/browser';
2
+ /**
3
+ * Inits the React SDK
4
+ */
5
+ export declare function init(options: BrowserOptions): void;
6
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAoC,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAalD"}
package/esm/sdk.js ADDED
@@ -0,0 +1,19 @@
1
+ import { init as browserInit, SDK_VERSION } from '@sentry/browser';
2
+ /**
3
+ * Inits the React SDK
4
+ */
5
+ export function init(options) {
6
+ options._metadata = options._metadata || {};
7
+ options._metadata.sdk = options._metadata.sdk || {
8
+ name: 'sentry.javascript.react',
9
+ packages: [
10
+ {
11
+ name: 'npm:@sentry/react',
12
+ version: SDK_VERSION,
13
+ },
14
+ ],
15
+ version: SDK_VERSION,
16
+ };
17
+ browserInit(options);
18
+ }
19
+ //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,IAAI,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnF;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAuB;IAC1C,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;QAC/C,IAAI,EAAE,yBAAyB;QAC/B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,WAAW;aACrB;SACF;QACD,OAAO,EAAE,WAAW;KACrB,CAAC;IACF,WAAW,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC","sourcesContent":["import { BrowserOptions, init as browserInit, SDK_VERSION } from '@sentry/browser';\n\n/**\n * Inits the React SDK\n */\nexport function init(options: BrowserOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.react',\n packages: [\n {\n name: 'npm:@sentry/react',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n browserInit(options);\n}\n"]}
package/esm/types.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Transaction, TransactionContext } from '@sentry/types';
2
+ export declare type Action = 'PUSH' | 'REPLACE' | 'POP';
3
+ export declare type Location = {
4
+ pathname: string;
5
+ action?: Action;
6
+ } & Record<string, any>;
7
+ export declare type ReactRouterInstrumentation = <T extends Transaction>(startTransaction: (context: TransactionContext) => T | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean) => void;
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEhE,oBAAY,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,CAAC;AAEhD,oBAAY,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CAEjB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,oBAAY,0BAA0B,GAAG,CAAC,CAAC,SAAS,WAAW,EAC7D,gBAAgB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,CAAC,GAAG,SAAS,EAChE,0BAA0B,CAAC,EAAE,OAAO,EACpC,gCAAgC,CAAC,EAAE,OAAO,KACvC,IAAI,CAAC"}
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Transaction, TransactionContext } from '@sentry/types';\n\nexport type Action = 'PUSH' | 'REPLACE' | 'POP';\n\nexport type Location = {\n pathname: string;\n action?: Action;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & Record<string, any>;\n\nexport type ReactRouterInstrumentation = <T extends Transaction>(\n startTransaction: (context: TransactionContext) => T | undefined,\n startTransactionOnPageLoad?: boolean,\n startTransactionOnLocationChange?: boolean,\n) => void;\n"]}
package/package.json ADDED
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "@sentry/react",
3
+ "version": "6.13.0-beta.1",
4
+ "description": "Official Sentry SDK for React.js",
5
+ "repository": "git://github.com/getsentry/sentry-javascript.git",
6
+ "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
7
+ "author": "Sentry",
8
+ "license": "BSD-3-Clause",
9
+ "engines": {
10
+ "node": ">=6"
11
+ },
12
+ "main": "dist/index.js",
13
+ "module": "esm/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "dependencies": {
19
+ "@sentry/browser": "6.13.0-beta.1",
20
+ "@sentry/minimal": "6.13.0-beta.1",
21
+ "@sentry/types": "6.13.0-beta.1",
22
+ "@sentry/utils": "6.13.0-beta.1",
23
+ "hoist-non-react-statics": "^3.3.2",
24
+ "tslib": "^1.9.3"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "15.x || 16.x || 17.x"
28
+ },
29
+ "devDependencies": {
30
+ "@sentry-internal/eslint-config-sdk": "6.13.0-beta.1",
31
+ "@testing-library/react": "^11.2.6",
32
+ "@testing-library/react-hooks": "^5.1.1",
33
+ "@types/history-4": "npm:@types/history@4.7.8",
34
+ "@types/history-5": "npm:@types/history@4.7.8",
35
+ "@types/hoist-non-react-statics": "^3.3.1",
36
+ "@types/react": "^17.0.3",
37
+ "@types/react-router-3": "npm:@types/react-router@3.0.24",
38
+ "@types/react-router-4": "npm:@types/react-router@5.1.14",
39
+ "@types/react-router-5": "npm:@types/react-router@5.1.14",
40
+ "eslint-plugin-react": "^7.20.5",
41
+ "eslint-plugin-react-hooks": "^4.0.8",
42
+ "history-4": "npm:history@4.6.0",
43
+ "history-5": "npm:history@4.9.0",
44
+ "jest": "^24.7.1",
45
+ "jsdom": "^16.2.2",
46
+ "npm-run-all": "^4.1.2",
47
+ "prettier": "1.19.0",
48
+ "react": "^17.0.0",
49
+ "react-dom": "^17.0.0",
50
+ "react-router-3": "npm:react-router@3.2.0",
51
+ "react-router-4": "npm:react-router@4.1.0",
52
+ "react-router-5": "npm:react-router@5.0.0",
53
+ "react-test-renderer": "^16.13.1",
54
+ "redux": "^4.0.5",
55
+ "rimraf": "^2.6.3",
56
+ "typescript": "3.7.5"
57
+ },
58
+ "scripts": {
59
+ "build": "run-p build:es5 build:esm",
60
+ "build:es5": "tsc -p tsconfig.build.json",
61
+ "build:esm": "tsc -p tsconfig.esm.json",
62
+ "build:watch": "run-p build:watch:es5 build:watch:esm",
63
+ "build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
64
+ "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
65
+ "clean": "rimraf dist esm build coverage",
66
+ "link:yarn": "yarn link",
67
+ "lint": "run-s lint:prettier lint:eslint",
68
+ "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
69
+ "lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
70
+ "fix": "run-s fix:eslint fix:prettier",
71
+ "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
72
+ "fix:eslint": "eslint . --format stylish --fix",
73
+ "test": "jest",
74
+ "test:watch": "jest --watch",
75
+ "pack": "npm pack",
76
+ "circularDepCheck": "madge --circular src/index.ts"
77
+ },
78
+ "volta": {
79
+ "extends": "../../package.json"
80
+ },
81
+ "jest": {
82
+ "collectCoverage": true,
83
+ "transform": {
84
+ "^.+\\.ts$": "ts-jest",
85
+ "^.+\\.tsx$": "ts-jest"
86
+ },
87
+ "moduleFileExtensions": [
88
+ "js",
89
+ "ts",
90
+ "tsx"
91
+ ],
92
+ "testEnvironment": "jsdom",
93
+ "testMatch": [
94
+ "**/*.test.ts",
95
+ "**/*.test.tsx"
96
+ ],
97
+ "globals": {
98
+ "ts-jest": {
99
+ "tsConfig": "./tsconfig.json",
100
+ "diagnostics": false
101
+ }
102
+ }
103
+ },
104
+ "sideEffects": [
105
+ "./src/index.ts"
106
+ ]
107
+ }