@grafana/faro-react 2.2.1 → 2.2.3

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 (96) hide show
  1. package/dist/bundle/faro-react.iife.js +2 -20
  2. package/dist/bundle/types/index.d.ts +1 -1
  3. package/dist/bundle/types/router/index.d.ts +2 -2
  4. package/dist/bundle/types/router/v4v5/FaroRoute.d.ts +2 -1
  5. package/dist/bundle/types/router/{v6 → v6v7}/FaroRoutes.d.ts +2 -1
  6. package/dist/bundle/types/router/{v6 → v6v7}/index.d.ts +2 -2
  7. package/dist/{types/router/v6 → bundle/types/router/v6v7}/initialize.d.ts +3 -1
  8. package/dist/{types/router/v6 → bundle/types/router/v6v7}/routerDependencies.d.ts +1 -0
  9. package/dist/cjs/errorBoundary/FaroErrorBoundary.js +3 -0
  10. package/dist/cjs/errorBoundary/FaroErrorBoundary.js.map +1 -1
  11. package/dist/cjs/errorBoundary/withFaroErrorBoundary.js +3 -2
  12. package/dist/cjs/errorBoundary/withFaroErrorBoundary.js.map +1 -1
  13. package/dist/cjs/index.js +5 -2
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/profiler/FaroProfiler.js +3 -0
  16. package/dist/cjs/profiler/FaroProfiler.js.map +1 -1
  17. package/dist/cjs/profiler/withFaroProfiler.js +3 -2
  18. package/dist/cjs/profiler/withFaroProfiler.js.map +1 -1
  19. package/dist/cjs/router/index.js +10 -7
  20. package/dist/cjs/router/index.js.map +1 -1
  21. package/dist/cjs/router/initialize.js +3 -3
  22. package/dist/cjs/router/initialize.js.map +1 -1
  23. package/dist/cjs/router/v4v5/FaroRoute.js +5 -2
  24. package/dist/cjs/router/v4v5/FaroRoute.js.map +1 -1
  25. package/dist/cjs/router/{v6 → v6v7}/FaroRoutes.js +35 -3
  26. package/dist/cjs/router/v6v7/FaroRoutes.js.map +1 -0
  27. package/dist/cjs/router/{v6 → v6v7}/index.js +4 -1
  28. package/dist/cjs/router/v6v7/index.js.map +1 -0
  29. package/dist/cjs/router/{v6 → v6v7}/initialize.js +14 -0
  30. package/dist/cjs/router/v6v7/initialize.js.map +1 -0
  31. package/dist/cjs/router/{v6 → v6v7}/routerDependencies.js +4 -0
  32. package/dist/cjs/router/v6v7/routerDependencies.js.map +1 -0
  33. package/dist/cjs/router/v6v7/types.js.map +1 -0
  34. package/dist/cjs/router/v6v7/utils.js.map +1 -0
  35. package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js.map +1 -0
  36. package/dist/esm/errorBoundary/FaroErrorBoundary.js +4 -1
  37. package/dist/esm/errorBoundary/FaroErrorBoundary.js.map +1 -1
  38. package/dist/esm/errorBoundary/withFaroErrorBoundary.js +3 -2
  39. package/dist/esm/errorBoundary/withFaroErrorBoundary.js.map +1 -1
  40. package/dist/esm/index.js +1 -1
  41. package/dist/esm/index.js.map +1 -1
  42. package/dist/esm/profiler/FaroProfiler.js +4 -1
  43. package/dist/esm/profiler/FaroProfiler.js.map +1 -1
  44. package/dist/esm/profiler/withFaroProfiler.js +3 -2
  45. package/dist/esm/profiler/withFaroProfiler.js.map +1 -1
  46. package/dist/esm/router/index.js +1 -1
  47. package/dist/esm/router/index.js.map +1 -1
  48. package/dist/esm/router/initialize.js +1 -1
  49. package/dist/esm/router/initialize.js.map +1 -1
  50. package/dist/esm/router/v4v5/FaroRoute.js +2 -2
  51. package/dist/esm/router/v4v5/FaroRoute.js.map +1 -1
  52. package/dist/esm/router/{v6 → v6v7}/FaroRoutes.js +2 -3
  53. package/dist/esm/router/v6v7/FaroRoutes.js.map +1 -0
  54. package/dist/esm/router/{v6 → v6v7}/index.js +2 -2
  55. package/dist/esm/router/v6v7/index.js.map +1 -0
  56. package/dist/esm/router/{v6 → v6v7}/initialize.js +12 -0
  57. package/dist/esm/router/v6v7/initialize.js.map +1 -0
  58. package/dist/esm/router/{v6 → v6v7}/routerDependencies.js +3 -0
  59. package/dist/esm/router/v6v7/routerDependencies.js.map +1 -0
  60. package/dist/esm/router/v6v7/types.js.map +1 -0
  61. package/dist/esm/router/v6v7/utils.js.map +1 -0
  62. package/dist/esm/router/v6v7/withFaroRouterInstrumentation.js.map +1 -0
  63. package/dist/types/index.d.ts +1 -1
  64. package/dist/types/router/index.d.ts +2 -2
  65. package/dist/types/router/v4v5/FaroRoute.d.ts +2 -1
  66. package/dist/types/router/{v6 → v6v7}/FaroRoutes.d.ts +2 -1
  67. package/dist/types/router/{v6 → v6v7}/index.d.ts +2 -2
  68. package/dist/{bundle/types/router/v6 → types/router/v6v7}/initialize.d.ts +3 -1
  69. package/dist/{bundle/types/router/v6 → types/router/v6v7}/routerDependencies.d.ts +1 -0
  70. package/package.json +9 -9
  71. package/dist/cjs/router/v6/FaroRoutes.js.map +0 -1
  72. package/dist/cjs/router/v6/index.js.map +0 -1
  73. package/dist/cjs/router/v6/initialize.js.map +0 -1
  74. package/dist/cjs/router/v6/routerDependencies.js.map +0 -1
  75. package/dist/cjs/router/v6/types.js.map +0 -1
  76. package/dist/cjs/router/v6/utils.js.map +0 -1
  77. package/dist/cjs/router/v6/withFaroRouterInstrumentation.js.map +0 -1
  78. package/dist/esm/router/v6/FaroRoutes.js.map +0 -1
  79. package/dist/esm/router/v6/index.js.map +0 -1
  80. package/dist/esm/router/v6/initialize.js.map +0 -1
  81. package/dist/esm/router/v6/routerDependencies.js.map +0 -1
  82. package/dist/esm/router/v6/types.js.map +0 -1
  83. package/dist/esm/router/v6/utils.js.map +0 -1
  84. package/dist/esm/router/v6/withFaroRouterInstrumentation.js.map +0 -1
  85. /package/dist/bundle/types/router/{v6 → v6v7}/types.d.ts +0 -0
  86. /package/dist/bundle/types/router/{v6 → v6v7}/utils.d.ts +0 -0
  87. /package/dist/bundle/types/router/{v6 → v6v7}/withFaroRouterInstrumentation.d.ts +0 -0
  88. /package/dist/cjs/router/{v6 → v6v7}/types.js +0 -0
  89. /package/dist/cjs/router/{v6 → v6v7}/utils.js +0 -0
  90. /package/dist/cjs/router/{v6 → v6v7}/withFaroRouterInstrumentation.js +0 -0
  91. /package/dist/esm/router/{v6 → v6v7}/types.js +0 -0
  92. /package/dist/esm/router/{v6 → v6v7}/utils.js +0 -0
  93. /package/dist/esm/router/{v6 → v6v7}/withFaroRouterInstrumentation.js +0 -0
  94. /package/dist/types/router/{v6 → v6v7}/types.d.ts +0 -0
  95. /package/dist/types/router/{v6 → v6v7}/utils.d.ts +0 -0
  96. /package/dist/types/router/{v6 → v6v7}/withFaroRouterInstrumentation.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerDependencies.js","sourceRoot":"","sources":["../../../../src/router/v6v7/routerDependencies.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,IAAI,aAAa,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,IAAI,wBAA+D,CAAC;AAC3E,MAAM,CAAC,IAAI,WAAqC,CAAC;AACjD,MAAM,CAAC,IAAI,MAAgC,CAAC;AAC5C,MAAM,CAAC,IAAI,WAAqC,CAAC;AACjD,MAAM,CAAC,IAAI,iBAAiD,CAAC;AAE7D,MAAM,UAAU,4BAA4B,CAAC,eAA0C;IACrF,aAAa,GAAG,IAAI,CAAC;IAErB,wBAAwB,GAAG,eAAe,CAAC,wBAAwB,CAAC;IACpE,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAChC,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,eAA0D;IACxG,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,sCAAsC,CAAC,eAAoD;IACzG,aAAa,GAAG,IAAI,CAAC;IACrB,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,eAA0D;IACxG,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;AAClC,CAAC","sourcesContent":["import type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6DataRouterDependencies,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n\nexport let isInitialized = false;\nexport let createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\nexport let matchRoutes: ReactRouterV6MatchRoutes;\nexport let Routes: ReactRouterV6RoutesShape;\nexport let useLocation: ReactRouterV6UseLocation;\nexport let useNavigationType: ReactRouterV6UseNavigationType;\n\nexport function setReactRouterV6Dependencies(newDependencies: ReactRouterV6Dependencies): void {\n isInitialized = true;\n\n createRoutesFromChildren = newDependencies.createRoutesFromChildren;\n matchRoutes = newDependencies.matchRoutes;\n Routes = newDependencies.Routes;\n useLocation = newDependencies.useLocation;\n useNavigationType = newDependencies.useNavigationType;\n}\n\nexport function setReactRouterV6SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void {\n Routes = newDependencies.Routes;\n}\n\nexport function setReactRouterV6DataRouterDependencies(newDependencies: ReactRouterV6DataRouterDependencies): void {\n isInitialized = true;\n matchRoutes = newDependencies.matchRoutes;\n}\n\nexport function setReactRouterV7SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void {\n Routes = newDependencies.Routes;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6v7/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport type React 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 = (\n children: ReactNode\n) => ReactRouterV6RouteObject[] | RouteObjectV6DataRouter[];\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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6v7/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;AACnH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAkC,EAAE,QAA6B;IACpG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAE,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAE3B,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;oBAChB,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACzB,CAAC;gBAED,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAEtB,IAAI,IAAI,EAAE,CAAC;oBACT,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;oBAEhD,WAAW,IAAI,IAAI,CAAC;oBAEpB,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;wBAC1C,IAAI,sBAAsB,CAAC,WAAW,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;4BACpF,OAAO,IAAI,CAAC;wBACd,CAAC;wBAED,OAAO,WAAW,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["import type { ReactRouterLocation } from '../types';\n\nimport { matchRoutes } from './routerDependencies';\nimport type { ReactRouterV6RouteObject } from './types';\n\nexport function getNumberOfUrlSegments(url: string): number {\n return url.split(/\\\\?\\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;\n}\n\nexport function getRouteFromLocation(routes: ReactRouterV6RouteObject[], location: ReactRouterLocation): string {\n if (!routes || routes.length === 0) {\n return location.pathname;\n }\n\n const matchedRoutes = matchRoutes(routes, location);\n\n let pathBuilder = '';\n\n if (matchedRoutes) {\n for (let x = 0; x < matchedRoutes.length; x++) {\n const branch = matchedRoutes[x]!;\n const route = branch.route;\n\n if (route) {\n if (route.index) {\n return branch.pathname;\n }\n\n let path = route.path;\n\n if (path) {\n path = path.startsWith('/') ? path : `/${path}`;\n\n pathBuilder += path;\n\n if (branch.pathname === location.pathname) {\n if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) {\n return path;\n }\n\n return pathBuilder;\n }\n }\n }\n }\n }\n\n return location.pathname;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6v7/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,EAAE,MAAM,UAAU,CAAC;AAG1C,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,CAAC;YACvG,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;QACJ,CAAC;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 } from '../types';\nimport type { 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"]}
@@ -3,7 +3,7 @@ export type { FaroErrorBoundaryFallbackRender, FaroErrorBoundaryProps, FaroError
3
3
  export { ReactIntegration } from './instrumentation';
4
4
  export { FaroProfiler, withFaroProfiler } from './profiler';
5
5
  export type { FaroProfilerProps } from './profiler';
6
- export { FaroRoute, FaroRoutes, NavigationType, ReactRouterVersion, createReactRouterV4Options, createReactRouterV5Options, createReactRouterV6Options, createReactRouterV6DataOptions, setReactRouterV4V5SSRDependencies, setReactRouterV6SSRDependencies, withFaroRouterInstrumentation, } from './router';
6
+ export { FaroRoute, FaroRoutes, NavigationType, ReactRouterVersion, createReactRouterV4Options, createReactRouterV5Options, createReactRouterV6Options, createReactRouterV6DataOptions, createReactRouterV7Options, createReactRouterV7DataOptions, setReactRouterV4V5SSRDependencies, setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies, withFaroRouterInstrumentation, } from './router';
7
7
  export type { ReactRouterHistory, ReactRouterLocation, ReactRouterV4V5ActiveEvent, ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape, ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6Params, ReactRouterV6RouteMatch, ReactRouterV6RouteObject, ReactRouterV6RoutesProps, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType, } from './router';
8
8
  export type { ReactIntegrationConfig, ReactRouterV4V5Config, ReactRouterV6Config, ReactRouterV7Config, ReactRouterV7DataRouterConfig, } from './types';
9
9
  export { getMajorReactVersion, isReactVersionAtLeast, isReactVersionAtLeast16, isReactVersionAtLeast17, isReactVersionAtLeast18, isReactVersionAtLeast19, reactVersion, reactVersionMajor, } from './utils';
@@ -3,5 +3,5 @@ export { NavigationType, ReactRouterVersion } from './types';
3
3
  export type { ReactRouterLocation, ReactRouterHistory } from './types';
4
4
  export { FaroRoute, createReactRouterV4Options, createReactRouterV5Options, setReactRouterV4V5SSRDependencies, } from './v4v5';
5
5
  export type { ReactRouterV4V5ActiveEvent, ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './v4v5';
6
- export { FaroRoutes, createReactRouterV6Options, createReactRouterV6DataOptions, setReactRouterV6SSRDependencies, withFaroRouterInstrumentation, } from './v6';
7
- export type { ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6Params, ReactRouterV6RouteMatch, ReactRouterV6RouteObject, ReactRouterV6RoutesProps, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType, ReactRouterV6DataRouterDependencies, } from './v6';
6
+ export { FaroRoutes, createReactRouterV6Options, createReactRouterV6DataOptions, setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies, withFaroRouterInstrumentation, createReactRouterV7Options, createReactRouterV7DataOptions, } from './v6v7';
7
+ export type { ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6Params, ReactRouterV6RouteMatch, ReactRouterV6RouteObject, ReactRouterV6RoutesProps, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType, ReactRouterV6DataRouterDependencies, } from './v6v7';
@@ -1,2 +1,3 @@
1
+ import React from 'react';
1
2
  import type { ReactRouterV4V5RouteProps } from './types';
2
- export declare function FaroRoute(props: ReactRouterV4V5RouteProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function FaroRoute(props: ReactRouterV4V5RouteProps): React.JSX.Element;
@@ -1,2 +1,3 @@
1
+ import React from 'react';
1
2
  import type { ReactRouterV6RoutesProps } from './types';
2
- export declare function FaroRoutes(props: ReactRouterV6RoutesProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function FaroRoutes(props: ReactRouterV6RoutesProps): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  export { FaroRoutes } from './FaroRoutes';
2
- export { createReactRouterV6Options, createReactRouterV6DataOptions, initializeReactRouterV6Instrumentation, initializeReactRouterV6DataRouterInstrumentation, } from './initialize';
3
- export { setReactRouterV6SSRDependencies } from './routerDependencies';
2
+ export { createReactRouterV6Options, createReactRouterV6DataOptions, initializeReactRouterV6Instrumentation, initializeReactRouterV6DataRouterInstrumentation, createReactRouterV7DataOptions, createReactRouterV7Options, } from './initialize';
3
+ export { setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies } from './routerDependencies';
4
4
  export { withFaroRouterInstrumentation } from './withFaroRouterInstrumentation';
5
5
  export type { ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6Params, ReactRouterV6RouteMatch, ReactRouterV6RouteObject, ReactRouterV6RoutesProps, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType, ReactRouterV6DataRouterDependencies, } from './types';
@@ -1,6 +1,8 @@
1
- import type { ReactRouterV6Config, ReactRouterV6DataRouterConfig } from '../../types';
1
+ import type { ReactRouterV6Config, ReactRouterV6DataRouterConfig, ReactRouterV7Config, ReactRouterV7DataRouterConfig } from '../../types';
2
2
  import type { ReactRouterV6DataRouterDependencies, ReactRouterV6Dependencies } from './types';
3
3
  export declare function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies): void;
4
4
  export declare function createReactRouterV6Options(dependencies: ReactRouterV6Dependencies): ReactRouterV6Config;
5
5
  export declare function initializeReactRouterV6DataRouterInstrumentation(dependencies: ReactRouterV6DataRouterDependencies): void;
6
6
  export declare function createReactRouterV6DataOptions(dependencies: ReactRouterV6DataRouterDependencies): ReactRouterV6DataRouterConfig;
7
+ export declare function createReactRouterV7Options(dependencies: ReactRouterV6Dependencies): ReactRouterV7Config;
8
+ export declare function createReactRouterV7DataOptions(dependencies: ReactRouterV6DataRouterDependencies): ReactRouterV7DataRouterConfig;
@@ -8,3 +8,4 @@ export declare let useNavigationType: ReactRouterV6UseNavigationType;
8
8
  export declare function setReactRouterV6Dependencies(newDependencies: ReactRouterV6Dependencies): void;
9
9
  export declare function setReactRouterV6SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void;
10
10
  export declare function setReactRouterV6DataRouterDependencies(newDependencies: ReactRouterV6DataRouterDependencies): void;
11
+ export declare function setReactRouterV7SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-react",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "Faro package that enables easier integration in projects built with React.",
5
5
  "keywords": [
6
6
  "observability",
@@ -43,7 +43,7 @@
43
43
  "watch:compile": "yarn build:compile:cjs -w",
44
44
  "clean": "rimraf dist/ yarn-error.log",
45
45
  "quality": "run-s 'quality:*'",
46
- "quality:test": "exit 0",
46
+ "quality:test": "jest --passWithNoTests",
47
47
  "quality:format": "prettier --cache --cache-location=../../.cache/prettier/react --ignore-path ../../.prettierignore -w \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
48
48
  "quality:lint": "run-s 'quality:lint:*'",
49
49
  "quality:lint:eslint": "eslint --cache --cache-location ../../.cache/eslint/react \"./**/*.{js,jsx,ts,tsx}\"",
@@ -52,16 +52,16 @@
52
52
  "quality:circular-deps": "madge --circular ."
53
53
  },
54
54
  "dependencies": {
55
- "@grafana/faro-web-sdk": "^2.2.1",
56
- "@grafana/faro-web-tracing": "^2.2.1",
55
+ "@grafana/faro-web-sdk": "^2.2.3",
56
+ "@grafana/faro-web-tracing": "^2.2.3",
57
57
  "hoist-non-react-statics": "^3.3.2"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/hoist-non-react-statics": "3.3.7",
61
- "@types/react": "19.2.9",
62
- "react": "19.2.3",
63
- "react-dom": "19.2.3",
64
- "react-router": "7.12.0"
61
+ "@types/react": "19.2.13",
62
+ "react": "19.2.4",
63
+ "react-dom": "19.2.4",
64
+ "react-router": "7.13.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "aa59f4ec236bb7c8df4526d56d7c6bc013c5ad6e"
86
+ "gitHead": "27cb5bebe06077a050cfba9ea07c7c2f0bcdc455"
87
87
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"FaroRoutes.js","sourceRoot":"","sources":["../../../../src/router/v6/FaroRoutes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAWA,gCA6BC;;AAxCD,+BAAmD;AAEnD,sDAAyE;AAEzE,mDAAyC;AACzC,kCAA0C;AAE1C,2DAAuH;AAEvH,iCAA+C;AAE/C,SAAgB,UAAU,CAAC,KAA+B;;IACxD,IAAM,QAAQ,GAAG,gCAAW,aAAX,gCAAW,2BAAX,gCAAW,GAAI,CAAC;IACjC,IAAM,cAAc,GAAG,sCAAiB,aAAjB,sCAAiB,2BAAjB,sCAAiB,GAAI,CAAC;IAE7C,IAAM,MAAM,GAAG,IAAA,eAAO,EAAC,sBAAM,OAAA,MAAA,6CAAwB,aAAxB,6CAAwB,2BAAxB,6CAAwB,EAAG,KAAK,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAA,EAAA,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEjG,IAAM,YAAY,GAAG,IAAA,cAAM,EAAiC,EAAE,CAAC,CAAC;IAEhE,IAAA,iBAAS,EAAC;;QACR,IAAI,kCAAa,IAAI,CAAC,cAAc,KAAK,sBAAc,CAAC,IAAI,IAAI,cAAc,KAAK,sBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACvG,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,YAAY,CAAC,OAAO,EACvB,CAAC;YAEH,YAAY,CAAC,OAAO,GAAG;gBACrB,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvC,IAAM,YAAY,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,2BAAM,CAAC;IAErD,OAAO,uBAAC,YAAY,eAAK,KAAK,EAAI,CAAC;AACrC,CAAC","sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\n\nimport { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType } from '../types';\n\nimport { createRoutesFromChildren, isInitialized, Routes, useLocation, useNavigationType } from './routerDependencies';\nimport type { EventRouteTransitionAttributes, ReactRouterV6RoutesProps } from './types';\nimport { getRouteFromLocation } from './utils';\n\nexport function FaroRoutes(props: ReactRouterV6RoutesProps) {\n const location = useLocation?.();\n const navigationType = useNavigationType?.();\n\n const routes = useMemo(() => createRoutesFromChildren?.(props.children) ?? [], [props.children]);\n\n const lastRouteRef = useRef<EventRouteTransitionAttributes>({});\n\n useEffect(() => {\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 ...lastRouteRef.current,\n });\n\n lastRouteRef.current = {\n fromRoute: route,\n fromUrl: url,\n };\n }\n }, [location, navigationType, routes]);\n\n const ActualRoutes = props.routesComponent ?? Routes;\n\n return <ActualRoutes {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/router/v6/index.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,2CAKsB;AAJpB,wHAAA,0BAA0B,OAAA;AAC1B,4HAAA,8BAA8B,OAAA;AAC9B,oIAAA,sCAAsC,OAAA;AACtC,8IAAA,gDAAgD,OAAA;AAGlD,2DAAuE;AAA9D,qIAAA,+BAA+B,OAAA;AAExC,iFAAgF;AAAvE,8IAAA,6BAA6B,OAAA","sourcesContent":["export { FaroRoutes } from './FaroRoutes';\n\nexport {\n createReactRouterV6Options,\n createReactRouterV6DataOptions,\n initializeReactRouterV6Instrumentation,\n initializeReactRouterV6DataRouterInstrumentation,\n} from './initialize';\n\nexport { setReactRouterV6SSRDependencies } from './routerDependencies';\n\nexport { withFaroRouterInstrumentation } from './withFaroRouterInstrumentation';\n\nexport type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6Params,\n ReactRouterV6RouteMatch,\n ReactRouterV6RouteObject,\n ReactRouterV6RoutesProps,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n ReactRouterV6DataRouterDependencies,\n} from './types';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6/initialize.ts"],"names":[],"mappings":";;;;;AAYA,wFAGC;AAED,gEAKC;AAED,4GAIC;AAED,wEAOC;AArCD,oFAA2D;AAG3D,kCAA8C;AAE9C,2CAA0C;AAC1C,2DAG8B;AAG9B,SAAgB,sCAAsC,CAAC,YAAuC;IAC5F,IAAA,iCAAoB,EAAC,uBAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAA,iDAA4B,EAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAuC;IAChF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY,cAAA;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,gDAAgD,CAC9D,YAAiD;IAEjD,IAAA,2DAAsC,EAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,8BAA8B,CAC5C,YAAiD;IAEjD,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,cAAc;QAC1C,YAAY,cAAA;KACb,CAAC;AACJ,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport type { ReactRouterV6Config, ReactRouterV6DataRouterConfig } from '../../types';\nimport { ReactRouterVersion } from '../types';\n\nimport { FaroRoutes } from './FaroRoutes';\nimport {\n setReactRouterV6DataRouterDependencies as setReactRouterV6DataRouterDependencies,\n setReactRouterV6Dependencies,\n} from './routerDependencies';\nimport type { ReactRouterV6DataRouterDependencies, ReactRouterV6Dependencies } from './types';\n\nexport function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies): void {\n hoistNonReactStatics(FaroRoutes, dependencies.Routes);\n setReactRouterV6Dependencies(dependencies);\n}\n\nexport function createReactRouterV6Options(dependencies: ReactRouterV6Dependencies): ReactRouterV6Config {\n return {\n version: ReactRouterVersion.V6,\n dependencies,\n };\n}\n\nexport function initializeReactRouterV6DataRouterInstrumentation(\n dependencies: ReactRouterV6DataRouterDependencies\n): void {\n setReactRouterV6DataRouterDependencies(dependencies);\n}\n\nexport function createReactRouterV6DataOptions(\n dependencies: ReactRouterV6DataRouterDependencies\n): ReactRouterV6DataRouterConfig {\n return {\n version: ReactRouterVersion.V6_data_router,\n dependencies,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"routerDependencies.js","sourceRoot":"","sources":["../../../../src/router/v6/routerDependencies.ts"],"names":[],"mappings":";;;AAiBA,oEAQC;AAED,0EAEC;AAED,wFAGC;AAxBU,QAAA,aAAa,GAAG,KAAK,CAAC;AAOjC,SAAgB,4BAA4B,CAAC,eAA0C;IACrF,qBAAa,GAAG,IAAI,CAAC;IAErB,gCAAwB,GAAG,eAAe,CAAC,wBAAwB,CAAC;IACpE,mBAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,cAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAChC,mBAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,yBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;AACxD,CAAC;AAED,SAAgB,+BAA+B,CAAC,eAA0D;IACxG,cAAM,GAAG,eAAe,CAAC,MAAM,CAAC;AAClC,CAAC;AAED,SAAgB,sCAAsC,CAAC,eAAoD;IACzG,qBAAa,GAAG,IAAI,CAAC;IACrB,mBAAW,GAAG,eAAe,CAAC,WAAW,CAAC;AAC5C,CAAC","sourcesContent":["import type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6DataRouterDependencies,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n\nexport let isInitialized = false;\nexport let createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\nexport let matchRoutes: ReactRouterV6MatchRoutes;\nexport let Routes: ReactRouterV6RoutesShape;\nexport let useLocation: ReactRouterV6UseLocation;\nexport let useNavigationType: ReactRouterV6UseNavigationType;\n\nexport function setReactRouterV6Dependencies(newDependencies: ReactRouterV6Dependencies): void {\n isInitialized = true;\n\n createRoutesFromChildren = newDependencies.createRoutesFromChildren;\n matchRoutes = newDependencies.matchRoutes;\n Routes = newDependencies.Routes;\n useLocation = newDependencies.useLocation;\n useNavigationType = newDependencies.useNavigationType;\n}\n\nexport function setReactRouterV6SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void {\n Routes = newDependencies.Routes;\n}\n\nexport function setReactRouterV6DataRouterDependencies(newDependencies: ReactRouterV6DataRouterDependencies): void {\n isInitialized = true;\n matchRoutes = newDependencies.matchRoutes;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport type React 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 = (\n children: ReactNode\n) => ReactRouterV6RouteObject[] | RouteObjectV6DataRouter[];\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 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6/utils.ts"],"names":[],"mappings":";;AAKA,wDAEC;AAED,oDAuCC;AA9CD,2DAAmD;AAGnD,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAC,cAAc,IAAK,OAAA,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,KAAK,GAAG,EAAnD,CAAmD,CAAC,CAAC,MAAM,CAAC;AACnH,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAkC,EAAE,QAA6B;IACpG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAM,aAAa,GAAG,IAAA,gCAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,IAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAE,CAAC;YACjC,IAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAE3B,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;oBAChB,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACzB,CAAC;gBAED,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAEtB,IAAI,IAAI,EAAE,CAAC;oBACT,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAI,IAAI,CAAE,CAAC;oBAEhD,WAAW,IAAI,IAAI,CAAC;oBAEpB,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;wBAC1C,IAAI,sBAAsB,CAAC,WAAW,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;4BACpF,OAAO,IAAI,CAAC;wBACd,CAAC;wBAED,OAAO,WAAW,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["import type { ReactRouterLocation } from '../types';\n\nimport { matchRoutes } from './routerDependencies';\nimport type { ReactRouterV6RouteObject } from './types';\n\nexport function getNumberOfUrlSegments(url: string): number {\n return url.split(/\\\\?\\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;\n}\n\nexport function getRouteFromLocation(routes: ReactRouterV6RouteObject[], location: ReactRouterLocation): string {\n if (!routes || routes.length === 0) {\n return location.pathname;\n }\n\n const matchedRoutes = matchRoutes(routes, location);\n\n let pathBuilder = '';\n\n if (matchedRoutes) {\n for (let x = 0; x < matchedRoutes.length; x++) {\n const branch = matchedRoutes[x]!;\n const route = branch.route;\n\n if (route) {\n if (route.index) {\n return branch.pathname;\n }\n\n let path = route.path;\n\n if (path) {\n path = path.startsWith('/') ? path : `/${path}`;\n\n pathBuilder += path;\n\n if (branch.pathname === location.pathname) {\n if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) {\n return path;\n }\n\n return pathBuilder;\n }\n }\n }\n }\n }\n\n return location.pathname;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6/withFaroRouterInstrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAwBA,sEA0BC;AAlDD,sDAAyE;AAEzE,mDAAyC;AACzC,kCAA0C;AAG1C,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,CAAC;YACvG,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;QACJ,CAAC;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 } from '../types';\nimport type { 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 +0,0 @@
1
- {"version":3,"file":"FaroRoutes.js","sourceRoot":"","sources":["../../../../src/router/v6/FaroRoutes.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEvH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAC,KAA+B;;IACxD,MAAM,QAAQ,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;IACjC,MAAM,cAAc,GAAG,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,EAAI,CAAC;IAE7C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,WAAC,OAAA,MAAA,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,KAAK,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAA,EAAA,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEjG,MAAM,YAAY,GAAG,MAAM,CAAiC,EAAE,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,aAAa,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,IAAI,IAAI,cAAc,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACvG,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,YAAY,CAAC,OAAO,EACvB,CAAC;YAEH,YAAY,CAAC,OAAO,GAAG;gBACrB,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,GAAG;aACb,CAAC;QACJ,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvC,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,MAAM,CAAC;IAErD,OAAO,KAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;AACrC,CAAC","sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\n\nimport { EVENT_ROUTE_CHANGE, globalObject } from '@grafana/faro-web-sdk';\n\nimport { api } from '../../dependencies';\nimport { NavigationType } from '../types';\n\nimport { createRoutesFromChildren, isInitialized, Routes, useLocation, useNavigationType } from './routerDependencies';\nimport type { EventRouteTransitionAttributes, ReactRouterV6RoutesProps } from './types';\nimport { getRouteFromLocation } from './utils';\n\nexport function FaroRoutes(props: ReactRouterV6RoutesProps) {\n const location = useLocation?.();\n const navigationType = useNavigationType?.();\n\n const routes = useMemo(() => createRoutesFromChildren?.(props.children) ?? [], [props.children]);\n\n const lastRouteRef = useRef<EventRouteTransitionAttributes>({});\n\n useEffect(() => {\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 ...lastRouteRef.current,\n });\n\n lastRouteRef.current = {\n fromRoute: route,\n fromUrl: url,\n };\n }\n }, [location, navigationType, routes]);\n\n const ActualRoutes = props.routesComponent ?? Routes;\n\n return <ActualRoutes {...props} />;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/router/v6/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,sCAAsC,EACtC,gDAAgD,GACjD,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["export { FaroRoutes } from './FaroRoutes';\n\nexport {\n createReactRouterV6Options,\n createReactRouterV6DataOptions,\n initializeReactRouterV6Instrumentation,\n initializeReactRouterV6DataRouterInstrumentation,\n} from './initialize';\n\nexport { setReactRouterV6SSRDependencies } from './routerDependencies';\n\nexport { withFaroRouterInstrumentation } from './withFaroRouterInstrumentation';\n\nexport type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6Params,\n ReactRouterV6RouteMatch,\n ReactRouterV6RouteObject,\n ReactRouterV6RoutesProps,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n ReactRouterV6DataRouterDependencies,\n} from './types';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,sCAAsC,IAAI,sCAAsC,EAChF,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,UAAU,sCAAsC,CAAC,YAAuC;IAC5F,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,4BAA4B,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,YAAuC;IAChF,OAAO;QACL,OAAO,EAAE,kBAAkB,CAAC,EAAE;QAC9B,YAAY;KACb,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gDAAgD,CAC9D,YAAiD;IAEjD,sCAAsC,CAAC,YAAY,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,YAAiD;IAEjD,OAAO;QACL,OAAO,EAAE,kBAAkB,CAAC,cAAc;QAC1C,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport type { ReactRouterV6Config, ReactRouterV6DataRouterConfig } from '../../types';\nimport { ReactRouterVersion } from '../types';\n\nimport { FaroRoutes } from './FaroRoutes';\nimport {\n setReactRouterV6DataRouterDependencies as setReactRouterV6DataRouterDependencies,\n setReactRouterV6Dependencies,\n} from './routerDependencies';\nimport type { ReactRouterV6DataRouterDependencies, ReactRouterV6Dependencies } from './types';\n\nexport function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies): void {\n hoistNonReactStatics(FaroRoutes, dependencies.Routes);\n setReactRouterV6Dependencies(dependencies);\n}\n\nexport function createReactRouterV6Options(dependencies: ReactRouterV6Dependencies): ReactRouterV6Config {\n return {\n version: ReactRouterVersion.V6,\n dependencies,\n };\n}\n\nexport function initializeReactRouterV6DataRouterInstrumentation(\n dependencies: ReactRouterV6DataRouterDependencies\n): void {\n setReactRouterV6DataRouterDependencies(dependencies);\n}\n\nexport function createReactRouterV6DataOptions(\n dependencies: ReactRouterV6DataRouterDependencies\n): ReactRouterV6DataRouterConfig {\n return {\n version: ReactRouterVersion.V6_data_router,\n dependencies,\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"routerDependencies.js","sourceRoot":"","sources":["../../../../src/router/v6/routerDependencies.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,IAAI,aAAa,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,IAAI,wBAA+D,CAAC;AAC3E,MAAM,CAAC,IAAI,WAAqC,CAAC;AACjD,MAAM,CAAC,IAAI,MAAgC,CAAC;AAC5C,MAAM,CAAC,IAAI,WAAqC,CAAC;AACjD,MAAM,CAAC,IAAI,iBAAiD,CAAC;AAE7D,MAAM,UAAU,4BAA4B,CAAC,eAA0C;IACrF,aAAa,GAAG,IAAI,CAAC;IAErB,wBAAwB,GAAG,eAAe,CAAC,wBAAwB,CAAC;IACpE,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAChC,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAC1C,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,eAA0D;IACxG,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,sCAAsC,CAAC,eAAoD;IACzG,aAAa,GAAG,IAAI,CAAC;IACrB,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;AAC5C,CAAC","sourcesContent":["import type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6DataRouterDependencies,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n\nexport let isInitialized = false;\nexport let createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\nexport let matchRoutes: ReactRouterV6MatchRoutes;\nexport let Routes: ReactRouterV6RoutesShape;\nexport let useLocation: ReactRouterV6UseLocation;\nexport let useNavigationType: ReactRouterV6UseNavigationType;\n\nexport function setReactRouterV6Dependencies(newDependencies: ReactRouterV6Dependencies): void {\n isInitialized = true;\n\n createRoutesFromChildren = newDependencies.createRoutesFromChildren;\n matchRoutes = newDependencies.matchRoutes;\n Routes = newDependencies.Routes;\n useLocation = newDependencies.useLocation;\n useNavigationType = newDependencies.useNavigationType;\n}\n\nexport function setReactRouterV6SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void {\n Routes = newDependencies.Routes;\n}\n\nexport function setReactRouterV6DataRouterDependencies(newDependencies: ReactRouterV6DataRouterDependencies): void {\n isInitialized = true;\n matchRoutes = newDependencies.matchRoutes;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v6/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport type React 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 = (\n children: ReactNode\n) => ReactRouterV6RouteObject[] | RouteObjectV6DataRouter[];\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 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;AACnH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAkC,EAAE,QAA6B;IACpG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAE,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAE3B,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;oBAChB,OAAO,MAAM,CAAC,QAAQ,CAAC;gBACzB,CAAC;gBAED,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAEtB,IAAI,IAAI,EAAE,CAAC;oBACT,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;oBAEhD,WAAW,IAAI,IAAI,CAAC;oBAEpB,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;wBAC1C,IAAI,sBAAsB,CAAC,WAAW,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;4BACpF,OAAO,IAAI,CAAC;wBACd,CAAC;wBAED,OAAO,WAAW,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["import type { ReactRouterLocation } from '../types';\n\nimport { matchRoutes } from './routerDependencies';\nimport type { ReactRouterV6RouteObject } from './types';\n\nexport function getNumberOfUrlSegments(url: string): number {\n return url.split(/\\\\?\\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;\n}\n\nexport function getRouteFromLocation(routes: ReactRouterV6RouteObject[], location: ReactRouterLocation): string {\n if (!routes || routes.length === 0) {\n return location.pathname;\n }\n\n const matchedRoutes = matchRoutes(routes, location);\n\n let pathBuilder = '';\n\n if (matchedRoutes) {\n for (let x = 0; x < matchedRoutes.length; x++) {\n const branch = matchedRoutes[x]!;\n const route = branch.route;\n\n if (route) {\n if (route.index) {\n return branch.pathname;\n }\n\n let path = route.path;\n\n if (path) {\n path = path.startsWith('/') ? path : `/${path}`;\n\n pathBuilder += path;\n\n if (branch.pathname === location.pathname) {\n if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) {\n return path;\n }\n\n return pathBuilder;\n }\n }\n }\n }\n }\n\n return location.pathname;\n}\n"]}
@@ -1 +0,0 @@
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,EAAE,MAAM,UAAU,CAAC;AAG1C,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,CAAC;YACvG,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;QACJ,CAAC;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 } from '../types';\nimport type { 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"]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes