@grafana/faro-react 1.7.0 → 1.7.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.
- package/README.md +22 -8
- package/dist/bundle/types/router/v6/types.d.ts +16 -0
- package/dist/bundle/types/router/v6/withFaroRouterInstrumentation.d.ts +2 -2
- package/dist/cjs/router/v6/types.js.map +1 -1
- package/dist/cjs/router/v6/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/esm/router/v6/types.js.map +1 -1
- package/dist/esm/router/v6/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/types/router/v6/types.d.ts +16 -0
- package/dist/types/router/v6/withFaroRouterInstrumentation.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -204,6 +204,28 @@ In case of an error it sends a Faro error event which contains the error message
|
|
|
204
204
|
stack of the component which contains the exception, and the name of name of the error boundary
|
|
205
205
|
if configured.
|
|
206
206
|
|
|
207
|
+
```ts
|
|
208
|
+
import { initializeFaro } from '@grafana/faro-react';
|
|
209
|
+
|
|
210
|
+
initializeFaro({
|
|
211
|
+
// required: the URL of the Grafana collector
|
|
212
|
+
url: 'my/collector/url',
|
|
213
|
+
|
|
214
|
+
// required: the identification label of your application
|
|
215
|
+
app: {
|
|
216
|
+
name: 'my-react-app',
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
instrumentations: [
|
|
220
|
+
// Load the default Web instrumentations
|
|
221
|
+
...getWebInstrumentations(),
|
|
222
|
+
|
|
223
|
+
// Must be initialized to get FaroErrorBoundary support
|
|
224
|
+
new ReactIntegration(),
|
|
225
|
+
],
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
207
229
|
```tsx
|
|
208
230
|
import { FaroErrorBoundary } from '@grafana/faro-react';
|
|
209
231
|
|
|
@@ -240,14 +262,6 @@ Lifecycle callbacks:
|
|
|
240
262
|
object as a parameter
|
|
241
263
|
- `onReset`: Executed when React calls resetErrorBoundary, with the Error object as a parameter
|
|
242
264
|
|
|
243
|
-
```tsx
|
|
244
|
-
// ...
|
|
245
|
-
|
|
246
|
-
<FaroErrorBoundary>
|
|
247
|
-
<MyComponent />
|
|
248
|
-
</FaroErrorBoundary>
|
|
249
|
-
```
|
|
250
|
-
|
|
251
265
|
```tsx
|
|
252
266
|
import { FaroErrorBoundary, PushErrorOptions } from '@grafana/faro-react';
|
|
253
267
|
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { ReactRouterLocation } from '../types';
|
|
3
|
+
interface IndexRouteObjectV6DataRouter {
|
|
4
|
+
caseSensitive?: boolean;
|
|
5
|
+
children?: undefined;
|
|
6
|
+
element?: React.ReactNode | null;
|
|
7
|
+
index: true;
|
|
8
|
+
path?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NonIndexRouteObjectV6DataRouter {
|
|
11
|
+
caseSensitive?: boolean;
|
|
12
|
+
children?: RouteObjectV6DataRouter[];
|
|
13
|
+
element?: React.ReactNode | null;
|
|
14
|
+
index?: false;
|
|
15
|
+
path?: string;
|
|
16
|
+
}
|
|
17
|
+
export type RouteObjectV6DataRouter = IndexRouteObjectV6DataRouter | NonIndexRouteObjectV6DataRouter;
|
|
3
18
|
export interface ReactRouterV6BaseRouteObject {
|
|
4
19
|
action?: (...args: any[]) => any;
|
|
5
20
|
caseSensitive?: boolean;
|
|
@@ -50,3 +65,4 @@ export type EventRouteTransitionAttributes = {
|
|
|
50
65
|
fromRoute?: string;
|
|
51
66
|
fromUrl?: string;
|
|
52
67
|
};
|
|
68
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NavigationType, ReactRouterLocation } from '../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RouteObjectV6DataRouter } from './types';
|
|
3
3
|
interface RouterState {
|
|
4
4
|
historyAction: NavigationType | any;
|
|
5
5
|
location: ReactRouterLocation;
|
|
6
6
|
}
|
|
7
7
|
interface Router {
|
|
8
8
|
state: RouterState;
|
|
9
|
-
routes:
|
|
9
|
+
routes: RouteObjectV6DataRouter[];
|
|
10
10
|
subscribe(fn: (state: RouterState) => void): () => void;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport type { ReactRouterLocation } from '../types';\n\nexport interface ReactRouterV6BaseRouteObject {\n action?: (...args: any[]) => any;\n caseSensitive?: boolean;\n hasErrorBoundary?: boolean;\n handle?: any;\n id?: string;\n loader?: (...args: any[]) => any;\n path?: string;\n shouldRevalidate?: (...args: any[]) => any;\n}\n\nexport type ReactRouterV6RouteObject = ReactRouterV6BaseRouteObject &\n (\n | {\n children?: undefined;\n index: true;\n }\n | {\n children?: ReactRouterV6RouteObject[];\n index?: false;\n }\n );\n\nexport interface ReactRouterV6RoutesProps {\n children?: ReactNode;\n location?: Partial<ReactRouterLocation> | string;\n routesComponent?: ReactRouterV6RoutesShape;\n}\n\nexport type ReactRouterV6Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\nexport interface ReactRouterV6RouteMatch<ParamKey extends string = string> {\n params: ReactRouterV6Params<ParamKey>;\n pathname: string;\n pathnameBase: string;\n route: ReactRouterV6RouteObject;\n}\n\nexport type ReactRouterV6CreateRoutesFromChildren = (children: ReactNode) => ReactRouterV6RouteObject[];\n\nexport type ReactRouterV6MatchRoutes = (\n routes: ReactRouterV6RouteObject[],\n location: Partial<ReactRouterLocation> | string,\n basename?: string | undefined\n) => ReactRouterV6RouteMatch[] | null;\n\nexport type ReactRouterV6RoutesShape = (props: ReactRouterV6RoutesProps) => ReactElement | null;\n\nexport type ReactRouterV6UseLocation = () => ReactRouterLocation;\n\nexport type ReactRouterV6UseNavigationType = () => 'POP' | 'PUSH' | 'REPLACE';\n\nexport interface ReactRouterV6Dependencies {\n createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\n matchRoutes: ReactRouterV6MatchRoutes;\n Routes: ReactRouterV6RoutesShape;\n useLocation: ReactRouterV6UseLocation;\n useNavigationType: ReactRouterV6UseNavigationType;\n}\n\nexport interface ReactRouterV6DataRouterDependencies {\n matchRoutes: ReactRouterV6MatchRoutes;\n}\n\nexport type EventRouteTransitionAttributes = {\n fromRoute?: string;\n fromUrl?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport type { ReactRouterLocation } from '../types';\n\ninterface IndexRouteObjectV6DataRouter {\n caseSensitive?: boolean;\n children?: undefined;\n element?: React.ReactNode | null;\n index: true;\n path?: string;\n}\n\nexport interface NonIndexRouteObjectV6DataRouter {\n caseSensitive?: boolean;\n children?: RouteObjectV6DataRouter[];\n element?: React.ReactNode | null;\n index?: false;\n path?: string;\n}\n\nexport type RouteObjectV6DataRouter = IndexRouteObjectV6DataRouter | NonIndexRouteObjectV6DataRouter;\n\nexport interface ReactRouterV6BaseRouteObject {\n action?: (...args: any[]) => any;\n caseSensitive?: boolean;\n hasErrorBoundary?: boolean;\n handle?: any;\n id?: string;\n loader?: (...args: any[]) => any;\n path?: string;\n shouldRevalidate?: (...args: any[]) => any;\n}\n\nexport type ReactRouterV6RouteObject = ReactRouterV6BaseRouteObject &\n (\n | {\n children?: undefined;\n index: true;\n }\n | {\n children?: ReactRouterV6RouteObject[];\n index?: false;\n }\n );\n\nexport interface ReactRouterV6RoutesProps {\n children?: ReactNode;\n location?: Partial<ReactRouterLocation> | string;\n routesComponent?: ReactRouterV6RoutesShape;\n}\n\nexport type ReactRouterV6Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\nexport interface ReactRouterV6RouteMatch<ParamKey extends string = string> {\n params: ReactRouterV6Params<ParamKey>;\n pathname: string;\n pathnameBase: string;\n route: ReactRouterV6RouteObject;\n}\n\nexport type ReactRouterV6CreateRoutesFromChildren = (children: ReactNode) => ReactRouterV6RouteObject[];\n\nexport type ReactRouterV6MatchRoutes = (\n routes: ReactRouterV6RouteObject[],\n location: Partial<ReactRouterLocation> | string,\n basename?: string | undefined\n) => ReactRouterV6RouteMatch[] | null;\n\nexport type ReactRouterV6RoutesShape = (props: ReactRouterV6RoutesProps) => ReactElement | null;\n\nexport type ReactRouterV6UseLocation = () => ReactRouterLocation;\n\nexport type ReactRouterV6UseNavigationType = () => 'POP' | 'PUSH' | 'REPLACE';\n\nexport interface ReactRouterV6Dependencies {\n createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\n matchRoutes: ReactRouterV6MatchRoutes;\n Routes: ReactRouterV6RoutesShape;\n useLocation: ReactRouterV6UseLocation;\n useNavigationType: ReactRouterV6UseNavigationType;\n}\n\nexport interface ReactRouterV6DataRouterDependencies {\n matchRoutes: ReactRouterV6MatchRoutes;\n}\n\nexport type EventRouteTransitionAttributes = {\n fromRoute?: string;\n fromUrl?: string;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6/withFaroRouterInstrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAyE;AAEzE,mDAAyC;AACzC,kCAA+D;AAE/D,2DAAqD;AAErD,iCAA+C;AAa/C;;GAEG;AACH,SAAgB,6BAA6B,CAA4B,MAAS;IAChF,IAAI,SAAS,GAAmC,EAAE,CAAC;IAEnD,MAAM,CAAC,SAAS,CAAC,UAAC,KAAK;;QACrB,IAAM,cAAc,GAAmB,KAAK,CAAC,aAAa,CAAC;QAC3D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,kCAAa,IAAI,CAAC,cAAc,KAAK,sBAAc,CAAC,IAAI,IAAI,cAAc,KAAK,sBAAc,CAAC,GAAG,CAAC,EAAE;YACtG,IAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,IAAM,GAAG,GAAG,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,kBAAG,CAAC,SAAS,CAAC,iCAAkB,aAC9B,OAAO,EAAE,KAAK,EACd,KAAK,EAAE,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,IAC/B,SAAS,EACZ,CAAC;YAEH,SAAS,GAAG;gBACV,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,sEA0BC","sourcesContent":["import { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType, ReactRouterLocation } from '../types';\n\nimport { isInitialized } from './routerDependencies';\nimport type { EventRouteTransitionAttributes,
|
|
1
|
+
{"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6/withFaroRouterInstrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAAyE;AAEzE,mDAAyC;AACzC,kCAA+D;AAE/D,2DAAqD;AAErD,iCAA+C;AAa/C;;GAEG;AACH,SAAgB,6BAA6B,CAA4B,MAAS;IAChF,IAAI,SAAS,GAAmC,EAAE,CAAC;IAEnD,MAAM,CAAC,SAAS,CAAC,UAAC,KAAK;;QACrB,IAAM,cAAc,GAAmB,KAAK,CAAC,aAAa,CAAC;QAC3D,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,kCAAa,IAAI,CAAC,cAAc,KAAK,sBAAc,CAAC,IAAI,IAAI,cAAc,KAAK,sBAAc,CAAC,GAAG,CAAC,EAAE;YACtG,IAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,IAAM,GAAG,GAAG,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,kBAAG,CAAC,SAAS,CAAC,iCAAkB,aAC9B,OAAO,EAAE,KAAK,EACd,KAAK,EAAE,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,IAC/B,SAAS,EACZ,CAAC;YAEH,SAAS,GAAG;gBACV,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,sEA0BC","sourcesContent":["import { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType, ReactRouterLocation } from '../types';\n\nimport { isInitialized } from './routerDependencies';\nimport type { EventRouteTransitionAttributes, RouteObjectV6DataRouter } from './types';\nimport { getRouteFromLocation } from './utils';\n\ninterface RouterState {\n historyAction: NavigationType | any;\n location: ReactRouterLocation;\n}\n\ninterface Router {\n state: RouterState;\n routes: RouteObjectV6DataRouter[];\n subscribe(fn: (state: RouterState) => void): () => void;\n}\n\n/**\n * To use with React Router 6.4 data APIs.\n */\nexport function withFaroRouterInstrumentation<R extends Router = Router>(router: R) {\n let lastRoute: EventRouteTransitionAttributes = {};\n\n router.subscribe((state) => {\n const navigationType: NavigationType = state.historyAction;\n const location = state.location;\n const routes = router.routes;\n\n if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {\n const route = getRouteFromLocation(routes, location);\n const url = globalObject.location?.href;\n\n api.pushEvent(EVENT_ROUTE_CHANGE, {\n toRoute: route,\n toUrl: globalObject.location?.href,\n ...lastRoute,\n });\n\n lastRoute = {\n fromRoute: route,\n fromUrl: url,\n };\n }\n });\n\n return router;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport type { ReactRouterLocation } from '../types';\n\nexport interface ReactRouterV6BaseRouteObject {\n action?: (...args: any[]) => any;\n caseSensitive?: boolean;\n hasErrorBoundary?: boolean;\n handle?: any;\n id?: string;\n loader?: (...args: any[]) => any;\n path?: string;\n shouldRevalidate?: (...args: any[]) => any;\n}\n\nexport type ReactRouterV6RouteObject = ReactRouterV6BaseRouteObject &\n (\n | {\n children?: undefined;\n index: true;\n }\n | {\n children?: ReactRouterV6RouteObject[];\n index?: false;\n }\n );\n\nexport interface ReactRouterV6RoutesProps {\n children?: ReactNode;\n location?: Partial<ReactRouterLocation> | string;\n routesComponent?: ReactRouterV6RoutesShape;\n}\n\nexport type ReactRouterV6Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\nexport interface ReactRouterV6RouteMatch<ParamKey extends string = string> {\n params: ReactRouterV6Params<ParamKey>;\n pathname: string;\n pathnameBase: string;\n route: ReactRouterV6RouteObject;\n}\n\nexport type ReactRouterV6CreateRoutesFromChildren = (children: ReactNode) => ReactRouterV6RouteObject[];\n\nexport type ReactRouterV6MatchRoutes = (\n routes: ReactRouterV6RouteObject[],\n location: Partial<ReactRouterLocation> | string,\n basename?: string | undefined\n) => ReactRouterV6RouteMatch[] | null;\n\nexport type ReactRouterV6RoutesShape = (props: ReactRouterV6RoutesProps) => ReactElement | null;\n\nexport type ReactRouterV6UseLocation = () => ReactRouterLocation;\n\nexport type ReactRouterV6UseNavigationType = () => 'POP' | 'PUSH' | 'REPLACE';\n\nexport interface ReactRouterV6Dependencies {\n createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\n matchRoutes: ReactRouterV6MatchRoutes;\n Routes: ReactRouterV6RoutesShape;\n useLocation: ReactRouterV6UseLocation;\n useNavigationType: ReactRouterV6UseNavigationType;\n}\n\nexport interface ReactRouterV6DataRouterDependencies {\n matchRoutes: ReactRouterV6MatchRoutes;\n}\n\nexport type EventRouteTransitionAttributes = {\n fromRoute?: string;\n fromUrl?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\n\nimport type { ReactRouterLocation } from '../types';\n\ninterface IndexRouteObjectV6DataRouter {\n caseSensitive?: boolean;\n children?: undefined;\n element?: React.ReactNode | null;\n index: true;\n path?: string;\n}\n\nexport interface NonIndexRouteObjectV6DataRouter {\n caseSensitive?: boolean;\n children?: RouteObjectV6DataRouter[];\n element?: React.ReactNode | null;\n index?: false;\n path?: string;\n}\n\nexport type RouteObjectV6DataRouter = IndexRouteObjectV6DataRouter | NonIndexRouteObjectV6DataRouter;\n\nexport interface ReactRouterV6BaseRouteObject {\n action?: (...args: any[]) => any;\n caseSensitive?: boolean;\n hasErrorBoundary?: boolean;\n handle?: any;\n id?: string;\n loader?: (...args: any[]) => any;\n path?: string;\n shouldRevalidate?: (...args: any[]) => any;\n}\n\nexport type ReactRouterV6RouteObject = ReactRouterV6BaseRouteObject &\n (\n | {\n children?: undefined;\n index: true;\n }\n | {\n children?: ReactRouterV6RouteObject[];\n index?: false;\n }\n );\n\nexport interface ReactRouterV6RoutesProps {\n children?: ReactNode;\n location?: Partial<ReactRouterLocation> | string;\n routesComponent?: ReactRouterV6RoutesShape;\n}\n\nexport type ReactRouterV6Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\nexport interface ReactRouterV6RouteMatch<ParamKey extends string = string> {\n params: ReactRouterV6Params<ParamKey>;\n pathname: string;\n pathnameBase: string;\n route: ReactRouterV6RouteObject;\n}\n\nexport type ReactRouterV6CreateRoutesFromChildren = (children: ReactNode) => ReactRouterV6RouteObject[];\n\nexport type ReactRouterV6MatchRoutes = (\n routes: ReactRouterV6RouteObject[],\n location: Partial<ReactRouterLocation> | string,\n basename?: string | undefined\n) => ReactRouterV6RouteMatch[] | null;\n\nexport type ReactRouterV6RoutesShape = (props: ReactRouterV6RoutesProps) => ReactElement | null;\n\nexport type ReactRouterV6UseLocation = () => ReactRouterLocation;\n\nexport type ReactRouterV6UseNavigationType = () => 'POP' | 'PUSH' | 'REPLACE';\n\nexport interface ReactRouterV6Dependencies {\n createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\n matchRoutes: ReactRouterV6MatchRoutes;\n Routes: ReactRouterV6RoutesShape;\n useLocation: ReactRouterV6UseLocation;\n useNavigationType: ReactRouterV6UseNavigationType;\n}\n\nexport interface ReactRouterV6DataRouterDependencies {\n matchRoutes: ReactRouterV6MatchRoutes;\n}\n\nexport type EventRouteTransitionAttributes = {\n fromRoute?: string;\n fromUrl?: string;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6/withFaroRouterInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAa/C;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAA4B,MAAS;IAChF,IAAI,SAAS,GAAmC,EAAE,CAAC;IAEnD,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;;QACzB,MAAM,cAAc,GAAmB,KAAK,CAAC,aAAa,CAAC;QAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,aAAa,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,IAAI,IAAI,cAAc,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE;YACtG,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,MAAM,GAAG,GAAG,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,GAAG,CAAC,SAAS,CAAC,kBAAkB,kBAC9B,OAAO,EAAE,KAAK,EACd,KAAK,EAAE,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,IAC/B,SAAS,EACZ,CAAC;YAEH,SAAS,GAAG;gBACV,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType, ReactRouterLocation } from '../types';\n\nimport { isInitialized } from './routerDependencies';\nimport type { EventRouteTransitionAttributes,
|
|
1
|
+
{"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6/withFaroRouterInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAuB,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAa/C;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAA4B,MAAS;IAChF,IAAI,SAAS,GAAmC,EAAE,CAAC;IAEnD,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;;QACzB,MAAM,cAAc,GAAmB,KAAK,CAAC,aAAa,CAAC;QAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE7B,IAAI,aAAa,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,IAAI,IAAI,cAAc,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE;YACtG,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,MAAM,GAAG,GAAG,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,GAAG,CAAC,SAAS,CAAC,kBAAkB,kBAC9B,OAAO,EAAE,KAAK,EACd,KAAK,EAAE,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,IAC/B,SAAS,EACZ,CAAC;YAEH,SAAS,GAAG;gBACV,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType, ReactRouterLocation } from '../types';\n\nimport { isInitialized } from './routerDependencies';\nimport type { EventRouteTransitionAttributes, RouteObjectV6DataRouter } from './types';\nimport { getRouteFromLocation } from './utils';\n\ninterface RouterState {\n historyAction: NavigationType | any;\n location: ReactRouterLocation;\n}\n\ninterface Router {\n state: RouterState;\n routes: RouteObjectV6DataRouter[];\n subscribe(fn: (state: RouterState) => void): () => void;\n}\n\n/**\n * To use with React Router 6.4 data APIs.\n */\nexport function withFaroRouterInstrumentation<R extends Router = Router>(router: R) {\n let lastRoute: EventRouteTransitionAttributes = {};\n\n router.subscribe((state) => {\n const navigationType: NavigationType = state.historyAction;\n const location = state.location;\n const routes = router.routes;\n\n if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {\n const route = getRouteFromLocation(routes, location);\n const url = globalObject.location?.href;\n\n api.pushEvent(EVENT_ROUTE_CHANGE, {\n toRoute: route,\n toUrl: globalObject.location?.href,\n ...lastRoute,\n });\n\n lastRoute = {\n fromRoute: route,\n fromUrl: url,\n };\n }\n });\n\n return router;\n}\n"]}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { ReactRouterLocation } from '../types';
|
|
3
|
+
interface IndexRouteObjectV6DataRouter {
|
|
4
|
+
caseSensitive?: boolean;
|
|
5
|
+
children?: undefined;
|
|
6
|
+
element?: React.ReactNode | null;
|
|
7
|
+
index: true;
|
|
8
|
+
path?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NonIndexRouteObjectV6DataRouter {
|
|
11
|
+
caseSensitive?: boolean;
|
|
12
|
+
children?: RouteObjectV6DataRouter[];
|
|
13
|
+
element?: React.ReactNode | null;
|
|
14
|
+
index?: false;
|
|
15
|
+
path?: string;
|
|
16
|
+
}
|
|
17
|
+
export type RouteObjectV6DataRouter = IndexRouteObjectV6DataRouter | NonIndexRouteObjectV6DataRouter;
|
|
3
18
|
export interface ReactRouterV6BaseRouteObject {
|
|
4
19
|
action?: (...args: any[]) => any;
|
|
5
20
|
caseSensitive?: boolean;
|
|
@@ -50,3 +65,4 @@ export type EventRouteTransitionAttributes = {
|
|
|
50
65
|
fromRoute?: string;
|
|
51
66
|
fromUrl?: string;
|
|
52
67
|
};
|
|
68
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NavigationType, ReactRouterLocation } from '../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RouteObjectV6DataRouter } from './types';
|
|
3
3
|
interface RouterState {
|
|
4
4
|
historyAction: NavigationType | any;
|
|
5
5
|
location: ReactRouterLocation;
|
|
6
6
|
}
|
|
7
7
|
interface Router {
|
|
8
8
|
state: RouterState;
|
|
9
|
-
routes:
|
|
9
|
+
routes: RouteObjectV6DataRouter[];
|
|
10
10
|
subscribe(fn: (state: RouterState) => void): () => void;
|
|
11
11
|
}
|
|
12
12
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-react",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Faro package that enables easier integration in projects built with React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"quality:circular-deps": "madge --circular ."
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@grafana/faro-web-sdk": "^1.7.
|
|
56
|
-
"@grafana/faro-web-tracing": "^1.7.
|
|
55
|
+
"@grafana/faro-web-sdk": "^1.7.1",
|
|
56
|
+
"@grafana/faro-web-tracing": "^1.7.1",
|
|
57
57
|
"hoist-non-react-statics": "^3.3.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "11fba62c05d570dfdbc0f83fc1a3dbdc3abafecd"
|
|
75
75
|
}
|