@grafana/faro-react 1.0.0-beta4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +1 -1
  2. package/dist/bundle/faro-react.iife.js +3 -12
  3. package/dist/cjs/dependencies.js +9 -0
  4. package/dist/cjs/dependencies.js.map +1 -0
  5. package/dist/cjs/errorBoundary/FaroErrorBoundary.js +3 -2
  6. package/dist/cjs/errorBoundary/FaroErrorBoundary.js.map +1 -1
  7. package/dist/cjs/errorBoundary/types.js.map +1 -1
  8. package/dist/cjs/errorBoundary/withFaroErrorBoundary.js.map +1 -1
  9. package/dist/cjs/index.js +5 -2
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/instrumentation.js +6 -4
  12. package/dist/cjs/instrumentation.js.map +1 -1
  13. package/dist/cjs/profiler/FaroProfiler.js +5 -8
  14. package/dist/cjs/profiler/FaroProfiler.js.map +1 -1
  15. package/dist/cjs/profiler/withFaroProfiler.js.map +1 -1
  16. package/dist/cjs/router/initialize.js +8 -7
  17. package/dist/cjs/router/initialize.js.map +1 -1
  18. package/dist/cjs/router/v4v5/FaroRoute.js +2 -2
  19. package/dist/cjs/router/v4v5/FaroRoute.js.map +1 -1
  20. package/dist/cjs/router/v4v5/activeEvent.js +3 -3
  21. package/dist/cjs/router/v4v5/activeEvent.js.map +1 -1
  22. package/dist/cjs/router/v4v5/index.js +3 -3
  23. package/dist/cjs/router/v4v5/index.js.map +1 -1
  24. package/dist/cjs/router/v4v5/initialize.js +3 -3
  25. package/dist/cjs/router/v4v5/initialize.js.map +1 -1
  26. package/dist/cjs/router/v4v5/{dependencies.js → routerDependencies.js} +4 -5
  27. package/dist/cjs/router/v4v5/routerDependencies.js.map +1 -0
  28. package/dist/cjs/router/v4v5/types.js.map +1 -1
  29. package/dist/cjs/router/v6/FaroRoutes.js +9 -8
  30. package/dist/cjs/router/v6/FaroRoutes.js.map +1 -1
  31. package/dist/cjs/router/v6/index.js +3 -3
  32. package/dist/cjs/router/v6/index.js.map +1 -1
  33. package/dist/cjs/router/v6/initialize.js +3 -3
  34. package/dist/cjs/router/v6/initialize.js.map +1 -1
  35. package/dist/cjs/router/v6/{dependencies.js → routerDependencies.js} +4 -5
  36. package/dist/cjs/router/v6/routerDependencies.js.map +1 -0
  37. package/dist/cjs/router/v6/utils.js +2 -2
  38. package/dist/cjs/router/v6/utils.js.map +1 -1
  39. package/dist/esm/dependencies.js +7 -0
  40. package/dist/esm/dependencies.js.map +1 -0
  41. package/dist/esm/errorBoundary/FaroErrorBoundary.js +4 -3
  42. package/dist/esm/errorBoundary/FaroErrorBoundary.js.map +1 -1
  43. package/dist/esm/errorBoundary/types.js.map +1 -1
  44. package/dist/esm/errorBoundary/withFaroErrorBoundary.js.map +1 -1
  45. package/dist/esm/index.js +1 -1
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/instrumentation.js +5 -3
  48. package/dist/esm/instrumentation.js.map +1 -1
  49. package/dist/esm/profiler/FaroProfiler.js +5 -7
  50. package/dist/esm/profiler/FaroProfiler.js.map +1 -1
  51. package/dist/esm/profiler/withFaroProfiler.js.map +1 -1
  52. package/dist/esm/router/initialize.js +8 -7
  53. package/dist/esm/router/initialize.js.map +1 -1
  54. package/dist/esm/router/v4v5/FaroRoute.js +1 -1
  55. package/dist/esm/router/v4v5/FaroRoute.js.map +1 -1
  56. package/dist/esm/router/v4v5/activeEvent.js +3 -3
  57. package/dist/esm/router/v4v5/activeEvent.js.map +1 -1
  58. package/dist/esm/router/v4v5/index.js +1 -1
  59. package/dist/esm/router/v4v5/index.js.map +1 -1
  60. package/dist/esm/router/v4v5/initialize.js +3 -3
  61. package/dist/esm/router/v4v5/initialize.js.map +1 -1
  62. package/dist/esm/router/v4v5/{dependencies.js → routerDependencies.js} +2 -4
  63. package/dist/esm/router/v4v5/routerDependencies.js.map +1 -0
  64. package/dist/esm/router/v4v5/types.js.map +1 -1
  65. package/dist/esm/router/v6/FaroRoutes.js +4 -3
  66. package/dist/esm/router/v6/FaroRoutes.js.map +1 -1
  67. package/dist/esm/router/v6/index.js +1 -1
  68. package/dist/esm/router/v6/index.js.map +1 -1
  69. package/dist/esm/router/v6/initialize.js +3 -3
  70. package/dist/esm/router/v6/initialize.js.map +1 -1
  71. package/dist/esm/router/v6/{dependencies.js → routerDependencies.js} +2 -4
  72. package/dist/esm/router/v6/routerDependencies.js.map +1 -0
  73. package/dist/esm/router/v6/utils.js +1 -1
  74. package/dist/esm/router/v6/utils.js.map +1 -1
  75. package/dist/types/dependencies.d.ts +4 -0
  76. package/dist/types/errorBoundary/types.d.ts +0 -2
  77. package/dist/types/index.d.ts +2 -2
  78. package/dist/types/instrumentation.d.ts +2 -2
  79. package/dist/types/router/initialize.d.ts +1 -2
  80. package/dist/types/router/v4v5/index.d.ts +1 -1
  81. package/dist/types/router/v4v5/initialize.d.ts +1 -2
  82. package/dist/types/router/v4v5/{dependencies.d.ts → routerDependencies.d.ts} +1 -3
  83. package/dist/types/router/v4v5/types.d.ts +1 -1
  84. package/dist/types/router/v6/index.d.ts +1 -1
  85. package/dist/types/router/v6/initialize.d.ts +1 -2
  86. package/dist/types/router/v6/{dependencies.d.ts → routerDependencies.d.ts} +1 -3
  87. package/package.json +5 -5
  88. package/dist/cjs/router/v4v5/dependencies.js.map +0 -1
  89. package/dist/cjs/router/v6/dependencies.js.map +0 -1
  90. package/dist/esm/router/v4v5/dependencies.js.map +0 -1
  91. package/dist/esm/router/v6/dependencies.js.map +0 -1
@@ -1,14 +1,16 @@
1
1
  import { BaseInstrumentation, VERSION } from '@grafana/faro-web-sdk';
2
+ import { setDependencies } from './dependencies';
2
3
  import { initializeReactRouterInstrumentation } from './router';
3
4
  export class ReactIntegration extends BaseInstrumentation {
4
- constructor(config = {}) {
5
+ constructor(options = {}) {
5
6
  super();
6
- this.config = config;
7
+ this.options = options;
7
8
  this.name = '@grafana/faro-react';
8
9
  this.version = VERSION;
9
10
  }
10
11
  initialize() {
11
- initializeReactRouterInstrumentation(this.config, this.faro);
12
+ setDependencies(this.internalLogger, this.api);
13
+ initializeReactRouterInstrumentation(this.options);
12
14
  }
13
15
  }
14
16
  //# sourceMappingURL=instrumentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,oCAAoC,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,OAAO,gBAAiB,SAAQ,mBAAmB;IAIvD,YAAoB,SAAiC,EAAE;QACrD,KAAK,EAAE,CAAC;QADU,WAAM,GAAN,MAAM,CAA6B;QAHvD,SAAI,GAAG,qBAAqB,CAAC;QAC7B,YAAO,GAAG,OAAO,CAAC;IAIlB,CAAC;IAED,UAAU;QACR,oCAAoC,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;CACF","sourcesContent":["import { BaseInstrumentation, VERSION } from '@grafana/faro-web-sdk';\n\nimport { initializeReactRouterInstrumentation } from './router';\nimport type { ReactIntegrationConfig } from './types';\n\nexport class ReactIntegration extends BaseInstrumentation {\n name = '@grafana/faro-react';\n version = VERSION;\n\n constructor(private config: ReactIntegrationConfig = {}) {\n super();\n }\n\n initialize(): void {\n initializeReactRouterInstrumentation(this.config, this.faro);\n }\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,OAAO,gBAAiB,SAAQ,mBAAmB;IAIvD,YAAoB,UAAkC,EAAE;QACtD,KAAK,EAAE,CAAC;QADU,YAAO,GAAP,OAAO,CAA6B;QAHxD,SAAI,GAAG,qBAAqB,CAAC;QAC7B,YAAO,GAAG,OAAO,CAAC;IAIlB,CAAC;IAED,UAAU;QACR,eAAe,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,oCAAoC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["import { BaseInstrumentation, VERSION } from '@grafana/faro-web-sdk';\n\nimport { setDependencies } from './dependencies';\nimport { initializeReactRouterInstrumentation } from './router';\nimport type { ReactIntegrationConfig } from './types';\n\nexport class ReactIntegration extends BaseInstrumentation {\n name = '@grafana/faro-react';\n version = VERSION;\n\n constructor(private options: ReactIntegrationConfig = {}) {\n super();\n }\n\n initialize(): void {\n setDependencies(this.internalLogger, this.api);\n initializeReactRouterInstrumentation(this.options);\n }\n}\n"]}
@@ -1,13 +1,12 @@
1
1
  import { Component } from 'react';
2
- import { faro, VERSION } from '@grafana/faro-web-sdk';
2
+ import { VERSION } from '@grafana/faro-web-sdk';
3
+ import { api, internalLogger } from '../dependencies';
3
4
  export class FaroProfiler extends Component {
4
5
  get isOtelInitialized() {
5
- var _a;
6
- return !!((_a = faro.api) === null || _a === void 0 ? void 0 : _a.isOTELInitialized());
6
+ return !!(api === null || api === void 0 ? void 0 : api.isOTELInitialized());
7
7
  }
8
8
  get otel() {
9
- var _a;
10
- return (_a = faro.api) === null || _a === void 0 ? void 0 : _a.getOTEL();
9
+ return api === null || api === void 0 ? void 0 : api.getOTEL();
11
10
  }
12
11
  get tracer() {
13
12
  var _a;
@@ -34,7 +33,6 @@ export class FaroProfiler extends Component {
34
33
  return span;
35
34
  }
36
35
  constructor(props) {
37
- var _a;
38
36
  super(props);
39
37
  this.mountSpan = undefined;
40
38
  this.mountSpanEndTime = undefined;
@@ -43,7 +41,7 @@ export class FaroProfiler extends Component {
43
41
  this.mountSpan = this.createSpan('componentMount');
44
42
  }
45
43
  else {
46
- (_a = faro.internalLogger) === null || _a === void 0 ? void 0 : _a.error('The Faro React Profiler requires tracing instrumentation. Please enable it in the "instrumentations" section of your config.');
44
+ internalLogger === null || internalLogger === void 0 ? void 0 : internalLogger.error('The Faro React Profiler requires tracing instrumentation. Please enable it in the "instrumentations" section of your config.');
47
45
  }
48
46
  }
49
47
  componentDidMount() {
@@ -1 +1 @@
1
- {"version":3,"file":"FaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/FaroProfiler.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAQtD,MAAM,OAAO,YAAa,SAAQ,SAA4B;IAK5D,IAAY,iBAAiB;;QAC3B,OAAO,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,GAAG,0CAAE,iBAAiB,EAAE,CAAA,CAAC;IACzC,CAAC;IAED,IAAY,IAAI;;QACd,OAAO,MAAA,IAAI,CAAC,GAAG,0CAAE,OAAO,EAAG,CAAC;IAC9B,CAAC;IAED,IAAY,MAAM;;QAChB,OAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,SAAS,CAAC,qBAAqB,EAAE,OAAO,CAAE,CAAC;IACrE,CAAC;IAEO,UAAU,CAChB,QAAgB,EAChB,OAA2E;;QAE3E,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;YAC7B,UAAU,kBACR,sBAAsB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IACpC,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,mCAAI,EAAE,CAAC,CAC/B;SACF,CAAC,CAAC;QAEH,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,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{ ReactNode } from 'react';\n\nimport type { OTELApi } from '@grafana/faro-web-sdk';\nimport { faro, VERSION } from '@grafana/faro-web-sdk';\n\nexport interface FaroProfilerProps {\n children: ReactNode;\n name: string;\n updateProps: Record<string, unknown>;\n}\n\nexport class FaroProfiler extends Component<FaroProfilerProps> {\n protected mountSpan: Span | undefined = undefined;\n protected mountSpanEndTime: number | undefined = undefined;\n protected updateSpan: Span | undefined = undefined;\n\n private get isOtelInitialized(): boolean {\n return !!faro.api?.isOTELInitialized();\n }\n\n private get otel(): OTELApi | undefined {\n return faro.api?.getOTEL()!;\n }\n\n private get tracer(): Tracer {\n return this.otel?.trace.getTracer('@grafana/faro-react', VERSION)!;\n }\n\n private createSpan(\n spanName: string,\n options?: { startTime?: number; endTime?: number; attributes?: Attributes }\n ): Span {\n const span = this.tracer.startSpan(spanName, {\n startTime: options?.startTime,\n attributes: {\n 'react.component.name': this.props.name,\n ...(options?.attributes ?? {}),\n },\n });\n\n this.otel?.trace.setSpan(this.otel.context.active(), span);\n\n if (options?.endTime) {\n span.end(options.endTime);\n }\n\n return span;\n }\n\n private createChildSpan(\n spanName: string,\n parent: Span,\n options?: { startTime?: number; endTime?: number; attributes?: Attributes }\n ): Span {\n let span: Span;\n\n this.otel?.context.with(this.otel.trace.setSpan(this.otel.context.active(), parent), () => {\n span = this.createSpan(spanName, options);\n });\n\n return span!;\n }\n\n constructor(props: FaroProfilerProps) {\n super(props);\n\n if (this.isOtelInitialized) {\n this.mountSpan = this.createSpan('componentMount');\n } else {\n faro.internalLogger?.error(\n 'The Faro React Profiler requires tracing instrumentation. Please enable it in the \"instrumentations\" section of your config.'\n );\n }\n }\n\n override componentDidMount(): void {\n if (this.isOtelInitialized && this.mountSpan) {\n this.mountSpanEndTime = Date.now();\n this.mountSpan.end(this.mountSpanEndTime);\n }\n }\n\n override shouldComponentUpdate({ updateProps }: FaroProfilerProps): boolean {\n if (this.isOtelInitialized && this.mountSpan && updateProps !== this.props.updateProps) {\n const changedProps = Object.keys(updateProps).filter((key) => updateProps[key] !== this.props.updateProps[key]);\n\n if (changedProps.length > 0) {\n this.updateSpan = this.createChildSpan('componentUpdate', this.mountSpan, {\n attributes: {\n 'react.component.changed_props': changedProps,\n },\n });\n }\n }\n\n return true;\n }\n\n override componentDidUpdate(): void {\n if (this.isOtelInitialized && this.updateSpan) {\n this.updateSpan.end();\n this.updateSpan = undefined;\n }\n }\n\n override componentWillUnmount(): void {\n if (this.isOtelInitialized && this.mountSpan) {\n this.createChildSpan('componentRender', this.mountSpan, {\n startTime: this.mountSpanEndTime,\n endTime: Date.now(),\n });\n }\n }\n\n override render(): ReactNode {\n return this.props.children;\n }\n}\n"]}
1
+ {"version":3,"file":"FaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/FaroProfiler.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAGhD,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,MAAM,OAAO,YAAa,SAAQ,SAA4B;IAK5D,IAAY,iBAAiB;QAC3B,OAAO,CAAC,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,iBAAiB,EAAE,CAAA,CAAC;IACpC,CAAC;IAED,IAAY,IAAI;QACd,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAG,CAAC;IACzB,CAAC;IAED,IAAY,MAAM;;QAChB,OAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,SAAS,CAAC,qBAAqB,EAAE,OAAO,CAAE,CAAC;IACrE,CAAC;IAEO,UAAU,CAChB,QAAgB,EAChB,OAA2E;;QAE3E,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3C,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAA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B;gBAChC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;aACpB,CAAC,CAAC;SACJ;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import type { Attributes, Span, Tracer } from '@opentelemetry/api';\nimport { Component } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { VERSION } from '@grafana/faro-web-sdk';\nimport type { OTELApi } from '@grafana/faro-web-sdk';\n\nimport { api, internalLogger } from '../dependencies';\n\nexport interface FaroProfilerProps {\n children: ReactNode;\n name: string;\n updateProps: Record<string, unknown>;\n}\n\nexport class FaroProfiler extends Component<FaroProfilerProps> {\n protected mountSpan: Span | undefined = undefined;\n protected mountSpanEndTime: number | undefined = undefined;\n protected updateSpan: Span | undefined = undefined;\n\n private get isOtelInitialized(): boolean {\n return !!api?.isOTELInitialized();\n }\n\n private get otel(): OTELApi | undefined {\n return api?.getOTEL()!;\n }\n\n private get tracer(): Tracer {\n return this.otel?.trace.getTracer('@grafana/faro-react', VERSION)!;\n }\n\n private createSpan(\n spanName: string,\n options?: { startTime?: number; endTime?: number; attributes?: Attributes }\n ): Span {\n const span = this.tracer.startSpan(spanName, {\n startTime: options?.startTime,\n attributes: {\n 'react.component.name': this.props.name,\n ...(options?.attributes ?? {}),\n },\n });\n\n this.otel?.trace.setSpan(this.otel.context.active(), span);\n\n if (options?.endTime) {\n span.end(options.endTime);\n }\n\n return span;\n }\n\n private createChildSpan(\n spanName: string,\n parent: Span,\n options?: { startTime?: number; endTime?: number; attributes?: Attributes }\n ): Span {\n let span: Span;\n\n this.otel?.context.with(this.otel.trace.setSpan(this.otel.context.active(), parent), () => {\n span = this.createSpan(spanName, options);\n });\n\n return span!;\n }\n\n constructor(props: FaroProfilerProps) {\n super(props);\n\n if (this.isOtelInitialized) {\n this.mountSpan = this.createSpan('componentMount');\n } else {\n internalLogger?.error(\n 'The Faro React Profiler requires tracing instrumentation. Please enable it in the \"instrumentations\" section of your config.'\n );\n }\n }\n\n override componentDidMount(): void {\n if (this.isOtelInitialized && this.mountSpan) {\n this.mountSpanEndTime = Date.now();\n this.mountSpan.end(this.mountSpanEndTime);\n }\n }\n\n override shouldComponentUpdate({ updateProps }: FaroProfilerProps): boolean {\n if (this.isOtelInitialized && this.mountSpan && updateProps !== this.props.updateProps) {\n const changedProps = Object.keys(updateProps).filter((key) => updateProps[key] !== this.props.updateProps[key]);\n\n if (changedProps.length > 0) {\n this.updateSpan = this.createChildSpan('componentUpdate', this.mountSpan, {\n attributes: {\n 'react.component.changed_props': changedProps,\n },\n });\n }\n }\n\n return true;\n }\n\n override componentDidUpdate(): void {\n if (this.isOtelInitialized && this.updateSpan) {\n this.updateSpan.end();\n this.updateSpan = undefined;\n }\n }\n\n override componentWillUnmount(): void {\n if (this.isOtelInitialized && this.mountSpan) {\n this.createChildSpan('componentRender', this.mountSpan, {\n startTime: this.mountSpanEndTime,\n endTime: Date.now(),\n });\n }\n }\n\n override render(): ReactNode {\n return this.props.children;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"withFaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/withFaroProfiler.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,UAAU,gBAAgB,CAC9B,gBAAkC,EAClC,OAAgD;;IAEhD,MAAM,oBAAoB,GAAG,MAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,gBAAgB,CAAC,WAAW,mCAAI,gBAAgB,CAAC,IAAI,mCAAI,aAAa,CAAC;IAErH,MAAM,SAAS,GAAU,CAAC,KAAQ,EAAE,EAAE,CAAC,CACrC,KAAC,YAAY,kBAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,KAAK,gBAC1D,KAAC,gBAAgB,oBAAK,KAAK,EAAI,IAClB,CAChB,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,gBAAgB,oBAAoB,GAAG,CAAC;IAEhE,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAElD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '../utils';\nimport { FaroProfiler } from './FaroProfiler';\nimport type { FaroProfilerProps } from './FaroProfiler';\n\nexport function withFaroProfiler<P extends Record<string, any>>(\n WrappedComponent: ComponentType<P>,\n options?: Omit<FaroProfilerProps, 'updateProps'>\n): FC<P> {\n const componentDisplayName = options?.name ?? WrappedComponent.displayName ?? WrappedComponent.name ?? unknownString;\n\n const Component: FC<P> = (props: P) => (\n <FaroProfiler name={componentDisplayName} updateProps={props}>\n <WrappedComponent {...props} />\n </FaroProfiler>\n );\n\n Component.displayName = `faroProfiler(${componentDisplayName})`;\n\n hoistNonReactStatics(Component, WrappedComponent);\n\n return Component;\n}\n"]}
1
+ {"version":3,"file":"withFaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/withFaroProfiler.tsx"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,MAAM,UAAU,gBAAgB,CAC9B,gBAAkC,EAClC,OAAgD;;IAEhD,MAAM,oBAAoB,GAAG,MAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,gBAAgB,CAAC,WAAW,mCAAI,gBAAgB,CAAC,IAAI,mCAAI,aAAa,CAAC;IAErH,MAAM,SAAS,GAAU,CAAC,KAAQ,EAAE,EAAE,CAAC,CACrC,KAAC,YAAY,kBAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,KAAK,gBAC1D,KAAC,gBAAgB,oBAAK,KAAK,EAAI,IAClB,CAChB,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,gBAAgB,oBAAoB,GAAG,CAAC;IAEhE,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAElD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '../utils';\n\nimport { FaroProfiler } from './FaroProfiler';\nimport type { FaroProfilerProps } from './FaroProfiler';\n\nexport function withFaroProfiler<P extends Record<string, any>>(\n WrappedComponent: ComponentType<P>,\n options?: Omit<FaroProfilerProps, 'updateProps'>\n): FC<P> {\n const componentDisplayName = options?.name ?? WrappedComponent.displayName ?? WrappedComponent.name ?? unknownString;\n\n const Component: FC<P> = (props: P) => (\n <FaroProfiler name={componentDisplayName} updateProps={props}>\n <WrappedComponent {...props} />\n </FaroProfiler>\n );\n\n Component.displayName = `faroProfiler(${componentDisplayName})`;\n\n hoistNonReactStatics(Component, WrappedComponent);\n\n return Component;\n}\n"]}
@@ -1,20 +1,21 @@
1
+ import { internalLogger } from '../dependencies';
1
2
  import { ReactRouterVersion } from './types';
2
3
  import { initializeReactRouterV4V5Instrumentation } from './v4v5';
3
4
  import { initializeReactRouterV6Instrumentation } from './v6';
4
- export function initializeReactRouterInstrumentation(config, faro) {
5
+ export function initializeReactRouterInstrumentation(options) {
5
6
  var _a;
6
- switch ((_a = config.router) === null || _a === void 0 ? void 0 : _a.version) {
7
+ switch ((_a = options.router) === null || _a === void 0 ? void 0 : _a.version) {
7
8
  case ReactRouterVersion.V6:
8
- faro.internalLogger.debug('Initializing React Router V6 instrumentation');
9
- initializeReactRouterV6Instrumentation(config.router.dependencies, faro);
9
+ internalLogger.debug('Initializing React Router V6 instrumentation');
10
+ initializeReactRouterV6Instrumentation(options.router.dependencies);
10
11
  break;
11
12
  case ReactRouterVersion.V5:
12
13
  case ReactRouterVersion.V4:
13
- faro.internalLogger.debug(`Initializing React Router ${config.router.version} instrumentation`);
14
- initializeReactRouterV4V5Instrumentation(config.router.dependencies, faro);
14
+ internalLogger.debug(`Initializing React Router ${options.router.version} instrumentation`);
15
+ initializeReactRouterV4V5Instrumentation(options.router.dependencies);
15
16
  break;
16
17
  default:
17
- faro.internalLogger.debug('Skipping initialization of React Router instrumentation');
18
+ internalLogger.debug('Skipping initialization of React Router instrumentation');
18
19
  }
19
20
  }
20
21
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/router/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,wCAAwC,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,sCAAsC,EAAE,MAAM,MAAM,CAAC;AAE9D,MAAM,UAAU,oCAAoC,CAAC,MAA8B,EAAE,IAAU;;IAC7F,QAAQ,MAAA,MAAM,CAAC,MAAM,0CAAE,OAAO,EAAE;QAC9B,KAAK,kBAAkB,CAAC,EAAE;YACxB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC1E,sCAAsC,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YACzE,MAAM;QAER,KAAK,kBAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,kBAAkB,CAAC,EAAE;YACxB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,6BAA6B,MAAM,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;YAChG,wCAAwC,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAC3E,MAAM;QAER;YACE,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;KACxF;AACH,CAAC","sourcesContent":["import type { Faro } from '@grafana/faro-web-sdk';\n\nimport type { ReactIntegrationConfig } from '../types';\nimport { ReactRouterVersion } from './types';\nimport { initializeReactRouterV4V5Instrumentation } from './v4v5';\nimport { initializeReactRouterV6Instrumentation } from './v6';\n\nexport function initializeReactRouterInstrumentation(config: ReactIntegrationConfig, faro: Faro): void {\n switch (config.router?.version) {\n case ReactRouterVersion.V6:\n faro.internalLogger.debug('Initializing React Router V6 instrumentation');\n initializeReactRouterV6Instrumentation(config.router.dependencies, faro);\n break;\n\n case ReactRouterVersion.V5:\n case ReactRouterVersion.V4:\n faro.internalLogger.debug(`Initializing React Router ${config.router.version} instrumentation`);\n initializeReactRouterV4V5Instrumentation(config.router.dependencies, faro);\n break;\n\n default:\n faro.internalLogger.debug('Skipping initialization of React Router instrumentation');\n }\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/router/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,wCAAwC,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,sCAAsC,EAAE,MAAM,MAAM,CAAC;AAE9D,MAAM,UAAU,oCAAoC,CAAC,OAA+B;;IAClF,QAAQ,MAAA,OAAO,CAAC,MAAM,0CAAE,OAAO,EAAE;QAC/B,KAAK,kBAAkB,CAAC,EAAE;YACxB,cAAc,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YACrE,sCAAsC,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACpE,MAAM;QAER,KAAK,kBAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,kBAAkB,CAAC,EAAE;YACxB,cAAc,CAAC,KAAK,CAAC,6BAA6B,OAAO,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;YAC5F,wCAAwC,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACtE,MAAM;QAER;YACE,cAAc,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;KACnF;AACH,CAAC","sourcesContent":["import { internalLogger } from '../dependencies';\nimport type { ReactIntegrationConfig } from '../types';\n\nimport { ReactRouterVersion } from './types';\nimport { initializeReactRouterV4V5Instrumentation } from './v4v5';\nimport { initializeReactRouterV6Instrumentation } from './v6';\n\nexport function initializeReactRouterInstrumentation(options: ReactIntegrationConfig): void {\n switch (options.router?.version) {\n case ReactRouterVersion.V6:\n internalLogger.debug('Initializing React Router V6 instrumentation');\n initializeReactRouterV6Instrumentation(options.router.dependencies);\n break;\n\n case ReactRouterVersion.V5:\n case ReactRouterVersion.V4:\n internalLogger.debug(`Initializing React Router ${options.router.version} instrumentation`);\n initializeReactRouterV4V5Instrumentation(options.router.dependencies);\n break;\n\n default:\n internalLogger.debug('Skipping initialization of React Router instrumentation');\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { setActiveEventRoute } from './activeEvent';
3
- import { Route } from './dependencies';
3
+ import { Route } from './routerDependencies';
4
4
  export function FaroRoute(props) {
5
5
  var _a;
6
6
  if ((_a = props === null || props === void 0 ? void 0 : props.computedMatch) === null || _a === void 0 ? void 0 : _a.isExact) {
@@ -1 +1 @@
1
- {"version":3,"file":"FaroRoute.js","sourceRoot":"","sources":["../../../../src/router/v4v5/FaroRoute.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,UAAU,SAAS,CAAC,KAAgC;;IACxD,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,0CAAE,OAAO,EAAE;QACjC,mBAAmB,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KAC/C;IAED,OAAO,KAAC,KAAK,oBAAK,KAAK,EAAI,CAAC;AAC9B,CAAC","sourcesContent":["import { setActiveEventRoute } from './activeEvent';\nimport { Route } from './dependencies';\nimport type { ReactRouterV4V5RouteProps } from './types';\n\nexport function FaroRoute(props: ReactRouterV4V5RouteProps) {\n if (props?.computedMatch?.isExact) {\n setActiveEventRoute(props.computedMatch.path);\n }\n\n return <Route {...props} />;\n}\n"]}
1
+ {"version":3,"file":"FaroRoute.js","sourceRoot":"","sources":["../../../../src/router/v4v5/FaroRoute.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,MAAM,UAAU,SAAS,CAAC,KAAgC;;IACxD,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,0CAAE,OAAO,EAAE;QACjC,mBAAmB,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KAC/C;IAED,OAAO,KAAC,KAAK,oBAAK,KAAK,EAAI,CAAC;AAC9B,CAAC","sourcesContent":["import { setActiveEventRoute } from './activeEvent';\nimport { Route } from './routerDependencies';\nimport type { ReactRouterV4V5RouteProps } from './types';\n\nexport function FaroRoute(props: ReactRouterV4V5RouteProps) {\n if (props?.computedMatch?.isExact) {\n setActiveEventRoute(props.computedMatch.path);\n }\n\n return <Route {...props} />;\n}\n"]}
@@ -1,9 +1,9 @@
1
- import { faro } from './dependencies';
1
+ import { api } from '../../dependencies';
2
2
  export let activeEvent = undefined;
3
3
  export function createNewActiveEvent(url) {
4
4
  activeEvent = {
5
- url,
6
5
  route: '',
6
+ url,
7
7
  };
8
8
  return activeEvent;
9
9
  }
@@ -13,7 +13,7 @@ export function setActiveEventRoute(route) {
13
13
  }
14
14
  }
15
15
  export function sendActiveEvent() {
16
- faro.api.pushEvent('routeChange', activeEvent, undefined, { skipDedupe: true });
16
+ api.pushEvent('routeChange', activeEvent, undefined, { skipDedupe: true });
17
17
  activeEvent = undefined;
18
18
  }
19
19
  //# sourceMappingURL=activeEvent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"activeEvent.js","sourceRoot":"","sources":["../../../../src/router/v4v5/activeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,MAAM,CAAC,IAAI,WAAW,GAA2C,SAAS,CAAC;AAE3E,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,WAAW,GAAG;QACZ,GAAG;QACH,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,WAAW,EAAE;QACf,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3B;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhF,WAAW,GAAG,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import { faro } from './dependencies';\nimport type { ReactRouterV4V5ActiveEvent } from './types';\n\nexport let activeEvent: ReactRouterV4V5ActiveEvent | undefined = undefined;\n\nexport function createNewActiveEvent(url: string): ReactRouterV4V5ActiveEvent {\n activeEvent = {\n url,\n route: '',\n };\n\n return activeEvent;\n}\n\nexport function setActiveEventRoute(route: string): void {\n if (activeEvent) {\n activeEvent.route = route;\n }\n}\n\nexport function sendActiveEvent(): void {\n faro.api.pushEvent('routeChange', activeEvent, undefined, { skipDedupe: true });\n\n activeEvent = undefined;\n}\n"]}
1
+ {"version":3,"file":"activeEvent.js","sourceRoot":"","sources":["../../../../src/router/v4v5/activeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAIzC,MAAM,CAAC,IAAI,WAAW,GAA2C,SAAS,CAAC;AAE3E,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,WAAW,GAAG;QACZ,KAAK,EAAE,EAAE;QACT,GAAG;KACJ,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,IAAI,WAAW,EAAE;QACf,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC;KAC3B;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3E,WAAW,GAAG,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import { api } from '../../dependencies';\n\nimport type { ReactRouterV4V5ActiveEvent } from './types';\n\nexport let activeEvent: ReactRouterV4V5ActiveEvent | undefined = undefined;\n\nexport function createNewActiveEvent(url: string): ReactRouterV4V5ActiveEvent {\n activeEvent = {\n route: '',\n url,\n };\n\n return activeEvent;\n}\n\nexport function setActiveEventRoute(route: string): void {\n if (activeEvent) {\n activeEvent.route = route;\n }\n}\n\nexport function sendActiveEvent(): void {\n api.pushEvent('routeChange', activeEvent, undefined, { skipDedupe: true });\n\n activeEvent = undefined;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { setReactRouterV4V5SSRDependencies } from './dependencies';
2
1
  export { FaroRoute } from './FaroRoute';
3
2
  export { initializeReactRouterV4V5Instrumentation } from './initialize';
3
+ export { setReactRouterV4V5SSRDependencies } from './routerDependencies';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/router/v4v5/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { setReactRouterV4V5SSRDependencies } from './dependencies';\n\nexport { FaroRoute } from './FaroRoute';\n\nexport { initializeReactRouterV4V5Instrumentation } from './initialize';\n\nexport type { ReactRouterV4V5ActiveEvent, ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/router/v4v5/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,wCAAwC,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { FaroRoute } from './FaroRoute';\n\nexport { initializeReactRouterV4V5Instrumentation } from './initialize';\n\nexport { setReactRouterV4V5SSRDependencies } from './routerDependencies';\n\nexport type { ReactRouterV4V5ActiveEvent, ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';\n"]}
@@ -2,15 +2,15 @@ import hoistNonReactStatics from 'hoist-non-react-statics';
2
2
  import { globalObject } from '@grafana/faro-web-sdk';
3
3
  import { NavigationType } from '../types';
4
4
  import { createNewActiveEvent, sendActiveEvent } from './activeEvent';
5
- import { setDependencies } from './dependencies';
6
5
  import { FaroRoute } from './FaroRoute';
7
- export function initializeReactRouterV4V5Instrumentation(dependencies, faro) {
6
+ import { setReactRouterV4V5Dependencies } from './routerDependencies';
7
+ export function initializeReactRouterV4V5Instrumentation(dependencies) {
8
8
  var _a, _b, _c, _d;
9
9
  const Route = dependencies.Route;
10
10
  const componentDisplayName = (_a = Route.displayName) !== null && _a !== void 0 ? _a : Route.name;
11
11
  FaroRoute.displayName = `faroRoute(${componentDisplayName})`;
12
12
  hoistNonReactStatics(FaroRoute, Route);
13
- setDependencies(dependencies, faro);
13
+ setReactRouterV4V5Dependencies(dependencies);
14
14
  createNewActiveEvent((_b = globalObject.location) === null || _b === void 0 ? void 0 : _b.href);
15
15
  (_d = (_c = dependencies.history).listen) === null || _d === void 0 ? void 0 : _d.call(_c, (_location, action) => {
16
16
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v4v5/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,UAAU,wCAAwC,CAAC,YAAyC,EAAE,IAAU;;IAC5G,MAAM,KAAK,GAAG,YAAY,CAAC,KAA0B,CAAC;IACtD,MAAM,oBAAoB,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,KAAK,CAAC,IAAI,CAAC;IAC5D,SAA+B,CAAC,WAAW,GAAG,aAAa,oBAAoB,GAAG,CAAC;IACpF,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEvC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAEpC,oBAAoB,CAAC,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;IAElD,MAAA,MAAA,YAAY,CAAC,OAAO,EAAC,MAAM,mDAAG,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE;;QAClD,IAAI,MAAM,KAAK,cAAc,CAAC,IAAI,IAAI,MAAM,KAAK,cAAc,CAAC,GAAG,EAAE;YACnE,eAAe,EAAE,CAAC;YAElB,oBAAoB,CAAC,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;SACnD;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { FunctionComponent } from 'react';\n\nimport { globalObject } from '@grafana/faro-web-sdk';\nimport type { Faro } from '@grafana/faro-web-sdk';\n\nimport { NavigationType } from '../types';\nimport { createNewActiveEvent, sendActiveEvent } from './activeEvent';\nimport { setDependencies } from './dependencies';\nimport { FaroRoute } from './FaroRoute';\nimport type { ReactRouterV4V5Dependencies } from './types';\n\nexport function initializeReactRouterV4V5Instrumentation(dependencies: ReactRouterV4V5Dependencies, faro: Faro): void {\n const Route = dependencies.Route as FunctionComponent;\n const componentDisplayName = Route.displayName ?? Route.name;\n (FaroRoute as FunctionComponent).displayName = `faroRoute(${componentDisplayName})`;\n hoistNonReactStatics(FaroRoute, Route);\n\n setDependencies(dependencies, faro);\n\n createNewActiveEvent(globalObject.location?.href);\n\n dependencies.history.listen?.((_location, action) => {\n if (action === NavigationType.Push || action === NavigationType.Pop) {\n sendActiveEvent();\n\n createNewActiveEvent(globalObject.location?.href);\n }\n });\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v4v5/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAGtE,MAAM,UAAU,wCAAwC,CAAC,YAAyC;;IAChG,MAAM,KAAK,GAAG,YAAY,CAAC,KAA0B,CAAC;IACtD,MAAM,oBAAoB,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,KAAK,CAAC,IAAI,CAAC;IAC5D,SAA+B,CAAC,WAAW,GAAG,aAAa,oBAAoB,GAAG,CAAC;IACpF,oBAAoB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEvC,8BAA8B,CAAC,YAAY,CAAC,CAAC;IAE7C,oBAAoB,CAAC,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;IAElD,MAAA,MAAA,YAAY,CAAC,OAAO,EAAC,MAAM,mDAAG,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE;;QAClD,IAAI,MAAM,KAAK,cAAc,CAAC,IAAI,IAAI,MAAM,KAAK,cAAc,CAAC,GAAG,EAAE;YACnE,eAAe,EAAE,CAAC;YAElB,oBAAoB,CAAC,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;SACnD;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { FunctionComponent } from 'react';\n\nimport { globalObject } from '@grafana/faro-web-sdk';\n\nimport { NavigationType } from '../types';\n\nimport { createNewActiveEvent, sendActiveEvent } from './activeEvent';\nimport { FaroRoute } from './FaroRoute';\nimport { setReactRouterV4V5Dependencies } from './routerDependencies';\nimport type { ReactRouterV4V5Dependencies } from './types';\n\nexport function initializeReactRouterV4V5Instrumentation(dependencies: ReactRouterV4V5Dependencies): void {\n const Route = dependencies.Route as FunctionComponent;\n const componentDisplayName = Route.displayName ?? Route.name;\n (FaroRoute as FunctionComponent).displayName = `faroRoute(${componentDisplayName})`;\n hoistNonReactStatics(FaroRoute, Route);\n\n setReactRouterV4V5Dependencies(dependencies);\n\n createNewActiveEvent(globalObject.location?.href);\n\n dependencies.history.listen?.((_location, action) => {\n if (action === NavigationType.Push || action === NavigationType.Pop) {\n sendActiveEvent();\n\n createNewActiveEvent(globalObject.location?.href);\n }\n });\n}\n"]}
@@ -1,14 +1,12 @@
1
1
  export let isInitialized = false;
2
- export let faro;
3
2
  export let history;
4
3
  export let Route;
5
- export function setDependencies(dependencies, newFaro) {
4
+ export function setReactRouterV4V5Dependencies(dependencies) {
6
5
  isInitialized = true;
7
- faro = newFaro;
8
6
  history = dependencies.history;
9
7
  Route = dependencies.Route;
10
8
  }
11
9
  export function setReactRouterV4V5SSRDependencies(newDependencies) {
12
10
  Route = newDependencies.Route;
13
11
  }
14
- //# sourceMappingURL=dependencies.js.map
12
+ //# sourceMappingURL=routerDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerDependencies.js","sourceRoot":"","sources":["../../../../src/router/v4v5/routerDependencies.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,IAAI,aAAa,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,IAAI,OAA2B,CAAC;AACvC,MAAM,CAAC,IAAI,KAAgC,CAAC;AAE5C,MAAM,UAAU,8BAA8B,CAAC,YAAyC;IACtF,aAAa,GAAG,IAAI,CAAC;IAErB,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;IAC/B,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,eAA2D;IAC3G,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;AAChC,CAAC","sourcesContent":["import type { ReactRouterHistory } from '../types';\n\nimport type { ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';\n\nexport let isInitialized = false;\nexport let history: ReactRouterHistory;\nexport let Route: ReactRouterV4V5RouteShape;\n\nexport function setReactRouterV4V5Dependencies(dependencies: ReactRouterV4V5Dependencies): void {\n isInitialized = true;\n\n history = dependencies.history;\n Route = dependencies.Route;\n}\n\nexport function setReactRouterV4V5SSRDependencies(newDependencies: Pick<ReactRouterV4V5Dependencies, 'Route'>): void {\n Route = newDependencies.Route;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v4v5/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactRouterHistory } from '../types';\n\nexport type ReactRouterV4V5RouteShape = any;\n\nexport interface ReactRouterV4V5RouteProps extends Record<string, any> {\n computedMatch?: {\n isExact: boolean;\n path: string;\n };\n}\n\nexport interface ReactRouterV4V5Dependencies {\n history: ReactRouterHistory;\n Route: ReactRouterV4V5RouteShape;\n}\n\nexport interface ReactRouterV4V5ActiveEvent extends Record<string, string> {\n url: string;\n route: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/router/v4v5/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReactRouterHistory } from '../types';\n\nexport type ReactRouterV4V5RouteShape = any;\n\nexport interface ReactRouterV4V5RouteProps extends Record<string, any> {\n computedMatch?: {\n isExact: boolean;\n path: string;\n };\n}\n\nexport interface ReactRouterV4V5Dependencies {\n history: ReactRouterHistory;\n Route: ReactRouterV4V5RouteShape;\n}\n\nexport interface ReactRouterV4V5ActiveEvent extends Record<string, string> {\n route: string;\n url: string;\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo } from 'react';
3
3
  import { globalObject } from '@grafana/faro-web-sdk';
4
+ import { api } from '../../dependencies';
4
5
  import { NavigationType } from '../types';
5
- import { createRoutesFromChildren, faro, isInitialized, Routes, useLocation, useNavigationType } from './dependencies';
6
+ import { createRoutesFromChildren, isInitialized, Routes, useLocation, useNavigationType } from './routerDependencies';
6
7
  import { getRouteFromLocation } from './utils';
7
8
  export function FaroRoutes(props) {
8
9
  var _a;
@@ -12,9 +13,9 @@ export function FaroRoutes(props) {
12
13
  useEffect(() => {
13
14
  var _a;
14
15
  if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {
15
- faro.api.pushEvent('routeChange', {
16
- url: (_a = globalObject.location) === null || _a === void 0 ? void 0 : _a.href,
16
+ api.pushEvent('routeChange', {
17
17
  route: getRouteFromLocation(routes, location),
18
+ url: (_a = globalObject.location) === null || _a === void 0 ? void 0 : _a.href,
18
19
  });
19
20
  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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 } from 'react';\n\nimport { globalObject } from '@grafana/faro-web-sdk';\n\nimport { NavigationType } from '../types';\nimport { createRoutesFromChildren, faro, isInitialized, Routes, useLocation, useNavigationType } from './dependencies';\nimport type { 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 useEffect(() => {\n if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {\n faro.api.pushEvent('routeChange', {\n url: globalObject.location?.href,\n route: getRouteFromLocation(routes, location),\n });\n }\n }, [location, navigationType, routes]);\n\n const ActualRoutes = props.routesComponent ?? Routes;\n\n return <ActualRoutes {...props} />;\n}\n"]}
1
+ {"version":3,"file":"FaroRoutes.js","sourceRoot":"","sources":["../../../../src/router/v6/FaroRoutes.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,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,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,aAAa,IAAI,CAAC,cAAc,KAAK,cAAc,CAAC,IAAI,IAAI,cAAc,KAAK,cAAc,CAAC,GAAG,CAAC,EAAE;YACtG,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE;gBAC3B,KAAK,EAAE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC;gBAC7C,GAAG,EAAE,MAAA,YAAY,CAAC,QAAQ,0CAAE,IAAI;aACjC,CAAC,CAAC;SACJ;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 } from 'react';\n\nimport { 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 { 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 useEffect(() => {\n if (isInitialized && (navigationType === NavigationType.Push || navigationType === NavigationType.Pop)) {\n api.pushEvent('routeChange', {\n route: getRouteFromLocation(routes, location),\n url: globalObject.location?.href,\n });\n }\n }, [location, navigationType, routes]);\n\n const ActualRoutes = props.routesComponent ?? Routes;\n\n return <ActualRoutes {...props} />;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { setReactRouterV6SSRDependencies } from './dependencies';
2
1
  export { FaroRoutes } from './FaroRoutes';
3
2
  export { initializeReactRouterV6Instrumentation } from './initialize';
3
+ export { setReactRouterV6SSRDependencies } from './routerDependencies';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/router/v6/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { setReactRouterV6SSRDependencies } from './dependencies';\n\nexport { FaroRoutes } from './FaroRoutes';\n\nexport { initializeReactRouterV6Instrumentation } from './initialize';\n\nexport type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6Params,\n ReactRouterV6RouteMatch,\n ReactRouterV6RouteObject,\n ReactRouterV6RoutesProps,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n"]}
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,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { FaroRoutes } from './FaroRoutes';\n\nexport { initializeReactRouterV6Instrumentation } from './initialize';\n\nexport { setReactRouterV6SSRDependencies } from './routerDependencies';\n\nexport type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6Params,\n ReactRouterV6RouteMatch,\n ReactRouterV6RouteObject,\n ReactRouterV6RoutesProps,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n"]}
@@ -1,8 +1,8 @@
1
1
  import hoistNonReactStatics from 'hoist-non-react-statics';
2
- import { setDependencies } from './dependencies';
3
2
  import { FaroRoutes } from './FaroRoutes';
4
- export function initializeReactRouterV6Instrumentation(dependencies, faro) {
3
+ import { setReactRouterV6Dependencies } from './routerDependencies';
4
+ export function initializeReactRouterV6Instrumentation(dependencies) {
5
5
  hoistNonReactStatics(FaroRoutes, dependencies.Routes);
6
- setDependencies(dependencies, faro);
6
+ setReactRouterV6Dependencies(dependencies);
7
7
  }
8
8
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,UAAU,sCAAsC,CAAC,YAAuC,EAAE,IAAU;IACxG,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAEtD,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport type { Faro } from '@grafana/faro-web-sdk';\n\nimport { setDependencies } from './dependencies';\nimport { FaroRoutes } from './FaroRoutes';\nimport type { ReactRouterV6Dependencies } from './types';\n\nexport function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies, faro: Faro): void {\n hoistNonReactStatics(FaroRoutes, dependencies.Routes);\n\n setDependencies(dependencies, faro);\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,UAAU,sCAAsC,CAAC,YAAuC;IAC5F,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAEtD,4BAA4B,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { FaroRoutes } from './FaroRoutes';\nimport { setReactRouterV6Dependencies } from './routerDependencies';\nimport type { ReactRouterV6Dependencies } from './types';\n\nexport function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies): void {\n hoistNonReactStatics(FaroRoutes, dependencies.Routes);\n\n setReactRouterV6Dependencies(dependencies);\n}\n"]}
@@ -1,13 +1,11 @@
1
1
  export let isInitialized = false;
2
- export let faro;
3
2
  export let createRoutesFromChildren;
4
3
  export let matchRoutes;
5
4
  export let Routes;
6
5
  export let useLocation;
7
6
  export let useNavigationType;
8
- export function setDependencies(newDependencies, newFaro) {
7
+ export function setReactRouterV6Dependencies(newDependencies) {
9
8
  isInitialized = true;
10
- faro = newFaro;
11
9
  createRoutesFromChildren = newDependencies.createRoutesFromChildren;
12
10
  matchRoutes = newDependencies.matchRoutes;
13
11
  Routes = newDependencies.Routes;
@@ -17,4 +15,4 @@ export function setDependencies(newDependencies, newFaro) {
17
15
  export function setReactRouterV6SSRDependencies(newDependencies) {
18
16
  Routes = newDependencies.Routes;
19
17
  }
20
- //# sourceMappingURL=dependencies.js.map
18
+ //# sourceMappingURL=routerDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerDependencies.js","sourceRoot":"","sources":["../../../../src/router/v6/routerDependencies.ts"],"names":[],"mappings":"AASA,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","sourcesContent":["import type {\n ReactRouterV6CreateRoutesFromChildren,\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"]}
@@ -1,4 +1,4 @@
1
- import { matchRoutes } from './dependencies';
1
+ import { matchRoutes } from './routerDependencies';
2
2
  export function getNumberOfUrlSegments(url) {
3
3
  return url.split(/\\?\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,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;QAClC,OAAO,QAAQ,CAAC,QAAQ,CAAC;KAC1B;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpD,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,IAAI,aAAa,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,CAAC,CAAE,CAAC;YACjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YAE3B,IAAI,KAAK,EAAE;gBACT,IAAI,KAAK,CAAC,KAAK,EAAE;oBACf,OAAO,MAAM,CAAC,QAAQ,CAAC;iBACxB;gBAED,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAEtB,IAAI,IAAI,EAAE;oBACR,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;wBACzC,IAAI,sBAAsB,CAAC,WAAW,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;4BACnF,OAAO,IAAI,CAAC;yBACb;wBAED,OAAO,WAAW,CAAC;qBACpB;iBACF;aACF;SACF;KACF;IAED,OAAO,QAAQ,CAAC,QAAQ,CAAC;AAC3B,CAAC","sourcesContent":["import type { ReactRouterLocation } from '../types';\nimport { matchRoutes } from './dependencies';\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
+ {"version":3,"file":"utils.js","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BAAsB,CAAC,WAAW,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;4BACnF,OAAO,IAAI,CAAC;yBACb;wBAED,OAAO,WAAW,CAAC;qBACpB;iBACF;aACF;SACF;KACF;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,4 @@
1
+ import type { API, InternalLogger } from '@grafana/faro-web-sdk';
2
+ export declare let internalLogger: InternalLogger;
3
+ export declare let api: API;
4
+ export declare function setDependencies(newInternalLogger: InternalLogger, newApi: API): void;
@@ -1,10 +1,8 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { Faro } from '@grafana/faro-web-sdk';
3
2
  export type ReactNodeRender = () => ReactNode;
4
3
  export type ReactProps = Record<string, any>;
5
4
  export type FaroErrorBoundaryFallbackRender = (error: Error, resetError: VoidFunction) => ReactElement;
6
5
  export interface FaroErrorBoundaryProps {
7
- faro?: Faro;
8
6
  beforeCapture?: (error: Error | null) => void;
9
7
  children?: ReactNode | ReactNodeRender;
10
8
  fallback?: ReactElement | FaroErrorBoundaryFallbackRender;
@@ -7,5 +7,5 @@ export { FaroRoute, FaroRoutes, NavigationType, ReactRouterVersion, setReactRout
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 } from './types';
9
9
  export { getMajorReactVersion, isReactVersionAtLeast, isReactVersionAtLeast16, isReactVersionAtLeast17, isReactVersionAtLeast18, reactVersion, reactVersionMajor, } from './utils';
10
- export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, browserMeta, buildStackFrame, ConsoleInstrumentation, ConsoleTransport, Conventions, createInternalLogger, createPromiseBuffer, createSession, deepEqual, defaultExceptionType, defaultEventDomain, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, defaultMetas, ErrorsInstrumentation, FetchTransport, getCurrentTimestamp, getDataFromSafariExtensions, getInternalFaroFromGlobalObject, getStackFramesFromError, getTransportBody, getWebInstrumentations, globalObject, initializeFaro, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, makeCoreConfig, noop, pageMeta, parseStacktrace, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, WebVitalsInstrumentation, } from '@grafana/faro-web-sdk';
11
- export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BrowserConfig, Config, ConsoleInstrumentationOptions, ConsoleTransportOptions, ErrorEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, ExtendedPromiseRejectionEvent, FetchTransportOptions, FetchTransportRequestOptions, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, OTELApi, Patterns, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-web-sdk';
10
+ export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, browserMeta, buildStackFrame, ConsoleInstrumentation, ConsoleTransport, Conventions, createInternalLogger, createPromiseBuffer, createSession, deepEqual, defaultExceptionType, defaultEventDomain, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, defaultMetas, defaultViewMeta, ErrorsInstrumentation, FetchTransport, genShortID, getCurrentTimestamp, getDataFromSafariExtensions, getInternalFaroFromGlobalObject, getStackFramesFromError, getTransportBody, getWebInstrumentations, globalObject, initializeFaro, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, makeCoreConfig, noop, pageMeta, parseStacktrace, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, ViewInstrumentation, WebVitalsInstrumentation, } from '@grafana/faro-web-sdk';
11
+ export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BrowserConfig, Config, ConsoleInstrumentationOptions, ConsoleTransportOptions, ErrorEvent, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, ExtendedPromiseRejectionEvent, Extension, FetchTransportOptions, FetchTransportRequestOptions, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, OTELApi, Patterns, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-web-sdk';
@@ -1,9 +1,9 @@
1
1
  import { BaseInstrumentation } from '@grafana/faro-web-sdk';
2
2
  import type { ReactIntegrationConfig } from './types';
3
3
  export declare class ReactIntegration extends BaseInstrumentation {
4
- private config;
4
+ private options;
5
5
  name: string;
6
6
  version: string;
7
- constructor(config?: ReactIntegrationConfig);
7
+ constructor(options?: ReactIntegrationConfig);
8
8
  initialize(): void;
9
9
  }
@@ -1,3 +1,2 @@
1
- import type { Faro } from '@grafana/faro-web-sdk';
2
1
  import type { ReactIntegrationConfig } from '../types';
3
- export declare function initializeReactRouterInstrumentation(config: ReactIntegrationConfig, faro: Faro): void;
2
+ export declare function initializeReactRouterInstrumentation(options: ReactIntegrationConfig): void;
@@ -1,4 +1,4 @@
1
- export { setReactRouterV4V5SSRDependencies } from './dependencies';
2
1
  export { FaroRoute } from './FaroRoute';
3
2
  export { initializeReactRouterV4V5Instrumentation } from './initialize';
3
+ export { setReactRouterV4V5SSRDependencies } from './routerDependencies';
4
4
  export type { ReactRouterV4V5ActiveEvent, ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';
@@ -1,3 +1,2 @@
1
- import type { Faro } from '@grafana/faro-web-sdk';
2
1
  import type { ReactRouterV4V5Dependencies } from './types';
3
- export declare function initializeReactRouterV4V5Instrumentation(dependencies: ReactRouterV4V5Dependencies, faro: Faro): void;
2
+ export declare function initializeReactRouterV4V5Instrumentation(dependencies: ReactRouterV4V5Dependencies): void;
@@ -1,9 +1,7 @@
1
- import type { Faro } from '@grafana/faro-web-sdk';
2
1
  import type { ReactRouterHistory } from '../types';
3
2
  import type { ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';
4
3
  export declare let isInitialized: boolean;
5
- export declare let faro: Faro;
6
4
  export declare let history: ReactRouterHistory;
7
5
  export declare let Route: ReactRouterV4V5RouteShape;
8
- export declare function setDependencies(dependencies: ReactRouterV4V5Dependencies, newFaro: Faro): void;
6
+ export declare function setReactRouterV4V5Dependencies(dependencies: ReactRouterV4V5Dependencies): void;
9
7
  export declare function setReactRouterV4V5SSRDependencies(newDependencies: Pick<ReactRouterV4V5Dependencies, 'Route'>): void;
@@ -11,6 +11,6 @@ export interface ReactRouterV4V5Dependencies {
11
11
  Route: ReactRouterV4V5RouteShape;
12
12
  }
13
13
  export interface ReactRouterV4V5ActiveEvent extends Record<string, string> {
14
- url: string;
15
14
  route: string;
15
+ url: string;
16
16
  }
@@ -1,4 +1,4 @@
1
- export { setReactRouterV6SSRDependencies } from './dependencies';
2
1
  export { FaroRoutes } from './FaroRoutes';
3
2
  export { initializeReactRouterV6Instrumentation } from './initialize';
3
+ export { setReactRouterV6SSRDependencies } from './routerDependencies';
4
4
  export type { ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6Params, ReactRouterV6RouteMatch, ReactRouterV6RouteObject, ReactRouterV6RoutesProps, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType, } from './types';
@@ -1,3 +1,2 @@
1
- import type { Faro } from '@grafana/faro-web-sdk';
2
1
  import type { ReactRouterV6Dependencies } from './types';
3
- export declare function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies, faro: Faro): void;
2
+ export declare function initializeReactRouterV6Instrumentation(dependencies: ReactRouterV6Dependencies): void;
@@ -1,11 +1,9 @@
1
- import type { Faro } from '@grafana/faro-web-sdk';
2
1
  import type { ReactRouterV6CreateRoutesFromChildren, ReactRouterV6Dependencies, ReactRouterV6MatchRoutes, ReactRouterV6RoutesShape, ReactRouterV6UseLocation, ReactRouterV6UseNavigationType } from './types';
3
2
  export declare let isInitialized: boolean;
4
- export declare let faro: Faro;
5
3
  export declare let createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;
6
4
  export declare let matchRoutes: ReactRouterV6MatchRoutes;
7
5
  export declare let Routes: ReactRouterV6RoutesShape;
8
6
  export declare let useLocation: ReactRouterV6UseLocation;
9
7
  export declare let useNavigationType: ReactRouterV6UseNavigationType;
10
- export declare function setDependencies(newDependencies: ReactRouterV6Dependencies, newFaro: Faro): void;
8
+ export declare function setReactRouterV6Dependencies(newDependencies: ReactRouterV6Dependencies): void;
11
9
  export declare function setReactRouterV6SSRDependencies(newDependencies: Pick<ReactRouterV6Dependencies, 'Routes'>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-react",
3
- "version": "1.0.0-beta4",
3
+ "version": "1.0.0",
4
4
  "description": "Faro package that enables easier integration in projects built with React.",
5
5
  "keywords": [
6
6
  "observability",
@@ -51,15 +51,15 @@
51
51
  "quality:circular-deps": "madge --circular ."
52
52
  },
53
53
  "dependencies": {
54
- "@grafana/faro-web-sdk": "^1.0.0-beta4",
55
- "@grafana/faro-web-tracing": "^1.0.0-beta4",
54
+ "@grafana/faro-web-sdk": "^1.0.0",
55
+ "@grafana/faro-web-tracing": "^1.0.0",
56
56
  "hoist-non-react-statics": "^3.3.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/hoist-non-react-statics": "^3.3.1",
60
60
  "@types/react": "^18.0.26",
61
61
  "react": "^18.2.0",
62
- "react-router-dom": "^6.4.5"
62
+ "react-router-dom": "^6.6.2"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "88ab57b93286d22830db932a7dc74bcaf2dd4c3d"
71
+ "gitHead": "afd9cbdff2b0665006e081bb72360301916e5e56"
72
72
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/router/v4v5/dependencies.ts"],"names":[],"mappings":";;;AAKW,QAAA,aAAa,GAAG,KAAK,CAAC;AAKjC,SAAgB,eAAe,CAAC,YAAyC,EAAE,OAAa;IACtF,qBAAa,GAAG,IAAI,CAAC;IAErB,YAAI,GAAG,OAAO,CAAC;IACf,eAAO,GAAG,YAAY,CAAC,OAAO,CAAC;IAC/B,aAAK,GAAG,YAAY,CAAC,KAAK,CAAC;AAC7B,CAAC;AAND,0CAMC;AAED,SAAgB,iCAAiC,CAAC,eAA2D;IAC3G,aAAK,GAAG,eAAe,CAAC,KAAK,CAAC;AAChC,CAAC;AAFD,8EAEC","sourcesContent":["import type { Faro } from '@grafana/faro-web-sdk';\n\nimport type { ReactRouterHistory } from '../types';\nimport type { ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';\n\nexport let isInitialized = false;\nexport let faro: Faro;\nexport let history: ReactRouterHistory;\nexport let Route: ReactRouterV4V5RouteShape;\n\nexport function setDependencies(dependencies: ReactRouterV4V5Dependencies, newFaro: Faro): void {\n isInitialized = true;\n\n faro = newFaro;\n history = dependencies.history;\n Route = dependencies.Route;\n}\n\nexport function setReactRouterV4V5SSRDependencies(newDependencies: Pick<ReactRouterV4V5Dependencies, 'Route'>): void {\n Route = newDependencies.Route;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/router/v6/dependencies.ts"],"names":[],"mappings":";;;AAWW,QAAA,aAAa,GAAG,KAAK,CAAC;AAQjC,SAAgB,eAAe,CAAC,eAA0C,EAAE,OAAa;IACvF,qBAAa,GAAG,IAAI,CAAC;IAErB,YAAI,GAAG,OAAO,CAAC;IACf,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;AATD,0CASC;AAED,SAAgB,+BAA+B,CAAC,eAA0D;IACxG,cAAM,GAAG,eAAe,CAAC,MAAM,CAAC;AAClC,CAAC;AAFD,0EAEC","sourcesContent":["import type { Faro } from '@grafana/faro-web-sdk';\n\nimport type {\n ReactRouterV6CreateRoutesFromChildren,\n ReactRouterV6Dependencies,\n ReactRouterV6MatchRoutes,\n ReactRouterV6RoutesShape,\n ReactRouterV6UseLocation,\n ReactRouterV6UseNavigationType,\n} from './types';\n\nexport let isInitialized = false;\nexport let faro: Faro;\nexport let createRoutesFromChildren: ReactRouterV6CreateRoutesFromChildren;\nexport let matchRoutes: ReactRouterV6MatchRoutes;\nexport let Routes: ReactRouterV6RoutesShape;\nexport let useLocation: ReactRouterV6UseLocation;\nexport let useNavigationType: ReactRouterV6UseNavigationType;\n\nexport function setDependencies(newDependencies: ReactRouterV6Dependencies, newFaro: Faro): void {\n isInitialized = true;\n\n faro = newFaro;\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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../src/router/v4v5/dependencies.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,IAAI,aAAa,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,IAAI,IAAU,CAAC;AACtB,MAAM,CAAC,IAAI,OAA2B,CAAC;AACvC,MAAM,CAAC,IAAI,KAAgC,CAAC;AAE5C,MAAM,UAAU,eAAe,CAAC,YAAyC,EAAE,OAAa;IACtF,aAAa,GAAG,IAAI,CAAC;IAErB,IAAI,GAAG,OAAO,CAAC;IACf,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;IAC/B,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,eAA2D;IAC3G,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;AAChC,CAAC","sourcesContent":["import type { Faro } from '@grafana/faro-web-sdk';\n\nimport type { ReactRouterHistory } from '../types';\nimport type { ReactRouterV4V5Dependencies, ReactRouterV4V5RouteShape } from './types';\n\nexport let isInitialized = false;\nexport let faro: Faro;\nexport let history: ReactRouterHistory;\nexport let Route: ReactRouterV4V5RouteShape;\n\nexport function setDependencies(dependencies: ReactRouterV4V5Dependencies, newFaro: Faro): void {\n isInitialized = true;\n\n faro = newFaro;\n history = dependencies.history;\n Route = dependencies.Route;\n}\n\nexport function setReactRouterV4V5SSRDependencies(newDependencies: Pick<ReactRouterV4V5Dependencies, 'Route'>): void {\n Route = newDependencies.Route;\n}\n"]}