@grafana/faro-react 2.9.0 → 2.11.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.
- package/dist/bundle/faro-react.iife.js +11 -8
- package/dist/bundle/faro-react.iife.js.map +1 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +13 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +26 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +15 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +10 -0
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +17 -0
- package/dist/cjs/_virtual/_rolldown/runtime.js +24 -0
- package/dist/cjs/dependencies.js +20 -4
- package/dist/cjs/dependencies.js.map +1 -1
- package/dist/cjs/errorBoundary/FaroErrorBoundary.js +62 -67
- package/dist/cjs/errorBoundary/FaroErrorBoundary.js.map +1 -1
- package/dist/cjs/errorBoundary/const.js +7 -4
- package/dist/cjs/errorBoundary/const.js.map +1 -1
- package/dist/cjs/errorBoundary/index.js +6 -8
- package/dist/cjs/errorBoundary/types.js +0 -1
- package/dist/cjs/errorBoundary/withFaroErrorBoundary.js +17 -15
- package/dist/cjs/errorBoundary/withFaroErrorBoundary.js.map +1 -1
- package/dist/cjs/index.js +480 -109
- package/dist/cjs/instrumentation.js +19 -16
- package/dist/cjs/instrumentation.js.map +1 -1
- package/dist/cjs/profiler/FaroProfiler.js +75 -97
- package/dist/cjs/profiler/FaroProfiler.js.map +1 -1
- package/dist/cjs/profiler/index.js +4 -6
- package/dist/cjs/profiler/withFaroProfiler.js +20 -15
- package/dist/cjs/profiler/withFaroProfiler.js.map +1 -1
- package/dist/cjs/router/index.js +26 -21
- package/dist/cjs/router/initialize.js +30 -26
- package/dist/cjs/router/initialize.js.map +1 -1
- package/dist/cjs/router/types.js +20 -16
- package/dist/cjs/router/types.js.map +1 -1
- package/dist/cjs/router/v4v5/FaroRoute.js +12 -12
- package/dist/cjs/router/v4v5/FaroRoute.js.map +1 -1
- package/dist/cjs/router/v4v5/activeEvent.js +23 -17
- package/dist/cjs/router/v4v5/activeEvent.js.map +1 -1
- package/dist/cjs/router/v4v5/index.js +8 -10
- package/dist/cjs/router/v4v5/initialize.js +36 -34
- package/dist/cjs/router/v4v5/initialize.js.map +1 -1
- package/dist/cjs/router/v4v5/routerDependencies.js +30 -8
- package/dist/cjs/router/v4v5/routerDependencies.js.map +1 -1
- package/dist/cjs/router/v4v5/types.js +0 -1
- package/dist/cjs/router/v6v7/FaroRoutes.js +42 -59
- package/dist/cjs/router/v6v7/FaroRoutes.js.map +1 -1
- package/dist/cjs/router/v6v7/index.js +14 -16
- package/dist/cjs/router/v6v7/initialize.js +34 -32
- package/dist/cjs/router/v6v7/initialize.js.map +1 -1
- package/dist/cjs/router/v6v7/routerDependencies.js +59 -16
- package/dist/cjs/router/v6v7/routerDependencies.js.map +1 -1
- package/dist/cjs/router/v6v7/types.js +0 -1
- package/dist/cjs/router/v6v7/utils.js +27 -32
- package/dist/cjs/router/v6v7/utils.js.map +1 -1
- package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js +32 -25
- package/dist/cjs/router/v6v7/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/utils/index.js +9 -11
- package/dist/cjs/utils/reactVersion.js +24 -18
- package/dist/cjs/utils/reactVersion.js.map +1 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.js +12 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js +25 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPrimitive.js +14 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.js +9 -0
- package/dist/esm/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/typeof.js +11 -0
- package/dist/esm/dependencies.js +9 -5
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/errorBoundary/FaroErrorBoundary.js +61 -66
- package/dist/esm/errorBoundary/FaroErrorBoundary.js.map +1 -1
- package/dist/esm/errorBoundary/const.js +7 -3
- package/dist/esm/errorBoundary/const.js.map +1 -1
- package/dist/esm/errorBoundary/index.js +4 -4
- package/dist/esm/errorBoundary/types.js +0 -2
- package/dist/esm/errorBoundary/withFaroErrorBoundary.js +15 -12
- package/dist/esm/errorBoundary/withFaroErrorBoundary.js.map +1 -1
- package/dist/esm/index.js +21 -7
- package/dist/esm/instrumentation.js +20 -15
- package/dist/esm/instrumentation.js.map +1 -1
- package/dist/esm/profiler/FaroProfiler.js +74 -96
- package/dist/esm/profiler/FaroProfiler.js.map +1 -1
- package/dist/esm/profiler/index.js +3 -3
- package/dist/esm/profiler/withFaroProfiler.js +18 -12
- package/dist/esm/profiler/withFaroProfiler.js.map +1 -1
- package/dist/esm/router/index.js +12 -5
- package/dist/esm/router/initialize.js +31 -26
- package/dist/esm/router/initialize.js.map +1 -1
- package/dist/esm/router/types.js +19 -15
- package/dist/esm/router/types.js.map +1 -1
- package/dist/esm/router/v4v5/FaroRoute.js +11 -9
- package/dist/esm/router/v4v5/FaroRoute.js.map +1 -1
- package/dist/esm/router/v4v5/activeEvent.js +18 -16
- package/dist/esm/router/v4v5/activeEvent.js.map +1 -1
- package/dist/esm/router/v4v5/index.js +4 -4
- package/dist/esm/router/v4v5/initialize.js +35 -31
- package/dist/esm/router/v4v5/initialize.js.map +1 -1
- package/dist/esm/router/v4v5/routerDependencies.js +13 -9
- package/dist/esm/router/v4v5/routerDependencies.js.map +1 -1
- package/dist/esm/router/v4v5/types.js +0 -2
- package/dist/esm/router/v6v7/FaroRoutes.js +41 -26
- package/dist/esm/router/v6v7/FaroRoutes.js.map +1 -1
- package/dist/esm/router/v6v7/index.js +5 -5
- package/dist/esm/router/v6v7/initialize.js +33 -29
- package/dist/esm/router/v6v7/initialize.js.map +1 -1
- package/dist/esm/router/v6v7/routerDependencies.js +24 -20
- package/dist/esm/router/v6v7/routerDependencies.js.map +1 -1
- package/dist/esm/router/v6v7/types.js +0 -2
- package/dist/esm/router/v6v7/utils.js +28 -32
- package/dist/esm/router/v6v7/utils.js.map +1 -1
- package/dist/esm/router/v6v7/withFaroRouterInstrumentation.js +33 -25
- package/dist/esm/router/v6v7/withFaroRouterInstrumentation.js.map +1 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/utils/index.js +2 -2
- package/dist/esm/utils/reactVersion.js +20 -17
- package/dist/esm/utils/reactVersion.js.map +1 -1
- package/dist/types/dependencies.d.ts +7 -4
- package/dist/types/errorBoundary/FaroErrorBoundary.d.ts +15 -13
- package/dist/types/errorBoundary/const.d.ts +5 -2
- package/dist/types/errorBoundary/index.d.ts +5 -4
- package/dist/types/errorBoundary/types.d.ts +20 -17
- package/dist/types/errorBoundary/withFaroErrorBoundary.d.ts +6 -3
- package/dist/types/index.d.ts +24 -11
- package/dist/types/instrumentation.d.ts +11 -8
- package/dist/types/profiler/FaroProfiler.d.ts +24 -22
- package/dist/types/profiler/index.d.ts +3 -3
- package/dist/types/profiler/withFaroProfiler.d.ts +6 -3
- package/dist/types/router/index.d.ts +14 -7
- package/dist/types/router/initialize.d.ts +5 -2
- package/dist/types/router/types.d.ts +23 -20
- package/dist/types/router/v4v5/FaroRoute.d.ts +6 -3
- package/dist/types/router/v4v5/activeEvent.d.ts +8 -5
- package/dist/types/router/v4v5/index.d.ts +5 -4
- package/dist/types/router/v4v5/initialize.d.ts +8 -5
- package/dist/types/router/v4v5/routerDependencies.d.ts +10 -7
- package/dist/types/router/v4v5/types.d.ts +16 -13
- package/dist/types/router/v6v7/FaroRoutes.d.ts +6 -3
- package/dist/types/router/v6v7/index.d.ts +6 -5
- package/dist/types/router/v6v7/initialize.d.ts +11 -8
- package/dist/types/router/v6v7/routerDependencies.d.ts +14 -11
- package/dist/types/router/v6v7/types.d.ts +57 -58
- package/dist/types/router/v6v7/utils.d.ts +7 -4
- package/dist/types/router/v6v7/withFaroRouterInstrumentation.d.ts +11 -10
- package/dist/types/types.d.ts +24 -18
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/reactVersion.d.ts +11 -8
- package/package.json +17 -21
- package/dist/bundle/types/dependencies.d.ts +0 -4
- package/dist/bundle/types/errorBoundary/FaroErrorBoundary.d.ts +0 -14
- package/dist/bundle/types/errorBoundary/const.d.ts +0 -2
- package/dist/bundle/types/errorBoundary/index.d.ts +0 -4
- package/dist/bundle/types/errorBoundary/types.d.ts +0 -19
- package/dist/bundle/types/errorBoundary/withFaroErrorBoundary.d.ts +0 -3
- package/dist/bundle/types/index.d.ts +0 -11
- package/dist/bundle/types/instrumentation.d.ts +0 -9
- package/dist/bundle/types/profiler/FaroProfiler.d.ts +0 -24
- package/dist/bundle/types/profiler/FaroProfiler.test.d.ts +0 -1
- package/dist/bundle/types/profiler/index.d.ts +0 -3
- package/dist/bundle/types/profiler/withFaroProfiler.d.ts +0 -3
- package/dist/bundle/types/router/index.d.ts +0 -7
- package/dist/bundle/types/router/initialize.d.ts +0 -2
- package/dist/bundle/types/router/types.d.ts +0 -24
- package/dist/bundle/types/router/v4v5/FaroRoute.d.ts +0 -3
- package/dist/bundle/types/router/v4v5/activeEvent.d.ts +0 -5
- package/dist/bundle/types/router/v4v5/index.d.ts +0 -4
- package/dist/bundle/types/router/v4v5/initialize.d.ts +0 -5
- package/dist/bundle/types/router/v4v5/routerDependencies.d.ts +0 -7
- package/dist/bundle/types/router/v4v5/types.d.ts +0 -16
- package/dist/bundle/types/router/v6v7/FaroRoutes.d.ts +0 -3
- package/dist/bundle/types/router/v6v7/index.d.ts +0 -5
- package/dist/bundle/types/router/v6v7/initialize.d.ts +0 -8
- package/dist/bundle/types/router/v6v7/routerDependencies.d.ts +0 -11
- package/dist/bundle/types/router/v6v7/types.d.ts +0 -69
- package/dist/bundle/types/router/v6v7/utils.d.ts +0 -4
- package/dist/bundle/types/router/v6v7/withFaroRouterInstrumentation.d.ts +0 -17
- package/dist/bundle/types/types.d.ts +0 -24
- package/dist/bundle/types/utils/index.d.ts +0 -1
- package/dist/bundle/types/utils/reactVersion.d.ts +0 -8
- package/dist/cjs/errorBoundary/index.js.map +0 -1
- package/dist/cjs/errorBoundary/types.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/profiler/FaroProfiler.test.js +0 -75
- package/dist/cjs/profiler/FaroProfiler.test.js.map +0 -1
- package/dist/cjs/profiler/index.js.map +0 -1
- package/dist/cjs/router/index.js.map +0 -1
- package/dist/cjs/router/v4v5/index.js.map +0 -1
- package/dist/cjs/router/v4v5/types.js.map +0 -1
- package/dist/cjs/router/v6v7/index.js.map +0 -1
- package/dist/cjs/router/v6v7/types.js.map +0 -1
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/esm/errorBoundary/index.js.map +0 -1
- package/dist/esm/errorBoundary/types.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/profiler/FaroProfiler.test.js +0 -73
- package/dist/esm/profiler/FaroProfiler.test.js.map +0 -1
- package/dist/esm/profiler/index.js.map +0 -1
- package/dist/esm/router/index.js.map +0 -1
- package/dist/esm/router/v4v5/index.js.map +0 -1
- package/dist/esm/router/v4v5/types.js.map +0 -1
- package/dist/esm/router/v6v7/index.js.map +0 -1
- package/dist/esm/router/v6v7/types.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/types/profiler/FaroProfiler.test.d.ts +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { faroErrorBoundaryInitialState } from "./errorBoundary/const.js";
|
|
2
|
+
import { getMajorReactVersion, isReactVersionAtLeast, isReactVersionAtLeast16, isReactVersionAtLeast17, isReactVersionAtLeast18, isReactVersionAtLeast19, reactVersion, reactVersionMajor } from "./utils/reactVersion.js";
|
|
3
|
+
import "./utils/index.js";
|
|
4
|
+
import { FaroErrorBoundary } from "./errorBoundary/FaroErrorBoundary.js";
|
|
5
|
+
import { withFaroErrorBoundary } from "./errorBoundary/withFaroErrorBoundary.js";
|
|
6
|
+
import "./errorBoundary/index.js";
|
|
7
|
+
import { NavigationType, ReactRouterVersion } from "./router/types.js";
|
|
8
|
+
import { setReactRouterV4V5SSRDependencies } from "./router/v4v5/routerDependencies.js";
|
|
9
|
+
import { FaroRoute } from "./router/v4v5/FaroRoute.js";
|
|
10
|
+
import { createReactRouterV4Options, createReactRouterV5Options } from "./router/v4v5/initialize.js";
|
|
11
|
+
import { setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies } from "./router/v6v7/routerDependencies.js";
|
|
12
|
+
import { FaroRoutes } from "./router/v6v7/FaroRoutes.js";
|
|
13
|
+
import { createReactRouterV6DataOptions, createReactRouterV6Options, createReactRouterV7DataOptions, createReactRouterV7Options } from "./router/v6v7/initialize.js";
|
|
14
|
+
import { withFaroRouterInstrumentation } from "./router/v6v7/withFaroRouterInstrumentation.js";
|
|
15
|
+
import "./router/index.js";
|
|
16
|
+
import { ReactIntegration } from "./instrumentation.js";
|
|
17
|
+
import { FaroProfiler } from "./profiler/FaroProfiler.js";
|
|
18
|
+
import { withFaroProfiler } from "./profiler/withFaroProfiler.js";
|
|
19
|
+
import "./profiler/index.js";
|
|
20
|
+
import { BaseExtension, BaseInstrumentation, BaseTransport, ConsoleInstrumentation, ConsoleTransport, ErrorsInstrumentation, FetchTransport, InternalLoggerLevel, LogLevel, TransportItemType, VERSION, ViewInstrumentation, WebVitalsInstrumentation, allLogLevels, browserMeta, buildStackFrame, createInternalLogger, createPromiseBuffer, createSession, deepEqual, defaultEventDomain, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, faro, 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, makeCoreConfig, noop, parseStacktrace, setInternalFaroOnGlobalObject, transportItemTypeToBodyKey, userActionDataAttribute, userActionTimeoutDataAttribute } from "@grafana/faro-web-sdk";
|
|
21
|
+
export { BaseExtension, BaseInstrumentation, BaseTransport, ConsoleInstrumentation, ConsoleTransport, ErrorsInstrumentation, FaroErrorBoundary, FaroProfiler, FaroRoute, FaroRoutes, FetchTransport, InternalLoggerLevel, LogLevel, NavigationType, ReactIntegration, ReactRouterVersion, TransportItemType, VERSION, ViewInstrumentation, WebVitalsInstrumentation, allLogLevels, browserMeta, buildStackFrame, createInternalLogger, createPromiseBuffer, createReactRouterV4Options, createReactRouterV5Options, createReactRouterV6DataOptions, createReactRouterV6Options, createReactRouterV7DataOptions, createReactRouterV7Options, createSession, deepEqual, defaultEventDomain, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, faro, faroErrorBoundaryInitialState, genShortID, getCurrentTimestamp, getDataFromSafariExtensions, getInternalFaroFromGlobalObject, getMajorReactVersion, 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, isReactVersionAtLeast, isReactVersionAtLeast16, isReactVersionAtLeast17, isReactVersionAtLeast18, isReactVersionAtLeast19, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, makeCoreConfig, noop, parseStacktrace, reactVersion, reactVersionMajor, setInternalFaroOnGlobalObject, setReactRouterV4V5SSRDependencies, setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies, transportItemTypeToBodyKey, userActionDataAttribute, userActionTimeoutDataAttribute, withFaroErrorBoundary, withFaroProfiler, withFaroRouterInstrumentation };
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { setDependencies } from "./dependencies.js";
|
|
2
|
+
import { initializeReactRouterInstrumentation } from "./router/initialize.js";
|
|
3
|
+
import "./router/index.js";
|
|
4
|
+
import { BaseInstrumentation, VERSION } from "@grafana/faro-web-sdk";
|
|
5
|
+
//#region src/instrumentation.ts
|
|
6
|
+
var ReactIntegration = class extends BaseInstrumentation {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
super();
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.name = "@grafana/faro-react";
|
|
11
|
+
this.version = VERSION;
|
|
12
|
+
}
|
|
13
|
+
initialize() {
|
|
14
|
+
setDependencies(this.internalLogger, this.api);
|
|
15
|
+
initializeReactRouterInstrumentation(this.options);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ReactIntegration };
|
|
20
|
+
|
|
16
21
|
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","
|
|
1
|
+
{"version":3,"file":"instrumentation.js","names":[],"sources":["../../src/instrumentation.ts"],"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: string = 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"],"mappings":";;;;;AAMA,IAAa,mBAAb,cAAsC,oBAAoB;CAIxD,YAAY,UAA0C,CAAC,GAAG;EACxD,MAAM;EADY,KAAA,UAAA;EAHpB,KAAA,OAAO;EACP,KAAA,UAAkB;CAIlB;CAEA,aAAmB;EACjB,gBAAgB,KAAK,gBAAgB,KAAK,GAAG;EAC7C,qCAAqC,KAAK,OAAO;CACnD;AACF"}
|
|
@@ -1,97 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
componentDidUpdate() {
|
|
81
|
-
if (this.isOtelInitialized && this.updateSpan) {
|
|
82
|
-
this.updateSpan.end();
|
|
83
|
-
this.updateSpan = undefined;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
componentWillUnmount() {
|
|
87
|
-
if (this.isOtelInitialized && this.renderSpan) {
|
|
88
|
-
// End via OTel hrTime (monotonic). See `componentDidMount` for rationale.
|
|
89
|
-
this.renderSpan.end();
|
|
90
|
-
this.renderSpan = undefined;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
render() {
|
|
94
|
-
return this.props.children;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
1
|
+
import { api, internalLogger } from "../dependencies.js";
|
|
2
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/objectSpread2.js";
|
|
3
|
+
import { Component } from "react";
|
|
4
|
+
import { VERSION } from "@grafana/faro-web-sdk";
|
|
5
|
+
//#region src/profiler/FaroProfiler.tsx
|
|
6
|
+
var FaroProfiler = class extends Component {
|
|
7
|
+
get isOtelInitialized() {
|
|
8
|
+
return !!(api === null || api === void 0 ? void 0 : api.isOTELInitialized());
|
|
9
|
+
}
|
|
10
|
+
get otel() {
|
|
11
|
+
return api === null || api === void 0 ? void 0 : api.getOTEL();
|
|
12
|
+
}
|
|
13
|
+
get tracer() {
|
|
14
|
+
var _this$otel;
|
|
15
|
+
return (_this$otel = this.otel) === null || _this$otel === void 0 ? void 0 : _this$otel.trace.getTracer("@grafana/faro-react", VERSION);
|
|
16
|
+
}
|
|
17
|
+
createSpan(spanName, options) {
|
|
18
|
+
var _options$attributes, _this$otel2;
|
|
19
|
+
const span = this.tracer.startSpan(spanName, {
|
|
20
|
+
startTime: options === null || options === void 0 ? void 0 : options.startTime,
|
|
21
|
+
attributes: _objectSpread2({ "react.component.name": this.props.name }, (_options$attributes = options === null || options === void 0 ? void 0 : options.attributes) !== null && _options$attributes !== void 0 ? _options$attributes : {})
|
|
22
|
+
});
|
|
23
|
+
(_this$otel2 = this.otel) === null || _this$otel2 === void 0 || _this$otel2.trace.setSpan(this.otel.context.active(), span);
|
|
24
|
+
if (options === null || options === void 0 ? void 0 : options.endTime) span.end(options.endTime);
|
|
25
|
+
return span;
|
|
26
|
+
}
|
|
27
|
+
createChildSpan(spanName, parent, options) {
|
|
28
|
+
var _this$otel3;
|
|
29
|
+
let span;
|
|
30
|
+
(_this$otel3 = this.otel) === null || _this$otel3 === void 0 || _this$otel3.context.with(this.otel.trace.setSpan(this.otel.context.active(), parent), () => {
|
|
31
|
+
span = this.createSpan(spanName, options);
|
|
32
|
+
});
|
|
33
|
+
return span;
|
|
34
|
+
}
|
|
35
|
+
constructor(props) {
|
|
36
|
+
super(props);
|
|
37
|
+
this.mountSpan = void 0;
|
|
38
|
+
this.renderSpan = void 0;
|
|
39
|
+
this.updateSpan = void 0;
|
|
40
|
+
if (this.isOtelInitialized) this.mountSpan = this.createSpan("componentMount");
|
|
41
|
+
else internalLogger === null || internalLogger === void 0 || internalLogger.error("The Faro React Profiler requires tracing instrumentation. Please enable it in the \"instrumentations\" section of your config.");
|
|
42
|
+
}
|
|
43
|
+
componentDidMount() {
|
|
44
|
+
if (this.isOtelInitialized && this.mountSpan) {
|
|
45
|
+
this.mountSpan.end();
|
|
46
|
+
this.renderSpan = this.createChildSpan("componentRender", this.mountSpan);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
shouldComponentUpdate({ updateProps }) {
|
|
50
|
+
if (this.isOtelInitialized && this.mountSpan && updateProps !== this.props.updateProps) {
|
|
51
|
+
const changedProps = Object.keys(updateProps).filter((key) => updateProps[key] !== this.props.updateProps[key]);
|
|
52
|
+
if (changedProps.length > 0) this.updateSpan = this.createChildSpan("componentUpdate", this.mountSpan, { attributes: { "react.component.changed_props": changedProps } });
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
componentDidUpdate() {
|
|
57
|
+
if (this.isOtelInitialized && this.updateSpan) {
|
|
58
|
+
this.updateSpan.end();
|
|
59
|
+
this.updateSpan = void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
componentWillUnmount() {
|
|
63
|
+
if (this.isOtelInitialized && this.renderSpan) {
|
|
64
|
+
this.renderSpan.end();
|
|
65
|
+
this.renderSpan = void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return this.props.children;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { FaroProfiler };
|
|
74
|
+
|
|
97
75
|
//# sourceMappingURL=FaroProfiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FaroProfiler.js","
|
|
1
|
+
{"version":3,"file":"FaroProfiler.js","names":[],"sources":["../../../src/profiler/FaroProfiler.tsx"],"sourcesContent":["import type { Attributes, Span, Tracer } from '@opentelemetry/api';\n// React is required in scope for JSX transformation with the classic transform\n// @ts-expect-error - TS6133: React appears unused but is required for JSX\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport React, { 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 renderSpan: Span | 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 // Let OTel stamp the end via its hrTime helper (`performance.timeOrigin +\n // performance.now()`), which is monotonic. Passing `Date.now()` here would mix the\n // wall clock with the mount span's start time (auto-stamped by OTel from hrTime),\n // making `endTime - startTime` drift with NTP / DST / manual clock changes.\n this.mountSpan.end();\n\n // Start the `componentRender` span immediately. It covers the live, mounted lifetime\n // of the component and is ended in `componentWillUnmount`. By starting and ending it\n // without explicit timestamps, both boundaries are stamped from OTel hrTime\n // (monotonic). This avoids the wall-clock issues of the previous implementation\n // which captured `Date.now()` here and subtracted it from another `Date.now()` at\n // unmount — a problem that compounded over a long-lived component (router/app\n // shells can live for the entire session).\n this.renderSpan = this.createChildSpan('componentRender', this.mountSpan);\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.renderSpan) {\n // End via OTel hrTime (monotonic). See `componentDidMount` for rationale.\n this.renderSpan.end();\n this.renderSpan = undefined;\n }\n }\n\n override render(): ReactNode {\n return this.props.children;\n }\n}\n"],"mappings":";;;;;AAkBA,IAAa,eAAb,cAAkC,UAA6B;CAK7D,IAAY,oBAA6B;EACvC,OAAO,CAAC,EAAA,QAAA,QAAA,QAAA,KAAA,IAAA,KAAA,IAAC,IAAK,kBAAkB;CAClC;CAEA,IAAY,OAA4B;EACtC,OAAA,QAAA,QAAA,QAAA,KAAA,IAAA,KAAA,IAAO,IAAK,QAAQ;CACtB;CAEA,IAAY,SAAiB;;EAC3B,QAAA,aAAO,KAAK,UAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAA,WAAM,MAAM,UAAU,uBAAuB,OAAO;CAClE;CAEA,WACE,UACA,SACM;;EACN,MAAM,OAAO,KAAK,OAAO,UAAU,UAAU;GAC3C,WAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAW,QAAS;GACpB,YAAA,eAAA,EACE,wBAAwB,KAAK,MAAM,KAAA,IAAA,sBAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAC/B,QAAS,gBAAA,QAAA,wBAAA,KAAA,IAAA,sBAAc,CAAC,CAC9B;EACF,CAAC;EAED,CAAA,cAAA,KAAK,UAAA,QAAA,gBAAA,KAAA,KAAA,YAAM,MAAM,QAAQ,KAAK,KAAK,QAAQ,OAAO,GAAG,IAAI;EAEzD,IAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAI,QAAS,SACX,KAAK,IAAI,QAAQ,OAAO;EAG1B,OAAO;CACT;CAEA,gBACE,UACA,QACA,SACM;;EACN,IAAI;EAEJ,CAAA,cAAA,KAAK,UAAA,QAAA,gBAAA,KAAA,KAAA,YAAM,QAAQ,KAAK,KAAK,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,OAAO,GAAG,MAAM,SAAS;GACzF,OAAO,KAAK,WAAW,UAAU,OAAO;EAC1C,CAAC;EAED,OAAO;CACT;CAEA,YAAY,OAA0B;EACpC,MAAM,KAAK;EApDb,KAAU,YAA8B,KAAA;EACxC,KAAU,aAA+B,KAAA;EACzC,KAAU,aAA+B,KAAA;EAoDvC,IAAI,KAAK,mBACP,KAAK,YAAY,KAAK,WAAW,gBAAgB;OAEjD,mBAAA,QAAA,mBAAA,KAAA,KAAA,eAAgB,MACd,gIACF;CAEJ;CAEA,oBAAmC;EACjC,IAAI,KAAK,qBAAqB,KAAK,WAAW;GAK5C,KAAK,UAAU,IAAI;GASnB,KAAK,aAAa,KAAK,gBAAgB,mBAAmB,KAAK,SAAS;EAC1E;CACF;CAEA,sBAA+B,EAAE,eAA2C;EAC1E,IAAI,KAAK,qBAAqB,KAAK,aAAa,gBAAgB,KAAK,MAAM,aAAa;GACtF,MAAM,eAAe,OAAO,KAAK,WAAW,CAAC,CAAC,QAAQ,QAAQ,YAAY,SAAS,KAAK,MAAM,YAAY,IAAI;GAE9G,IAAI,aAAa,SAAS,GACxB,KAAK,aAAa,KAAK,gBAAgB,mBAAmB,KAAK,WAAW,EACxE,YAAY,EACV,iCAAiC,aACnC,EACF,CAAC;EAEL;EAEA,OAAO;CACT;CAEA,qBAAoC;EAClC,IAAI,KAAK,qBAAqB,KAAK,YAAY;GAC7C,KAAK,WAAW,IAAI;GACpB,KAAK,aAAa,KAAA;EACpB;CACF;CAEA,uBAAsC;EACpC,IAAI,KAAK,qBAAqB,KAAK,YAAY;GAE7C,KAAK,WAAW,IAAI;GACpB,KAAK,aAAa,KAAA;EACpB;CACF;CAEA,SAA6B;EAC3B,OAAO,KAAK,MAAM;CACpB;AACF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { FaroProfiler } from "./FaroProfiler.js";
|
|
2
|
+
import { withFaroProfiler } from "./withFaroProfiler.js";
|
|
3
|
+
export { FaroProfiler, withFaroProfiler };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from
|
|
3
|
-
import { unknownString } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { FaroProfiler } from "./FaroProfiler.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { unknownString } from "@grafana/faro-web-sdk";
|
|
4
|
+
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
5
|
+
//#region src/profiler/withFaroProfiler.tsx
|
|
6
|
+
function withFaroProfiler(WrappedComponent, options) {
|
|
7
|
+
var _ref, _ref2, _options$name;
|
|
8
|
+
const componentDisplayName = (_ref = (_ref2 = (_options$name = options === null || options === void 0 ? void 0 : options.name) !== null && _options$name !== void 0 ? _options$name : WrappedComponent.displayName) !== null && _ref2 !== void 0 ? _ref2 : WrappedComponent.name) !== null && _ref !== void 0 ? _ref : unknownString;
|
|
9
|
+
const Component = (props) => /* @__PURE__ */ React.createElement(FaroProfiler, {
|
|
10
|
+
name: componentDisplayName,
|
|
11
|
+
updateProps: props
|
|
12
|
+
}, /* @__PURE__ */ React.createElement(WrappedComponent, props));
|
|
13
|
+
Component.displayName = `faroProfiler(${componentDisplayName})`;
|
|
14
|
+
hoistNonReactStatics(Component, WrappedComponent);
|
|
15
|
+
return Component;
|
|
13
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { withFaroProfiler };
|
|
19
|
+
|
|
14
20
|
//# sourceMappingURL=withFaroProfiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFaroProfiler.js","
|
|
1
|
+
{"version":3,"file":"withFaroProfiler.js","names":[],"sources":["../../../src/profiler/withFaroProfiler.tsx"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\nimport type { ComponentType, FC } from 'react';\n\nimport { unknownString } from '@grafana/faro-web-sdk';\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"],"mappings":";;;;;AASA,SAAgB,iBACd,kBACA,SACO;;CACP,MAAM,wBAAA,QAAA,SAAA,gBAAA,YAAA,QAAA,YAAA,KAAA,IAAA,KAAA,IAAuB,QAAS,UAAA,QAAA,kBAAA,KAAA,IAAA,gBAAQ,iBAAiB,iBAAA,QAAA,UAAA,KAAA,IAAA,QAAe,iBAAiB,UAAA,QAAA,SAAA,KAAA,IAAA,OAAQ;CAEvG,MAAM,aAAoB,UACxB,sBAAA,cAAC,cAAD;EAAc,MAAM;EAAsB,aAAa;CAEzC,GADZ,sBAAA,cAAC,kBAAqB,KAAQ,CAClB;CAGhB,UAAU,cAAc,gBAAgB,qBAAqB;CAE7D,qBAAqB,WAAW,gBAAgB;CAEhD,OAAO;AACT"}
|
package/dist/esm/router/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { NavigationType, ReactRouterVersion } from "./types.js";
|
|
2
|
+
import { setReactRouterV4V5SSRDependencies } from "./v4v5/routerDependencies.js";
|
|
3
|
+
import { FaroRoute } from "./v4v5/FaroRoute.js";
|
|
4
|
+
import { createReactRouterV4Options, createReactRouterV5Options } from "./v4v5/initialize.js";
|
|
5
|
+
import "./v4v5/index.js";
|
|
6
|
+
import { setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies } from "./v6v7/routerDependencies.js";
|
|
7
|
+
import { FaroRoutes } from "./v6v7/FaroRoutes.js";
|
|
8
|
+
import { createReactRouterV6DataOptions, createReactRouterV6Options, createReactRouterV7DataOptions, createReactRouterV7Options } from "./v6v7/initialize.js";
|
|
9
|
+
import { withFaroRouterInstrumentation } from "./v6v7/withFaroRouterInstrumentation.js";
|
|
10
|
+
import "./v6v7/index.js";
|
|
11
|
+
import { initializeReactRouterInstrumentation } from "./initialize.js";
|
|
12
|
+
export { FaroRoute, FaroRoutes, NavigationType, ReactRouterVersion, createReactRouterV4Options, createReactRouterV5Options, createReactRouterV6DataOptions, createReactRouterV6Options, createReactRouterV7DataOptions, createReactRouterV7Options, initializeReactRouterInstrumentation, setReactRouterV4V5SSRDependencies, setReactRouterV6SSRDependencies, setReactRouterV7SSRDependencies, withFaroRouterInstrumentation };
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import { internalLogger } from
|
|
2
|
-
import
|
|
3
|
-
import { initializeReactRouterV4V5Instrumentation } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { internalLogger } from "../dependencies.js";
|
|
2
|
+
import "./types.js";
|
|
3
|
+
import { initializeReactRouterV4V5Instrumentation } from "./v4v5/initialize.js";
|
|
4
|
+
import "./v4v5/index.js";
|
|
5
|
+
import { initializeReactRouterV6DataRouterInstrumentation, initializeReactRouterV6Instrumentation } from "./v6v7/initialize.js";
|
|
6
|
+
import "./v6v7/index.js";
|
|
7
|
+
//#region src/router/initialize.ts
|
|
8
|
+
function initializeReactRouterInstrumentation(options) {
|
|
9
|
+
var _options$router;
|
|
10
|
+
const initMessage = "Initializing React Router";
|
|
11
|
+
switch ((_options$router = options.router) === null || _options$router === void 0 ? void 0 : _options$router.version) {
|
|
12
|
+
case "v7":
|
|
13
|
+
case "v6":
|
|
14
|
+
internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);
|
|
15
|
+
initializeReactRouterV6Instrumentation(options.router.dependencies);
|
|
16
|
+
break;
|
|
17
|
+
case "v7_data_router":
|
|
18
|
+
case "v6_data_router":
|
|
19
|
+
internalLogger.debug(`${initMessage} ${options.router.version} data router instrumentation`);
|
|
20
|
+
initializeReactRouterV6DataRouterInstrumentation(options.router.dependencies);
|
|
21
|
+
break;
|
|
22
|
+
case "v5":
|
|
23
|
+
case "v4":
|
|
24
|
+
internalLogger.debug(`${initMessage} ${options.router.version} instrumentation`);
|
|
25
|
+
initializeReactRouterV4V5Instrumentation(options.router.dependencies);
|
|
26
|
+
break;
|
|
27
|
+
default: internalLogger.debug("Skipping initialization of React Router instrumentation");
|
|
28
|
+
}
|
|
27
29
|
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { initializeReactRouterInstrumentation };
|
|
32
|
+
|
|
28
33
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","
|
|
1
|
+
{"version":3,"file":"initialize.js","names":[],"sources":["../../../src/router/initialize.ts"],"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"],"mappings":";;;;;;;AAOA,SAAgB,qCAAqC,SAAuC;;CAC1F,MAAM,cAAc;CAEpB,SAAA,kBAAQ,QAAQ,YAAA,QAAA,oBAAA,KAAA,IAAA,KAAA,IAAA,gBAAQ,SAAxB;EACE,KAAA;EACA,KAAA;GACE,eAAe,MAAM,GAAG,YAAY,GAAG,QAAQ,OAAO,QAAQ,iBAAiB;GAC/E,uCAAuC,QAAQ,OAAO,YAAY;GAClE;EAEF,KAAA;EACA,KAAA;GACE,eAAe,MAAM,GAAG,YAAY,GAAG,QAAQ,OAAO,QAAQ,6BAA6B;GAC3F,iDAAiD,QAAQ,OAAO,YAAY;GAC5E;EAEF,KAAA;EACA,KAAA;GACE,eAAe,MAAM,GAAG,YAAY,GAAG,QAAQ,OAAO,QAAQ,iBAAiB;GAC/E,yCAAyC,QAAQ,OAAO,YAAY;GACpE;EAEF,SACE,eAAe,MAAM,yDAAyD;CAClF;AACF"}
|
package/dist/esm/router/types.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
//#region src/router/types.ts
|
|
2
|
+
let ReactRouterVersion = /* @__PURE__ */ function(ReactRouterVersion) {
|
|
3
|
+
ReactRouterVersion["V4"] = "v4";
|
|
4
|
+
ReactRouterVersion["V5"] = "v5";
|
|
5
|
+
ReactRouterVersion["V6"] = "v6";
|
|
6
|
+
ReactRouterVersion["V6_data_router"] = "v6_data_router";
|
|
7
|
+
ReactRouterVersion["V7"] = "v7";
|
|
8
|
+
ReactRouterVersion["V7_data_router"] = "v7_data_router";
|
|
9
|
+
return ReactRouterVersion;
|
|
10
|
+
}({});
|
|
11
|
+
let NavigationType = /* @__PURE__ */ function(NavigationType) {
|
|
12
|
+
NavigationType["Pop"] = "POP";
|
|
13
|
+
NavigationType["Push"] = "PUSH";
|
|
14
|
+
NavigationType["Replace"] = "REPLACE";
|
|
15
|
+
return NavigationType;
|
|
16
|
+
}({});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { NavigationType, ReactRouterVersion };
|
|
19
|
+
|
|
16
20
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/router/types.ts"],"sourcesContent":["export interface ReactRouterLocation<S extends any = unknown> {\n hash: string;\n key: string;\n pathname: string;\n search: string;\n state: S;\n}\n\nexport interface ReactRouterHistory extends Record<string, any> {\n listen?: (cb: (location: ReactRouterLocation, action: NavigationType) => void) => void;\n location?: ReactRouterLocation;\n}\n\nexport enum ReactRouterVersion {\n V4 = 'v4',\n V5 = 'v5',\n V6 = 'v6',\n V6_data_router = 'v6_data_router',\n V7 = 'v7',\n V7_data_router = 'v7_data_router',\n}\n\nexport enum NavigationType {\n Pop = 'POP',\n Push = 'PUSH',\n Replace = 'REPLACE',\n}\n"],"mappings":";AAaA,IAAY,qBAAL,yBAAA,oBAAA;CACL,mBAAA,QAAA;CACA,mBAAA,QAAA;CACA,mBAAA,QAAA;CACA,mBAAA,oBAAA;CACA,mBAAA,QAAA;CACA,mBAAA,oBAAA;;AACF,EAAA,CAAA,CAAA;AAEA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,SAAA;CACA,eAAA,UAAA;CACA,eAAA,aAAA;;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return React.createElement(Route, Object.assign({}, props));
|
|
1
|
+
import { setActiveEventRoute } from "./activeEvent.js";
|
|
2
|
+
import { Route } from "./routerDependencies.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
//#region src/router/v4v5/FaroRoute.tsx
|
|
5
|
+
function FaroRoute(props) {
|
|
6
|
+
var _props$computedMatch;
|
|
7
|
+
if (props === null || props === void 0 || (_props$computedMatch = props.computedMatch) === null || _props$computedMatch === void 0 ? void 0 : _props$computedMatch.isExact) setActiveEventRoute(props.computedMatch.path);
|
|
8
|
+
return /* @__PURE__ */ React.createElement(Route, props);
|
|
10
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { FaroRoute };
|
|
12
|
+
|
|
11
13
|
//# sourceMappingURL=FaroRoute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FaroRoute.js","
|
|
1
|
+
{"version":3,"file":"FaroRoute.js","names":[],"sources":["../../../../src/router/v4v5/FaroRoute.tsx"],"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): React.JSX.Element {\n if (props?.computedMatch?.isExact) {\n setActiveEventRoute(props.computedMatch.path);\n }\n\n return <Route {...props} />;\n}\n"],"mappings":";;;;AAMA,SAAgB,UAAU,OAAqD;;CAC7E,IAAA,UAAA,QAAA,UAAA,KAAA,MAAA,uBAAI,MAAO,mBAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAe,SACxB,oBAAoB,MAAM,cAAc,IAAI;CAG9C,OAAO,sBAAA,cAAC,OAAU,KAAQ;AAC5B"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { api } from "../../dependencies.js";
|
|
2
|
+
import { EVENT_ROUTE_CHANGE } from "@grafana/faro-web-sdk";
|
|
3
|
+
//#region src/router/v4v5/activeEvent.ts
|
|
4
|
+
let activeEvent = void 0;
|
|
5
|
+
function createNewActiveEvent(url) {
|
|
6
|
+
activeEvent = {
|
|
7
|
+
route: "",
|
|
8
|
+
url
|
|
9
|
+
};
|
|
10
|
+
return activeEvent;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
activeEvent.route = route;
|
|
14
|
-
}
|
|
12
|
+
function setActiveEventRoute(route) {
|
|
13
|
+
if (activeEvent) activeEvent.route = route;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
function sendActiveEvent() {
|
|
16
|
+
api.pushEvent(EVENT_ROUTE_CHANGE, activeEvent, void 0, { skipDedupe: true });
|
|
17
|
+
activeEvent = void 0;
|
|
19
18
|
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { activeEvent, createNewActiveEvent, sendActiveEvent, setActiveEventRoute };
|
|
21
|
+
|
|
20
22
|
//# sourceMappingURL=activeEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activeEvent.js","
|
|
1
|
+
{"version":3,"file":"activeEvent.js","names":[],"sources":["../../../../src/router/v4v5/activeEvent.ts"],"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"],"mappings":";;;AAMA,IAAW,cAAsD,KAAA;AAEjE,SAAgB,qBAAqB,KAAyC;CAC5E,cAAc;EACZ,OAAO;EACP;CACF;CAEA,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAAqB;CACvD,IAAI,aACF,YAAY,QAAQ;AAExB;AAEA,SAAgB,kBAAwB;CACtC,IAAI,UAAU,oBAAoB,aAAa,KAAA,GAAW,EAAE,YAAY,KAAK,CAAC;CAE9E,cAAc,KAAA;AAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { setReactRouterV4V5SSRDependencies } from "./routerDependencies.js";
|
|
2
|
+
import { FaroRoute } from "./FaroRoute.js";
|
|
3
|
+
import { createReactRouterV4Options, createReactRouterV5Options, initializeReactRouterV4V5Instrumentation } from "./initialize.js";
|
|
4
|
+
export { FaroRoute, createReactRouterV4Options, createReactRouterV5Options, initializeReactRouterV4V5Instrumentation, setReactRouterV4V5SSRDependencies };
|