@grafana/faro-react 2.3.1 → 2.5.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 (40) hide show
  1. package/dist/bundle/faro-react.iife.js +1 -1
  2. package/dist/bundle/types/profiler/FaroProfiler.d.ts +1 -1
  3. package/dist/bundle/types/profiler/FaroProfiler.test.d.ts +1 -0
  4. package/dist/cjs/errorBoundary/FaroErrorBoundary.js +31 -49
  5. package/dist/cjs/errorBoundary/FaroErrorBoundary.js.map +1 -1
  6. package/dist/cjs/errorBoundary/withFaroErrorBoundary.js +8 -19
  7. package/dist/cjs/errorBoundary/withFaroErrorBoundary.js.map +1 -1
  8. package/dist/cjs/instrumentation.js +12 -31
  9. package/dist/cjs/instrumentation.js.map +1 -1
  10. package/dist/cjs/profiler/FaroProfiler.js +63 -97
  11. package/dist/cjs/profiler/FaroProfiler.js.map +1 -1
  12. package/dist/cjs/profiler/FaroProfiler.test.js +75 -0
  13. package/dist/cjs/profiler/FaroProfiler.test.js.map +1 -0
  14. package/dist/cjs/profiler/withFaroProfiler.js +8 -19
  15. package/dist/cjs/profiler/withFaroProfiler.js.map +1 -1
  16. package/dist/cjs/router/initialize.js +8 -8
  17. package/dist/cjs/router/initialize.js.map +1 -1
  18. package/dist/cjs/router/v4v5/FaroRoute.js +4 -15
  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/initialize.js +12 -12
  23. package/dist/cjs/router/v4v5/initialize.js.map +1 -1
  24. package/dist/cjs/router/v6v7/FaroRoutes.js +16 -27
  25. package/dist/cjs/router/v6v7/FaroRoutes.js.map +1 -1
  26. package/dist/cjs/router/v6v7/initialize.js +8 -8
  27. package/dist/cjs/router/v6v7/initialize.js.map +1 -1
  28. package/dist/cjs/router/v6v7/utils.js +9 -9
  29. package/dist/cjs/router/v6v7/utils.js.map +1 -1
  30. package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js +13 -24
  31. package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js.map +1 -1
  32. package/dist/cjs/utils/reactVersion.js +2 -2
  33. package/dist/cjs/utils/reactVersion.js.map +1 -1
  34. package/dist/esm/profiler/FaroProfiler.js +18 -8
  35. package/dist/esm/profiler/FaroProfiler.js.map +1 -1
  36. package/dist/esm/profiler/FaroProfiler.test.js +73 -0
  37. package/dist/esm/profiler/FaroProfiler.test.js.map +1 -0
  38. package/dist/types/profiler/FaroProfiler.d.ts +1 -1
  39. package/dist/types/profiler/FaroProfiler.test.d.ts +1 -0
  40. package/package.json +7 -7
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependencies_1 = require("../dependencies");
4
+ const FaroProfiler_1 = require("./FaroProfiler");
5
+ describe('FaroProfiler', () => {
6
+ let mockSpan;
7
+ let mockChildSpan;
8
+ let startSpanCalls;
9
+ let setSpanMock;
10
+ let activeContextMock;
11
+ let withMock;
12
+ beforeEach(() => {
13
+ mockSpan = { end: jest.fn() };
14
+ mockChildSpan = { end: jest.fn() };
15
+ startSpanCalls = [];
16
+ let callIdx = 0;
17
+ const startSpan = jest.fn((name, options) => {
18
+ startSpanCalls.push({ name, options });
19
+ // First call is the mount span (from constructor); subsequent calls are children.
20
+ return callIdx++ === 0 ? mockSpan : mockChildSpan;
21
+ });
22
+ setSpanMock = jest.fn();
23
+ activeContextMock = jest.fn(() => ({}));
24
+ withMock = jest.fn((_ctx, fn) => fn());
25
+ const otelMock = {
26
+ trace: {
27
+ getTracer: () => ({ startSpan }),
28
+ setSpan: setSpanMock,
29
+ },
30
+ context: {
31
+ active: activeContextMock,
32
+ with: withMock,
33
+ },
34
+ };
35
+ const apiMock = {
36
+ isOTELInitialized: () => true,
37
+ getOTEL: () => otelMock,
38
+ };
39
+ const internalLoggerMock = { error: jest.fn(), warn: jest.fn(), info: jest.fn(), debug: jest.fn() };
40
+ (0, dependencies_1.setDependencies)(internalLoggerMock, apiMock);
41
+ });
42
+ it('does not pass Date.now() to span.end on mount (lets OTel stamp via monotonic hrTime)', () => {
43
+ const dateNowSpy = jest.spyOn(Date, 'now');
44
+ const profiler = new FaroProfiler_1.FaroProfiler({ name: 'C', updateProps: {}, children: null });
45
+ profiler.componentDidMount();
46
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
47
+ // Critical assertion: span.end was called with no wall-clock timestamp argument.
48
+ // OTel's web SDK stamps the end time via its hrTime helper (performance.timeOrigin +
49
+ // performance.now()), which is monotonic. Passing Date.now() here would mix clocks
50
+ // with the mount span's start (auto-stamped by OTel from hrTime).
51
+ expect(mockSpan.end).toHaveBeenCalledWith();
52
+ expect(dateNowSpy).not.toHaveBeenCalled();
53
+ dateNowSpy.mockRestore();
54
+ });
55
+ it('does not pass Date.now() to componentRender child span on unmount', () => {
56
+ const dateNowSpy = jest.spyOn(Date, 'now');
57
+ const profiler = new FaroProfiler_1.FaroProfiler({ name: 'C', updateProps: {}, children: null });
58
+ profiler.componentDidMount();
59
+ dateNowSpy.mockClear();
60
+ profiler.componentWillUnmount();
61
+ // A componentRender child span should have been created.
62
+ const renderCall = startSpanCalls.find((c) => c.name === 'componentRender');
63
+ expect(renderCall).toBeTruthy();
64
+ // Critical: neither startTime nor endTime should be sourced from Date.now() (wall clock).
65
+ expect(dateNowSpy).not.toHaveBeenCalled();
66
+ // Both timestamps should be undefined (let OTel stamp from hrTime) or, if explicitly
67
+ // provided, derived from a monotonic source. The simplest fix uses undefined.
68
+ if (renderCall.options) {
69
+ expect(renderCall.options.startTime).toBeUndefined();
70
+ expect(renderCall.options.endTime).toBeUndefined();
71
+ }
72
+ dateNowSpy.mockRestore();
73
+ });
74
+ });
75
+ //# sourceMappingURL=FaroProfiler.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FaroProfiler.test.js","sourceRoot":"","sources":["../../../src/profiler/FaroProfiler.test.tsx"],"names":[],"mappings":";;AAAA,kDAAkD;AAElD,iDAA8C;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,QAA4B,CAAC;IACjC,IAAI,aAAiC,CAAC;IACtC,IAAI,cAAqD,CAAC;IAC1D,IAAI,WAAsB,CAAC;IAC3B,IAAI,iBAA4B,CAAC;IACjC,IAAI,QAAmB,CAAC;IAExB,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;QAC9B,aAAa,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;QACnC,cAAc,GAAG,EAAE,CAAC;QAEpB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,IAAY,EAAE,OAAY,EAAE,EAAE;YACvD,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YACvC,kFAAkF;YAClF,OAAO,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,WAAW,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACxB,iBAAiB,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAQ,CAAC,CAAC;QAC/C,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,IAAS,EAAE,EAAc,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAQ;YACpB,KAAK,EAAE;gBACL,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;gBAChC,OAAO,EAAE,WAAW;aACrB;YACD,OAAO,EAAE;gBACP,MAAM,EAAE,iBAAiB;gBACzB,IAAI,EAAE,QAAQ;aACf;SACF,CAAC;QAEF,MAAM,OAAO,GAAQ;YACnB,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI;YAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ;SACxB,CAAC;QAEF,MAAM,kBAAkB,GAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;QAEzG,IAAA,8BAAe,EAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,IAAI,2BAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAW,EAAE,CAAC,CAAC;QACzF,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAE7B,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,iFAAiF;QACjF,qFAAqF;QACrF,mFAAmF;QACnF,kEAAkE;QAClE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,oBAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAE1C,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,IAAI,2BAAY,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAW,EAAE,CAAC,CAAC;QACzF,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAE7B,UAAU,CAAC,SAAS,EAAE,CAAC;QACvB,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QAEhC,yDAAyD;QACzD,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC;QAC5E,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,CAAC;QAEhC,0FAA0F;QAC1F,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAE1C,qFAAqF;QACrF,8EAA8E;QAC9E,IAAI,UAAW,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,CAAC,UAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,aAAa,EAAE,CAAC;YACtD,MAAM,CAAC,UAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,CAAC;QACtD,CAAC;QAED,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { setDependencies } from '../dependencies';\n\nimport { FaroProfiler } from './FaroProfiler';\n\ndescribe('FaroProfiler', () => {\n let mockSpan: { end: jest.Mock };\n let mockChildSpan: { end: jest.Mock };\n let startSpanCalls: Array<{ name: string; options: any }>;\n let setSpanMock: jest.Mock;\n let activeContextMock: jest.Mock;\n let withMock: jest.Mock;\n\n beforeEach(() => {\n mockSpan = { end: jest.fn() };\n mockChildSpan = { end: jest.fn() };\n startSpanCalls = [];\n\n let callIdx = 0;\n const startSpan = jest.fn((name: string, options: any) => {\n startSpanCalls.push({ name, options });\n // First call is the mount span (from constructor); subsequent calls are children.\n return callIdx++ === 0 ? mockSpan : mockChildSpan;\n });\n\n setSpanMock = jest.fn();\n activeContextMock = jest.fn(() => ({}) as any);\n withMock = jest.fn((_ctx: any, fn: () => void) => fn());\n\n const otelMock: any = {\n trace: {\n getTracer: () => ({ startSpan }),\n setSpan: setSpanMock,\n },\n context: {\n active: activeContextMock,\n with: withMock,\n },\n };\n\n const apiMock: any = {\n isOTELInitialized: () => true,\n getOTEL: () => otelMock,\n };\n\n const internalLoggerMock: any = { error: jest.fn(), warn: jest.fn(), info: jest.fn(), debug: jest.fn() };\n\n setDependencies(internalLoggerMock, apiMock);\n });\n\n it('does not pass Date.now() to span.end on mount (lets OTel stamp via monotonic hrTime)', () => {\n const dateNowSpy = jest.spyOn(Date, 'now');\n\n const profiler = new FaroProfiler({ name: 'C', updateProps: {}, children: null as any });\n profiler.componentDidMount();\n\n expect(mockSpan.end).toHaveBeenCalledTimes(1);\n // Critical assertion: span.end was called with no wall-clock timestamp argument.\n // OTel's web SDK stamps the end time via its hrTime helper (performance.timeOrigin +\n // performance.now()), which is monotonic. Passing Date.now() here would mix clocks\n // with the mount span's start (auto-stamped by OTel from hrTime).\n expect(mockSpan.end).toHaveBeenCalledWith();\n expect(dateNowSpy).not.toHaveBeenCalled();\n\n dateNowSpy.mockRestore();\n });\n\n it('does not pass Date.now() to componentRender child span on unmount', () => {\n const dateNowSpy = jest.spyOn(Date, 'now');\n\n const profiler = new FaroProfiler({ name: 'C', updateProps: {}, children: null as any });\n profiler.componentDidMount();\n\n dateNowSpy.mockClear();\n profiler.componentWillUnmount();\n\n // A componentRender child span should have been created.\n const renderCall = startSpanCalls.find((c) => c.name === 'componentRender');\n expect(renderCall).toBeTruthy();\n\n // Critical: neither startTime nor endTime should be sourced from Date.now() (wall clock).\n expect(dateNowSpy).not.toHaveBeenCalled();\n\n // Both timestamps should be undefined (let OTel stamp from hrTime) or, if explicitly\n // provided, derived from a monotonic source. The simplest fix uses undefined.\n if (renderCall!.options) {\n expect(renderCall!.options.startTime).toBeUndefined();\n expect(renderCall!.options.endTime).toBeUndefined();\n }\n\n dateNowSpy.mockRestore();\n });\n});\n"]}
@@ -1,30 +1,19 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.withFaroProfiler = withFaroProfiler;
18
- var hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
19
- var react_1 = __importDefault(require("react"));
20
- var faro_core_1 = require("@grafana/faro-core");
21
- var FaroProfiler_1 = require("./FaroProfiler");
7
+ const hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
8
+ const react_1 = __importDefault(require("react"));
9
+ const faro_core_1 = require("@grafana/faro-core");
10
+ const FaroProfiler_1 = require("./FaroProfiler");
22
11
  function withFaroProfiler(WrappedComponent, options) {
23
12
  var _a, _b, _c;
24
- var componentDisplayName = (_c = (_b = (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : WrappedComponent.displayName) !== null && _b !== void 0 ? _b : WrappedComponent.name) !== null && _c !== void 0 ? _c : faro_core_1.unknownString;
25
- var Component = function (props) { return (react_1.default.createElement(FaroProfiler_1.FaroProfiler, { name: componentDisplayName, updateProps: props },
26
- react_1.default.createElement(WrappedComponent, __assign({}, props)))); };
27
- Component.displayName = "faroProfiler(".concat(componentDisplayName, ")");
13
+ const componentDisplayName = (_c = (_b = (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : WrappedComponent.displayName) !== null && _b !== void 0 ? _b : WrappedComponent.name) !== null && _c !== void 0 ? _c : faro_core_1.unknownString;
14
+ const Component = (props) => (react_1.default.createElement(FaroProfiler_1.FaroProfiler, { name: componentDisplayName, updateProps: props },
15
+ react_1.default.createElement(WrappedComponent, Object.assign({}, props))));
16
+ Component.displayName = `faroProfiler(${componentDisplayName})`;
28
17
  (0, hoist_non_react_statics_1.default)(Component, WrappedComponent);
29
18
  return Component;
30
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"withFaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/withFaroProfiler.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AASA,4CAiBC;AA1BD,oFAA2D;AAC3D,gDAA0B;AAG1B,gDAAmD;AAEnD,+CAA8C;AAG9C,SAAgB,gBAAgB,CAC9B,gBAAkC,EAClC,OAAgD;;IAEhD,IAAM,oBAAoB,GAAG,MAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,gBAAgB,CAAC,WAAW,mCAAI,gBAAgB,CAAC,IAAI,mCAAI,yBAAa,CAAC;IAErH,IAAM,SAAS,GAAU,UAAC,KAAQ,IAAK,OAAA,CACrC,8BAAC,2BAAY,IAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,KAAK;QAC1D,8BAAC,gBAAgB,eAAK,KAAK,EAAI,CAClB,CAChB,EAJsC,CAItC,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,uBAAgB,oBAAoB,MAAG,CAAC;IAEhE,IAAA,iCAAoB,EAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAElD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '@grafana/faro-core';\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
+ {"version":3,"file":"withFaroProfiler.js","sourceRoot":"","sources":["../../../src/profiler/withFaroProfiler.tsx"],"names":[],"mappings":";;;;;AASA,4CAiBC;AA1BD,sFAA2D;AAC3D,kDAA0B;AAG1B,kDAAmD;AAEnD,iDAA8C;AAG9C,SAAgB,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,yBAAa,CAAC;IAErH,MAAM,SAAS,GAAU,CAAC,KAAQ,EAAE,EAAE,CAAC,CACrC,8BAAC,2BAAY,IAAC,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,KAAK;QAC1D,8BAAC,gBAAgB,oBAAK,KAAK,EAAI,CAClB,CAChB,CAAC;IAEF,SAAS,CAAC,WAAW,GAAG,gBAAgB,oBAAoB,GAAG,CAAC;IAEhE,IAAA,iCAAoB,EAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAElD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '@grafana/faro-core';\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,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initializeReactRouterInstrumentation = initializeReactRouterInstrumentation;
4
- var dependencies_1 = require("../dependencies");
5
- var types_1 = require("./types");
6
- var v4v5_1 = require("./v4v5");
7
- var v6v7_1 = require("./v6v7");
4
+ const dependencies_1 = require("../dependencies");
5
+ const types_1 = require("./types");
6
+ const v4v5_1 = require("./v4v5");
7
+ const v6v7_1 = require("./v6v7");
8
8
  function initializeReactRouterInstrumentation(options) {
9
9
  var _a;
10
- var initMessage = 'Initializing React Router';
10
+ const initMessage = 'Initializing React Router';
11
11
  switch ((_a = options.router) === null || _a === void 0 ? void 0 : _a.version) {
12
12
  case types_1.ReactRouterVersion.V7:
13
13
  case types_1.ReactRouterVersion.V6:
14
- dependencies_1.internalLogger.debug("".concat(initMessage, " ").concat(options.router.version, " instrumentation"));
14
+ dependencies_1.internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);
15
15
  (0, v6v7_1.initializeReactRouterV6Instrumentation)(options.router.dependencies);
16
16
  break;
17
17
  case types_1.ReactRouterVersion.V7_data_router:
18
18
  case types_1.ReactRouterVersion.V6_data_router:
19
- dependencies_1.internalLogger.debug("".concat(initMessage, " ").concat(options.router.version, " data router instrumentation"));
19
+ dependencies_1.internalLogger.debug(`${initMessage} ${options.router.version} data router instrumentation`);
20
20
  (0, v6v7_1.initializeReactRouterV6DataRouterInstrumentation)(options.router.dependencies);
21
21
  break;
22
22
  case types_1.ReactRouterVersion.V5:
23
23
  case types_1.ReactRouterVersion.V4:
24
- dependencies_1.internalLogger.debug("".concat(initMessage, " ").concat(options.router.version, " instrumentation"));
24
+ dependencies_1.internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);
25
25
  (0, v4v5_1.initializeReactRouterV4V5Instrumentation)(options.router.dependencies);
26
26
  break;
27
27
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/router/initialize.ts"],"names":[],"mappings":";;AAOA,oFAyBC;AAhCD,gDAAiD;AAGjD,iCAA6C;AAC7C,+BAAkE;AAClE,+BAAkH;AAElH,SAAgB,oCAAoC,CAAC,OAA+B;;IAClF,IAAM,WAAW,GAAG,2BAA2B,CAAC;IAEhD,QAAQ,MAAA,OAAO,CAAC,MAAM,0CAAE,OAAO,EAAE,CAAC;QAChC,KAAK,0BAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,0BAAkB,CAAC,EAAE;YACxB,6BAAc,CAAC,KAAK,CAAC,UAAG,WAAW,cAAI,OAAO,CAAC,MAAM,CAAC,OAAO,qBAAkB,CAAC,CAAC;YACjF,IAAA,6CAAsC,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACpE,MAAM;QAER,KAAK,0BAAkB,CAAC,cAAc,CAAC;QACvC,KAAK,0BAAkB,CAAC,cAAc;YACpC,6BAAc,CAAC,KAAK,CAAC,UAAG,WAAW,cAAI,OAAO,CAAC,MAAM,CAAC,OAAO,iCAA8B,CAAC,CAAC;YAC7F,IAAA,uDAAgD,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC9E,MAAM;QAER,KAAK,0BAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,0BAAkB,CAAC,EAAE;YACxB,6BAAc,CAAC,KAAK,CAAC,UAAG,WAAW,cAAI,OAAO,CAAC,MAAM,CAAC,OAAO,qBAAkB,CAAC,CAAC;YACjF,IAAA,+CAAwC,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACtE,MAAM;QAER;YACE,6BAAc,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IACpF,CAAC;AACH,CAAC","sourcesContent":["import { internalLogger } from '../dependencies';\nimport type { ReactIntegrationConfig } from '../types';\n\nimport { ReactRouterVersion } from './types';\nimport { initializeReactRouterV4V5Instrumentation } from './v4v5';\nimport { initializeReactRouterV6DataRouterInstrumentation, initializeReactRouterV6Instrumentation } from './v6v7';\n\nexport function initializeReactRouterInstrumentation(options: ReactIntegrationConfig): void {\n const initMessage = 'Initializing React Router';\n\n switch (options.router?.version) {\n case ReactRouterVersion.V7:\n case ReactRouterVersion.V6:\n internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);\n initializeReactRouterV6Instrumentation(options.router.dependencies);\n break;\n\n case ReactRouterVersion.V7_data_router:\n case ReactRouterVersion.V6_data_router:\n internalLogger.debug(`${initMessage} ${options.router.version} data router instrumentation`);\n initializeReactRouterV6DataRouterInstrumentation(options.router.dependencies);\n break;\n\n case ReactRouterVersion.V5:\n case ReactRouterVersion.V4:\n internalLogger.debug(`${initMessage} ${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
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/router/initialize.ts"],"names":[],"mappings":";;AAOA,oFAyBC;AAhCD,kDAAiD;AAGjD,mCAA6C;AAC7C,iCAAkE;AAClE,iCAAkH;AAElH,SAAgB,oCAAoC,CAAC,OAA+B;;IAClF,MAAM,WAAW,GAAG,2BAA2B,CAAC;IAEhD,QAAQ,MAAA,OAAO,CAAC,MAAM,0CAAE,OAAO,EAAE,CAAC;QAChC,KAAK,0BAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,0BAAkB,CAAC,EAAE;YACxB,6BAAc,CAAC,KAAK,CAAC,GAAG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;YACjF,IAAA,6CAAsC,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACpE,MAAM;QAER,KAAK,0BAAkB,CAAC,cAAc,CAAC;QACvC,KAAK,0BAAkB,CAAC,cAAc;YACpC,6BAAc,CAAC,KAAK,CAAC,GAAG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,8BAA8B,CAAC,CAAC;YAC7F,IAAA,uDAAgD,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YAC9E,MAAM;QAER,KAAK,0BAAkB,CAAC,EAAE,CAAC;QAC3B,KAAK,0BAAkB,CAAC,EAAE;YACxB,6BAAc,CAAC,KAAK,CAAC,GAAG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;YACjF,IAAA,+CAAwC,EAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;YACtE,MAAM;QAER;YACE,6BAAc,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IACpF,CAAC;AACH,CAAC","sourcesContent":["import { internalLogger } from '../dependencies';\nimport type { ReactIntegrationConfig } from '../types';\n\nimport { ReactRouterVersion } from './types';\nimport { initializeReactRouterV4V5Instrumentation } from './v4v5';\nimport { initializeReactRouterV6DataRouterInstrumentation, initializeReactRouterV6Instrumentation } from './v6v7';\n\nexport function initializeReactRouterInstrumentation(options: ReactIntegrationConfig): void {\n const initMessage = 'Initializing React Router';\n\n switch (options.router?.version) {\n case ReactRouterVersion.V7:\n case ReactRouterVersion.V6:\n internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);\n initializeReactRouterV6Instrumentation(options.router.dependencies);\n break;\n\n case ReactRouterVersion.V7_data_router:\n case ReactRouterVersion.V6_data_router:\n internalLogger.debug(`${initMessage} ${options.router.version} data router instrumentation`);\n initializeReactRouterV6DataRouterInstrumentation(options.router.dependencies);\n break;\n\n case ReactRouterVersion.V5:\n case ReactRouterVersion.V4:\n internalLogger.debug(`${initMessage} ${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,28 +1,17 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
6
  exports.FaroRoute = FaroRoute;
18
- var react_1 = __importDefault(require("react"));
19
- var activeEvent_1 = require("./activeEvent");
20
- var routerDependencies_1 = require("./routerDependencies");
7
+ const react_1 = __importDefault(require("react"));
8
+ const activeEvent_1 = require("./activeEvent");
9
+ const routerDependencies_1 = require("./routerDependencies");
21
10
  function FaroRoute(props) {
22
11
  var _a;
23
12
  if ((_a = props === null || props === void 0 ? void 0 : props.computedMatch) === null || _a === void 0 ? void 0 : _a.isExact) {
24
13
  (0, activeEvent_1.setActiveEventRoute)(props.computedMatch.path);
25
14
  }
26
- return react_1.default.createElement(routerDependencies_1.Route, __assign({}, props));
15
+ return react_1.default.createElement(routerDependencies_1.Route, Object.assign({}, props));
27
16
  }
28
17
  //# sourceMappingURL=FaroRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FaroRoute.js","sourceRoot":"","sources":["../../../../src/router/v4v5/FaroRoute.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA,8BAMC;AAZD,gDAA0B;AAE1B,6CAAoD;AACpD,2DAA6C;AAG7C,SAAgB,SAAS,CAAC,KAAgC;;IACxD,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,0CAAE,OAAO,EAAE,CAAC;QAClC,IAAA,iCAAmB,EAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,8BAAC,0BAAK,eAAK,KAAK,EAAI,CAAC;AAC9B,CAAC","sourcesContent":["import React from 'react';\n\nimport { 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
+ {"version":3,"file":"FaroRoute.js","sourceRoot":"","sources":["../../../../src/router/v4v5/FaroRoute.tsx"],"names":[],"mappings":";;;;;AAMA,8BAMC;AAZD,kDAA0B;AAE1B,+CAAoD;AACpD,6DAA6C;AAG7C,SAAgB,SAAS,CAAC,KAAgC;;IACxD,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,aAAa,0CAAE,OAAO,EAAE,CAAC;QAClC,IAAA,iCAAmB,EAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,8BAAC,0BAAK,oBAAK,KAAK,EAAI,CAAC;AAC9B,CAAC","sourcesContent":["import React from 'react';\n\nimport { 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"]}
@@ -4,13 +4,13 @@ exports.activeEvent = void 0;
4
4
  exports.createNewActiveEvent = createNewActiveEvent;
5
5
  exports.setActiveEventRoute = setActiveEventRoute;
6
6
  exports.sendActiveEvent = sendActiveEvent;
7
- var faro_web_sdk_1 = require("@grafana/faro-web-sdk");
8
- var dependencies_1 = require("../../dependencies");
7
+ const faro_web_sdk_1 = require("@grafana/faro-web-sdk");
8
+ const dependencies_1 = require("../../dependencies");
9
9
  exports.activeEvent = undefined;
10
10
  function createNewActiveEvent(url) {
11
11
  exports.activeEvent = {
12
12
  route: '',
13
- url: url,
13
+ url,
14
14
  };
15
15
  return exports.activeEvent;
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"activeEvent.js","sourceRoot":"","sources":["../../../../src/router/v4v5/activeEvent.ts"],"names":[],"mappings":";;;AAQA,oDAOC;AAED,kDAIC;AAED,0CAIC;AA3BD,sDAA2D;AAE3D,mDAAyC;AAI9B,QAAA,WAAW,GAA2C,SAAS,CAAC;AAE3E,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,mBAAW,GAAG;QACZ,KAAK,EAAE,EAAE;QACT,GAAG,KAAA;KACJ,CAAC;IAEF,OAAO,mBAAW,CAAC;AACrB,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,IAAI,mBAAW,EAAE,CAAC;QAChB,mBAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,SAAgB,eAAe;IAC7B,kBAAG,CAAC,SAAS,CAAC,iCAAkB,EAAE,mBAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhF,mBAAW,GAAG,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import { EVENT_ROUTE_CHANGE } from '@grafana/faro-web-sdk';\n\nimport { 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(EVENT_ROUTE_CHANGE, 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":";;;AAQA,oDAOC;AAED,kDAIC;AAED,0CAIC;AA3BD,wDAA2D;AAE3D,qDAAyC;AAI9B,QAAA,WAAW,GAA2C,SAAS,CAAC;AAE3E,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,mBAAW,GAAG;QACZ,KAAK,EAAE,EAAE;QACT,GAAG;KACJ,CAAC;IAEF,OAAO,mBAAW,CAAC;AACrB,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,IAAI,mBAAW,EAAE,CAAC;QAChB,mBAAW,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,SAAgB,eAAe;IAC7B,kBAAG,CAAC,SAAS,CAAC,iCAAkB,EAAE,mBAAW,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhF,mBAAW,GAAG,SAAS,CAAC;AAC1B,CAAC","sourcesContent":["import { EVENT_ROUTE_CHANGE } from '@grafana/faro-web-sdk';\n\nimport { 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(EVENT_ROUTE_CHANGE, activeEvent, undefined, { skipDedupe: true });\n\n activeEvent = undefined;\n}\n"]}
@@ -6,21 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.initializeReactRouterV4V5Instrumentation = initializeReactRouterV4V5Instrumentation;
7
7
  exports.createReactRouterV4Options = createReactRouterV4Options;
8
8
  exports.createReactRouterV5Options = createReactRouterV5Options;
9
- var hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
10
- var faro_web_sdk_1 = require("@grafana/faro-web-sdk");
11
- var types_1 = require("../types");
12
- var activeEvent_1 = require("./activeEvent");
13
- var FaroRoute_1 = require("./FaroRoute");
14
- var routerDependencies_1 = require("./routerDependencies");
9
+ const hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
10
+ const faro_web_sdk_1 = require("@grafana/faro-web-sdk");
11
+ const types_1 = require("../types");
12
+ const activeEvent_1 = require("./activeEvent");
13
+ const FaroRoute_1 = require("./FaroRoute");
14
+ const routerDependencies_1 = require("./routerDependencies");
15
15
  function initializeReactRouterV4V5Instrumentation(dependencies) {
16
16
  var _a, _b, _c, _d;
17
- var Route = dependencies.Route;
18
- var componentDisplayName = (_a = Route.displayName) !== null && _a !== void 0 ? _a : Route.name;
19
- FaroRoute_1.FaroRoute.displayName = "faroRoute(".concat(componentDisplayName, ")");
17
+ const Route = dependencies.Route;
18
+ const componentDisplayName = (_a = Route.displayName) !== null && _a !== void 0 ? _a : Route.name;
19
+ FaroRoute_1.FaroRoute.displayName = `faroRoute(${componentDisplayName})`;
20
20
  (0, hoist_non_react_statics_1.default)(FaroRoute_1.FaroRoute, Route);
21
21
  (0, routerDependencies_1.setReactRouterV4V5Dependencies)(dependencies);
22
22
  (0, activeEvent_1.createNewActiveEvent)((_b = faro_web_sdk_1.globalObject.location) === null || _b === void 0 ? void 0 : _b.href);
23
- (_d = (_c = dependencies.history).listen) === null || _d === void 0 ? void 0 : _d.call(_c, function (_location, action) {
23
+ (_d = (_c = dependencies.history).listen) === null || _d === void 0 ? void 0 : _d.call(_c, (_location, action) => {
24
24
  var _a;
25
25
  if (action === types_1.NavigationType.Push || action === types_1.NavigationType.Pop) {
26
26
  (0, activeEvent_1.sendActiveEvent)();
@@ -31,13 +31,13 @@ function initializeReactRouterV4V5Instrumentation(dependencies) {
31
31
  function createReactRouterV4Options(dependencies) {
32
32
  return {
33
33
  version: types_1.ReactRouterVersion.V4,
34
- dependencies: dependencies,
34
+ dependencies,
35
35
  };
36
36
  }
37
37
  function createReactRouterV5Options(dependencies) {
38
38
  return {
39
39
  version: types_1.ReactRouterVersion.V5,
40
- dependencies: dependencies,
40
+ dependencies,
41
41
  };
42
42
  }
43
43
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v4v5/initialize.ts"],"names":[],"mappings":";;;;;AAaA,4FAiBC;AAED,gEAKC;AAED,gEAKC;AA5CD,oFAA2D;AAG3D,sDAAqD;AAGrD,kCAA8D;AAE9D,6CAAsE;AACtE,yCAAwC;AACxC,2DAAsE;AAGtE,SAAgB,wCAAwC,CAAC,YAAyC;;IAChG,IAAM,KAAK,GAAG,YAAY,CAAC,KAA0B,CAAC;IACtD,IAAM,oBAAoB,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,KAAK,CAAC,IAAI,CAAC;IAC5D,qBAA+B,CAAC,WAAW,GAAG,oBAAa,oBAAoB,MAAG,CAAC;IACpF,IAAA,iCAAoB,EAAC,qBAAS,EAAE,KAAK,CAAC,CAAC;IAEvC,IAAA,mDAA8B,EAAC,YAAY,CAAC,CAAC;IAE7C,IAAA,kCAAoB,EAAC,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;IAElD,MAAA,MAAA,YAAY,CAAC,OAAO,EAAC,MAAM,mDAAG,UAAC,SAAS,EAAE,MAAM;;QAC9C,IAAI,MAAM,KAAK,sBAAc,CAAC,IAAI,IAAI,MAAM,KAAK,sBAAc,CAAC,GAAG,EAAE,CAAC;YACpE,IAAA,6BAAe,GAAE,CAAC;YAElB,IAAA,kCAAoB,EAAC,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAyC;IAClF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY,cAAA;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAyC;IAClF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY,cAAA;KACb,CAAC;AACJ,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { FunctionComponent } from 'react';\n\nimport { globalObject } from '@grafana/faro-web-sdk';\n\nimport type { ReactRouterV4V5Config } from '../../types';\nimport { NavigationType, ReactRouterVersion } 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\nexport function createReactRouterV4Options(dependencies: ReactRouterV4V5Dependencies): ReactRouterV4V5Config {\n return {\n version: ReactRouterVersion.V4,\n dependencies,\n };\n}\n\nexport function createReactRouterV5Options(dependencies: ReactRouterV4V5Dependencies): ReactRouterV4V5Config {\n return {\n version: ReactRouterVersion.V5,\n dependencies,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v4v5/initialize.ts"],"names":[],"mappings":";;;;;AAaA,4FAiBC;AAED,gEAKC;AAED,gEAKC;AA5CD,sFAA2D;AAG3D,wDAAqD;AAGrD,oCAA8D;AAE9D,+CAAsE;AACtE,2CAAwC;AACxC,6DAAsE;AAGtE,SAAgB,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,qBAA+B,CAAC,WAAW,GAAG,aAAa,oBAAoB,GAAG,CAAC;IACpF,IAAA,iCAAoB,EAAC,qBAAS,EAAE,KAAK,CAAC,CAAC;IAEvC,IAAA,mDAA8B,EAAC,YAAY,CAAC,CAAC;IAE7C,IAAA,kCAAoB,EAAC,MAAA,2BAAY,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,sBAAc,CAAC,IAAI,IAAI,MAAM,KAAK,sBAAc,CAAC,GAAG,EAAE,CAAC;YACpE,IAAA,6BAAe,GAAE,CAAC;YAElB,IAAA,kCAAoB,EAAC,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAyC;IAClF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAyC;IAClF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { FunctionComponent } from 'react';\n\nimport { globalObject } from '@grafana/faro-web-sdk';\n\nimport type { ReactRouterV4V5Config } from '../../types';\nimport { NavigationType, ReactRouterVersion } 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\nexport function createReactRouterV4Options(dependencies: ReactRouterV4V5Dependencies): ReactRouterV4V5Config {\n return {\n version: ReactRouterVersion.V4,\n dependencies,\n };\n}\n\nexport function createReactRouterV5Options(dependencies: ReactRouterV4V5Dependencies): ReactRouterV4V5Config {\n return {\n version: ReactRouterVersion.V5,\n dependencies,\n };\n}\n"]}
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -45,31 +34,31 @@ var __importStar = (this && this.__importStar) || (function () {
45
34
  })();
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.FaroRoutes = FaroRoutes;
48
- var react_1 = __importStar(require("react"));
49
- var faro_web_sdk_1 = require("@grafana/faro-web-sdk");
50
- var dependencies_1 = require("../../dependencies");
51
- var types_1 = require("../types");
52
- var routerDependencies_1 = require("./routerDependencies");
53
- var utils_1 = require("./utils");
37
+ const react_1 = __importStar(require("react"));
38
+ const faro_web_sdk_1 = require("@grafana/faro-web-sdk");
39
+ const dependencies_1 = require("../../dependencies");
40
+ const types_1 = require("../types");
41
+ const routerDependencies_1 = require("./routerDependencies");
42
+ const utils_1 = require("./utils");
54
43
  function FaroRoutes(props) {
55
44
  var _a;
56
- var location = routerDependencies_1.useLocation === null || routerDependencies_1.useLocation === void 0 ? void 0 : (0, routerDependencies_1.useLocation)();
57
- var navigationType = routerDependencies_1.useNavigationType === null || routerDependencies_1.useNavigationType === void 0 ? void 0 : (0, routerDependencies_1.useNavigationType)();
58
- var routes = (0, react_1.useMemo)(function () { var _a; return (_a = routerDependencies_1.createRoutesFromChildren === null || routerDependencies_1.createRoutesFromChildren === void 0 ? void 0 : (0, routerDependencies_1.createRoutesFromChildren)(props.children)) !== null && _a !== void 0 ? _a : []; }, [props.children]);
59
- var lastRouteRef = (0, react_1.useRef)({});
60
- (0, react_1.useEffect)(function () {
45
+ const location = routerDependencies_1.useLocation === null || routerDependencies_1.useLocation === void 0 ? void 0 : (0, routerDependencies_1.useLocation)();
46
+ const navigationType = routerDependencies_1.useNavigationType === null || routerDependencies_1.useNavigationType === void 0 ? void 0 : (0, routerDependencies_1.useNavigationType)();
47
+ const routes = (0, react_1.useMemo)(() => { var _a; return (_a = routerDependencies_1.createRoutesFromChildren === null || routerDependencies_1.createRoutesFromChildren === void 0 ? void 0 : (0, routerDependencies_1.createRoutesFromChildren)(props.children)) !== null && _a !== void 0 ? _a : []; }, [props.children]);
48
+ const lastRouteRef = (0, react_1.useRef)({});
49
+ (0, react_1.useEffect)(() => {
61
50
  var _a, _b;
62
51
  if (routerDependencies_1.isInitialized && (navigationType === types_1.NavigationType.Push || navigationType === types_1.NavigationType.Pop)) {
63
- var route = (0, utils_1.getRouteFromLocation)(routes, location);
64
- var url = (_a = faro_web_sdk_1.globalObject.location) === null || _a === void 0 ? void 0 : _a.href;
65
- dependencies_1.api.pushEvent(faro_web_sdk_1.EVENT_ROUTE_CHANGE, __assign({ toRoute: route, toUrl: (_b = faro_web_sdk_1.globalObject.location) === null || _b === void 0 ? void 0 : _b.href }, lastRouteRef.current));
52
+ const route = (0, utils_1.getRouteFromLocation)(routes, location);
53
+ const url = (_a = faro_web_sdk_1.globalObject.location) === null || _a === void 0 ? void 0 : _a.href;
54
+ dependencies_1.api.pushEvent(faro_web_sdk_1.EVENT_ROUTE_CHANGE, Object.assign({ toRoute: route, toUrl: (_b = faro_web_sdk_1.globalObject.location) === null || _b === void 0 ? void 0 : _b.href }, lastRouteRef.current));
66
55
  lastRouteRef.current = {
67
56
  fromRoute: route,
68
57
  fromUrl: url,
69
58
  };
70
59
  }
71
60
  }, [location, navigationType, routes]);
72
- var ActualRoutes = (_a = props.routesComponent) !== null && _a !== void 0 ? _a : routerDependencies_1.Routes;
73
- return react_1.default.createElement(ActualRoutes, __assign({}, props));
61
+ const ActualRoutes = (_a = props.routesComponent) !== null && _a !== void 0 ? _a : routerDependencies_1.Routes;
62
+ return react_1.default.createElement(ActualRoutes, Object.assign({}, props));
74
63
  }
75
64
  //# sourceMappingURL=FaroRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FaroRoutes.js","sourceRoot":"","sources":["../../../../src/router/v6v7/FaroRoutes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,gCA6BC;AAxCD,6CAA0D;AAE1D,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,8BAAC,YAAY,eAAK,KAAK,EAAI,CAAC;AACrC,CAAC","sourcesContent":["import React, { 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
+ {"version":3,"file":"FaroRoutes.js","sourceRoot":"","sources":["../../../../src/router/v6v7/FaroRoutes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,gCA6BC;AAxCD,+CAA0D;AAE1D,wDAAyE;AAEzE,qDAAyC;AACzC,oCAA0C;AAE1C,6DAAuH;AAEvH,mCAA+C;AAE/C,SAAgB,UAAU,CAAC,KAA+B;;IACxD,MAAM,QAAQ,GAAG,gCAAW,aAAX,gCAAW,2BAAX,gCAAW,GAAI,CAAC;IACjC,MAAM,cAAc,GAAG,sCAAiB,aAAjB,sCAAiB,2BAAjB,sCAAiB,GAAI,CAAC;IAE7C,MAAM,MAAM,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,WAAC,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,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiC,EAAE,CAAC,CAAC;IAEhE,IAAA,iBAAS,EAAC,GAAG,EAAE;;QACb,IAAI,kCAAa,IAAI,CAAC,cAAc,KAAK,sBAAc,CAAC,IAAI,IAAI,cAAc,KAAK,sBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACvG,MAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,MAAM,GAAG,GAAG,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,kBAAG,CAAC,SAAS,CAAC,iCAAkB,kBAC9B,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,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,eAAe,mCAAI,2BAAM,CAAC;IAErD,OAAO,8BAAC,YAAY,oBAAK,KAAK,EAAI,CAAC;AACrC,CAAC","sourcesContent":["import React, { 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"]}
@@ -9,10 +9,10 @@ exports.initializeReactRouterV6DataRouterInstrumentation = initializeReactRouter
9
9
  exports.createReactRouterV6DataOptions = createReactRouterV6DataOptions;
10
10
  exports.createReactRouterV7Options = createReactRouterV7Options;
11
11
  exports.createReactRouterV7DataOptions = createReactRouterV7DataOptions;
12
- var hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
13
- var types_1 = require("../types");
14
- var FaroRoutes_1 = require("./FaroRoutes");
15
- var routerDependencies_1 = require("./routerDependencies");
12
+ const hoist_non_react_statics_1 = __importDefault(require("hoist-non-react-statics"));
13
+ const types_1 = require("../types");
14
+ const FaroRoutes_1 = require("./FaroRoutes");
15
+ const routerDependencies_1 = require("./routerDependencies");
16
16
  function initializeReactRouterV6Instrumentation(dependencies) {
17
17
  (0, hoist_non_react_statics_1.default)(FaroRoutes_1.FaroRoutes, dependencies.Routes);
18
18
  (0, routerDependencies_1.setReactRouterV6Dependencies)(dependencies);
@@ -20,7 +20,7 @@ function initializeReactRouterV6Instrumentation(dependencies) {
20
20
  function createReactRouterV6Options(dependencies) {
21
21
  return {
22
22
  version: types_1.ReactRouterVersion.V6,
23
- dependencies: dependencies,
23
+ dependencies,
24
24
  };
25
25
  }
26
26
  function initializeReactRouterV6DataRouterInstrumentation(dependencies) {
@@ -29,19 +29,19 @@ function initializeReactRouterV6DataRouterInstrumentation(dependencies) {
29
29
  function createReactRouterV6DataOptions(dependencies) {
30
30
  return {
31
31
  version: types_1.ReactRouterVersion.V6_data_router,
32
- dependencies: dependencies,
32
+ dependencies,
33
33
  };
34
34
  }
35
35
  function createReactRouterV7Options(dependencies) {
36
36
  return {
37
37
  version: types_1.ReactRouterVersion.V7,
38
- dependencies: dependencies,
38
+ dependencies,
39
39
  };
40
40
  }
41
41
  function createReactRouterV7DataOptions(dependencies) {
42
42
  return {
43
43
  version: types_1.ReactRouterVersion.V7_data_router,
44
- dependencies: dependencies,
44
+ dependencies,
45
45
  };
46
46
  }
47
47
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6v7/initialize.ts"],"names":[],"mappings":";;;;;AAiBA,wFAGC;AAED,gEAKC;AAED,4GAIC;AAED,wEAOC;AAED,gEAKC;AAED,wEAOC;AA1DD,oFAA2D;AAQ3D,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;AAED,SAAgB,0BAA0B,CAAC,YAAuC;IAChF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY,cAAA;KACb,CAAC;AACJ,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 {\n ReactRouterV6Config,\n ReactRouterV6DataRouterConfig,\n ReactRouterV7Config,\n ReactRouterV7DataRouterConfig,\n} 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\nexport function createReactRouterV7Options(dependencies: ReactRouterV6Dependencies): ReactRouterV7Config {\n return {\n version: ReactRouterVersion.V7,\n dependencies,\n };\n}\n\nexport function createReactRouterV7DataOptions(\n dependencies: ReactRouterV6DataRouterDependencies\n): ReactRouterV7DataRouterConfig {\n return {\n version: ReactRouterVersion.V7_data_router,\n dependencies,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/router/v6v7/initialize.ts"],"names":[],"mappings":";;;;;AAiBA,wFAGC;AAED,gEAKC;AAED,4GAIC;AAED,wEAOC;AAED,gEAKC;AAED,wEAOC;AA1DD,sFAA2D;AAQ3D,oCAA8C;AAE9C,6CAA0C;AAC1C,6DAG8B;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;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;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,0BAA0B,CAAC,YAAuC;IAChF,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,EAAE;QAC9B,YAAY;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,8BAA8B,CAC5C,YAAiD;IAEjD,OAAO;QACL,OAAO,EAAE,0BAAkB,CAAC,cAAc;QAC1C,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport type {\n ReactRouterV6Config,\n ReactRouterV6DataRouterConfig,\n ReactRouterV7Config,\n ReactRouterV7DataRouterConfig,\n} 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\nexport function createReactRouterV7Options(dependencies: ReactRouterV6Dependencies): ReactRouterV7Config {\n return {\n version: ReactRouterVersion.V7,\n dependencies,\n };\n}\n\nexport function createReactRouterV7DataOptions(\n dependencies: ReactRouterV6DataRouterDependencies\n): ReactRouterV7DataRouterConfig {\n return {\n version: ReactRouterVersion.V7_data_router,\n dependencies,\n };\n}\n"]}
@@ -2,27 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNumberOfUrlSegments = getNumberOfUrlSegments;
4
4
  exports.getRouteFromLocation = getRouteFromLocation;
5
- var routerDependencies_1 = require("./routerDependencies");
5
+ const routerDependencies_1 = require("./routerDependencies");
6
6
  function getNumberOfUrlSegments(url) {
7
- return url.split(/\\?\//).filter(function (currentSegment) { return currentSegment.length > 0 && currentSegment !== ','; }).length;
7
+ return url.split(/\\?\//).filter((currentSegment) => currentSegment.length > 0 && currentSegment !== ',').length;
8
8
  }
9
9
  function getRouteFromLocation(routes, location) {
10
10
  if (!routes || routes.length === 0) {
11
11
  return location.pathname;
12
12
  }
13
- var matchedRoutes = (0, routerDependencies_1.matchRoutes)(routes, location);
14
- var pathBuilder = '';
13
+ const matchedRoutes = (0, routerDependencies_1.matchRoutes)(routes, location);
14
+ let pathBuilder = '';
15
15
  if (matchedRoutes) {
16
- for (var x = 0; x < matchedRoutes.length; x++) {
17
- var branch = matchedRoutes[x];
18
- var route = branch.route;
16
+ for (let x = 0; x < matchedRoutes.length; x++) {
17
+ const branch = matchedRoutes[x];
18
+ const route = branch.route;
19
19
  if (route) {
20
20
  if (route.index) {
21
21
  return branch.pathname;
22
22
  }
23
- var path = route.path;
23
+ let path = route.path;
24
24
  if (path) {
25
- path = path.startsWith('/') ? path : "/".concat(path);
25
+ path = path.startsWith('/') ? path : `/${path}`;
26
26
  pathBuilder += path;
27
27
  if (branch.pathname === location.pathname) {
28
28
  if (getNumberOfUrlSegments(pathBuilder) !== getNumberOfUrlSegments(branch.pathname)) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6v7/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
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/router/v6v7/utils.ts"],"names":[],"mappings":";;AAKA,wDAEC;AAED,oDAuCC;AA9CD,6DAAmD;AAGnD,SAAgB,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,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,MAAM,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,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,36 +1,25 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.withFaroRouterInstrumentation = withFaroRouterInstrumentation;
15
- var faro_web_sdk_1 = require("@grafana/faro-web-sdk");
16
- var dependencies_1 = require("../../dependencies");
17
- var types_1 = require("../types");
18
- var routerDependencies_1 = require("./routerDependencies");
19
- var utils_1 = require("./utils");
4
+ const faro_web_sdk_1 = require("@grafana/faro-web-sdk");
5
+ const dependencies_1 = require("../../dependencies");
6
+ const types_1 = require("../types");
7
+ const routerDependencies_1 = require("./routerDependencies");
8
+ const utils_1 = require("./utils");
20
9
  /**
21
10
  * To use with React Router 6.4 data APIs.
22
11
  */
23
12
  function withFaroRouterInstrumentation(router) {
24
- var lastRoute = {};
25
- router.subscribe(function (state) {
13
+ let lastRoute = {};
14
+ router.subscribe((state) => {
26
15
  var _a, _b;
27
- var navigationType = state.historyAction;
28
- var location = state.location;
29
- var routes = router.routes;
16
+ const navigationType = state.historyAction;
17
+ const location = state.location;
18
+ const routes = router.routes;
30
19
  if (routerDependencies_1.isInitialized && (navigationType === types_1.NavigationType.Push || navigationType === types_1.NavigationType.Pop)) {
31
- var route = (0, utils_1.getRouteFromLocation)(routes, location);
32
- var url = (_a = faro_web_sdk_1.globalObject.location) === null || _a === void 0 ? void 0 : _a.href;
33
- dependencies_1.api.pushEvent(faro_web_sdk_1.EVENT_ROUTE_CHANGE, __assign({ toRoute: route, toUrl: (_b = faro_web_sdk_1.globalObject.location) === null || _b === void 0 ? void 0 : _b.href }, lastRoute));
20
+ const route = (0, utils_1.getRouteFromLocation)(routes, location);
21
+ const url = (_a = faro_web_sdk_1.globalObject.location) === null || _a === void 0 ? void 0 : _a.href;
22
+ dependencies_1.api.pushEvent(faro_web_sdk_1.EVENT_ROUTE_CHANGE, Object.assign({ toRoute: route, toUrl: (_b = faro_web_sdk_1.globalObject.location) === null || _b === void 0 ? void 0 : _b.href }, lastRoute));
34
23
  lastRoute = {
35
24
  fromRoute: route,
36
25
  fromUrl: url,
@@ -1 +1 @@
1
- {"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6v7/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
+ {"version":3,"file":"withFaroRouterInstrumentation.js","sourceRoot":"","sources":["../../../../src/router/v6v7/withFaroRouterInstrumentation.ts"],"names":[],"mappings":";;AAwBA,sEA0BC;AAlDD,wDAAyE;AAEzE,qDAAyC;AACzC,oCAA0C;AAG1C,6DAAqD;AAErD,mCAA+C;AAa/C;;GAEG;AACH,SAAgB,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,kCAAa,IAAI,CAAC,cAAc,KAAK,sBAAc,CAAC,IAAI,IAAI,cAAc,KAAK,sBAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACvG,MAAM,KAAK,GAAG,IAAA,4BAAoB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACrD,MAAM,GAAG,GAAG,MAAA,2BAAY,CAAC,QAAQ,0CAAE,IAAI,CAAC;YAExC,kBAAG,CAAC,SAAS,CAAC,iCAAkB,kBAC9B,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"]}