@dreamhorizonorg/pulse-react-native 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PulseReactNativeOtel.podspec +1 -1
- package/README.md +34 -879
- package/android/build.gradle +10 -15
- package/android/proguard-rules.pro +3 -99
- package/android/src/main/java/com/pulsereactnativeotel/Pulse.kt +89 -0
- package/android/src/main/java/com/pulsereactnativeotel/PulseOtelConstants.kt +1 -1
- package/android/src/main/java/com/pulsereactnativeotel/PulseReactNativeOtelLogger.kt +3 -1
- package/android/src/main/java/com/pulsereactnativeotel/PulseReactNativeOtelModule.kt +69 -3
- package/android/src/main/java/com/pulsereactnativeotel/PulseReactNativeOtelPackage.kt +1 -1
- package/android/src/main/java/com/pulsereactnativeotel/PulseReactNativeOtelTracer.kt +24 -8
- package/android/src/main/java/com/pulsereactnativeotel/ReactNativeScreenAttributesLogRecordProcessor.kt +21 -0
- package/android/src/main/java/com/pulsereactnativeotel/ReactNativeScreenAttributesSpanProcessor.kt +30 -0
- package/android/src/main/java/com/pulsereactnativeotel/ReactNativeScreenNameTracker.kt +17 -0
- package/app.plugin.js +1 -0
- package/ios/PulseReactNativeOtel.mm +7 -1
- package/lib/module/NativePulseReactNativeOtel.js.map +1 -1
- package/lib/module/config.js +57 -19
- package/lib/module/config.js.map +1 -1
- package/lib/module/errorBoundary.js.map +1 -1
- package/lib/module/events.js +6 -0
- package/lib/module/events.js.map +1 -1
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigation/index.js +179 -0
- package/lib/module/navigation/index.js.map +1 -0
- package/lib/module/navigation/navigation.interface.js +8 -0
- package/lib/module/navigation/navigation.interface.js.map +1 -0
- package/lib/module/navigation/screen-interactive.js +101 -0
- package/lib/module/navigation/screen-interactive.js.map +1 -0
- package/lib/module/navigation/screen-load.js +67 -0
- package/lib/module/navigation/screen-load.js.map +1 -0
- package/lib/module/navigation/screen-session.js +60 -0
- package/lib/module/navigation/screen-session.js.map +1 -0
- package/lib/module/navigation/useNavigationTracking.js +34 -0
- package/lib/module/navigation/useNavigationTracking.js.map +1 -0
- package/lib/module/navigation/utils.js +17 -0
- package/lib/module/navigation/utils.js.map +1 -0
- package/lib/module/network-interceptor/graphql-helper.js +92 -0
- package/lib/module/network-interceptor/graphql-helper.js.map +1 -0
- package/lib/module/network-interceptor/header-helper.js +24 -0
- package/lib/module/network-interceptor/header-helper.js.map +1 -0
- package/lib/module/network-interceptor/initialization.js +18 -1
- package/lib/module/network-interceptor/initialization.js.map +1 -1
- package/lib/module/network-interceptor/request-tracker-xhr.js +61 -4
- package/lib/module/network-interceptor/request-tracker-xhr.js.map +1 -1
- package/lib/module/network-interceptor/span-helpers.js +36 -16
- package/lib/module/network-interceptor/span-helpers.js.map +1 -1
- package/lib/module/network-interceptor/url-helper.js +58 -2
- package/lib/module/network-interceptor/url-helper.js.map +1 -1
- package/lib/module/pulse.constants.js +47 -0
- package/lib/module/pulse.constants.js.map +1 -0
- package/lib/module/trace.js +17 -2
- package/lib/module/trace.js.map +1 -1
- package/lib/typescript/plugin/src/index.d.ts +5 -0
- package/lib/typescript/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/plugin/src/types.d.ts +27 -0
- package/lib/typescript/plugin/src/types.d.ts.map +1 -0
- package/lib/typescript/plugin/src/utils.d.ts +10 -0
- package/lib/typescript/plugin/src/utils.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withAndroidPulse.d.ts +4 -0
- package/lib/typescript/plugin/src/withAndroidPulse.d.ts.map +1 -0
- package/lib/typescript/src/NativePulseReactNativeOtel.d.ts +15 -2
- package/lib/typescript/src/NativePulseReactNativeOtel.d.ts.map +1 -1
- package/lib/typescript/src/config.d.ts +14 -8
- package/lib/typescript/src/config.d.ts.map +1 -1
- package/lib/typescript/src/errorBoundary.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/index.d.ts +13 -0
- package/lib/typescript/src/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/navigation.interface.d.ts +18 -0
- package/lib/typescript/src/navigation/navigation.interface.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen-interactive.d.ts +16 -0
- package/lib/typescript/src/navigation/screen-interactive.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen-load.d.ts +13 -0
- package/lib/typescript/src/navigation/screen-load.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen-session.d.ts +15 -0
- package/lib/typescript/src/navigation/screen-session.d.ts.map +1 -0
- package/lib/typescript/src/navigation/useNavigationTracking.d.ts +5 -0
- package/lib/typescript/src/navigation/useNavigationTracking.d.ts.map +1 -0
- package/lib/typescript/src/navigation/utils.d.ts +8 -0
- package/lib/typescript/src/navigation/utils.d.ts.map +1 -0
- package/lib/typescript/src/network-interceptor/graphql-helper.d.ts +8 -0
- package/lib/typescript/src/network-interceptor/graphql-helper.d.ts.map +1 -0
- package/lib/typescript/src/network-interceptor/header-helper.d.ts +15 -0
- package/lib/typescript/src/network-interceptor/header-helper.d.ts.map +1 -0
- package/lib/typescript/src/network-interceptor/initialization.d.ts +4 -1
- package/lib/typescript/src/network-interceptor/initialization.d.ts.map +1 -1
- package/lib/typescript/src/network-interceptor/network.interface.d.ts +3 -0
- package/lib/typescript/src/network-interceptor/network.interface.d.ts.map +1 -1
- package/lib/typescript/src/network-interceptor/request-tracker-xhr.d.ts.map +1 -1
- package/lib/typescript/src/network-interceptor/span-helpers.d.ts +1 -1
- package/lib/typescript/src/network-interceptor/span-helpers.d.ts.map +1 -1
- package/lib/typescript/src/network-interceptor/url-helper.d.ts +9 -0
- package/lib/typescript/src/network-interceptor/url-helper.d.ts.map +1 -1
- package/lib/typescript/src/pulse.constants.d.ts +43 -0
- package/lib/typescript/src/pulse.constants.d.ts.map +1 -0
- package/lib/typescript/src/pulse.interface.d.ts +2 -1
- package/lib/typescript/src/pulse.interface.d.ts.map +1 -1
- package/lib/typescript/src/trace.d.ts +7 -0
- package/lib/typescript/src/trace.d.ts.map +1 -1
- package/package.json +29 -9
- package/plugin/build/index.d.ts +4 -0
- package/plugin/build/index.js +10 -0
- package/plugin/build/types.d.ts +26 -0
- package/plugin/build/types.js +2 -0
- package/plugin/build/utils.d.ts +9 -0
- package/plugin/build/utils.js +102 -0
- package/plugin/build/withAndroidPulse.d.ts +3 -0
- package/plugin/build/withAndroidPulse.js +53 -0
- package/scripts/pulse-cli.js +82 -0
- package/scripts/uploadService.js +122 -0
- package/scripts/utils.js +125 -0
- package/src/NativePulseReactNativeOtel.ts +18 -2
- package/src/config.ts +94 -23
- package/src/errorBoundary.tsx +11 -5
- package/src/events.ts +7 -0
- package/src/global.d.ts +0 -1
- package/src/index.tsx +7 -4
- package/src/navigation/index.ts +335 -0
- package/src/navigation/navigation.interface.ts +26 -0
- package/src/navigation/screen-interactive.ts +149 -0
- package/src/navigation/screen-load.ts +97 -0
- package/src/navigation/screen-session.ts +87 -0
- package/src/navigation/useNavigationTracking.ts +59 -0
- package/src/navigation/utils.ts +19 -0
- package/src/network-interceptor/graphql-helper.ts +110 -0
- package/src/network-interceptor/header-helper.ts +26 -0
- package/src/network-interceptor/initialization.ts +22 -1
- package/src/network-interceptor/network.interface.ts +3 -0
- package/src/network-interceptor/request-tracker-xhr.ts +93 -3
- package/src/network-interceptor/span-helpers.ts +47 -18
- package/src/network-interceptor/url-helper.ts +67 -1
- package/src/pulse.constants.ts +52 -0
- package/src/pulse.interface.ts +6 -1
- package/src/trace.ts +25 -2
- package/LICENSE +0 -20
- package/lib/module/network-interceptor/request-tracker-fetch.js +0 -72
- package/lib/module/network-interceptor/request-tracker-fetch.js.map +0 -1
- package/lib/module/reactNavigation.js +0 -100
- package/lib/module/reactNavigation.js.map +0 -1
- package/lib/typescript/src/network-interceptor/request-tracker-fetch.d.ts +0 -7
- package/lib/typescript/src/network-interceptor/request-tracker-fetch.d.ts.map +0 -1
- package/lib/typescript/src/reactNavigation.d.ts +0 -10
- package/lib/typescript/src/reactNavigation.d.ts.map +0 -1
- package/src/network-interceptor/request-tracker-fetch.ts +0 -96
- package/src/reactNavigation.tsx +0 -146
package/src/trace.ts
CHANGED
|
@@ -4,8 +4,14 @@ import { mergeWithGlobalAttributes } from './globalAttributes';
|
|
|
4
4
|
import { extractErrorDetails } from './utility';
|
|
5
5
|
import type { PulseAttributes } from './pulse.interface';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Options for starting a span.
|
|
9
|
+
* @param attributes - Attributes to set on the span.
|
|
10
|
+
* @param inheritContext - Controls whether or not the new span will be parented in the existing (current) context. If false, a new context is created.
|
|
11
|
+
*/
|
|
7
12
|
export type SpanOptions = {
|
|
8
13
|
attributes?: PulseAttributes;
|
|
14
|
+
inheritContext?: boolean;
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export enum SpanStatusCode {
|
|
@@ -35,7 +41,12 @@ export function startSpan(name: string, options?: SpanOptions): Span {
|
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
const mergedAttributes = mergeWithGlobalAttributes(options?.attributes || {});
|
|
38
|
-
const
|
|
44
|
+
const inheritContext = options?.inheritContext ?? true;
|
|
45
|
+
const spanId = PulseReactNativeOtel.startSpan(
|
|
46
|
+
name,
|
|
47
|
+
inheritContext,
|
|
48
|
+
mergedAttributes
|
|
49
|
+
);
|
|
39
50
|
return {
|
|
40
51
|
end: (statusCode?: SpanStatusCode) => {
|
|
41
52
|
return endSpan(spanId, statusCode);
|
|
@@ -63,7 +74,12 @@ export function trackSpan<T>(
|
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
const mergedAttributes = mergeWithGlobalAttributes(options?.attributes || {});
|
|
66
|
-
const
|
|
77
|
+
const inheritContext = options?.inheritContext ?? true;
|
|
78
|
+
const spanId = PulseReactNativeOtel.startSpan(
|
|
79
|
+
name,
|
|
80
|
+
inheritContext,
|
|
81
|
+
mergedAttributes
|
|
82
|
+
);
|
|
67
83
|
|
|
68
84
|
const result = fn();
|
|
69
85
|
|
|
@@ -81,6 +97,13 @@ function endSpan(spanId: string, statusCode?: SpanStatusCode): void {
|
|
|
81
97
|
PulseReactNativeOtel.endSpan(spanId, statusCode);
|
|
82
98
|
}
|
|
83
99
|
|
|
100
|
+
export function discardSpan(spanId: string): void {
|
|
101
|
+
if (!isSupportedPlatform()) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
PulseReactNativeOtel.discardSpan(spanId);
|
|
105
|
+
}
|
|
106
|
+
|
|
84
107
|
function addSpanEvent(
|
|
85
108
|
spanId: string,
|
|
86
109
|
name: string,
|
package/LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 HorizonOS
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
SOFTWARE.
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { RequestTracker } from "./request-tracker.js";
|
|
4
|
-
import { getAbsoluteUrl } from "../utility.js";
|
|
5
|
-
import { createNetworkSpan, completeNetworkSpan } from "./span-helpers.js";
|
|
6
|
-
function createStartContext(input, init) {
|
|
7
|
-
const inputIsRequest = isRequest(input);
|
|
8
|
-
const url = inputIsRequest ? input.url : String(input);
|
|
9
|
-
const method = !!init && init.method || inputIsRequest && input.method || 'GET';
|
|
10
|
-
return {
|
|
11
|
-
url: getAbsoluteUrl(url),
|
|
12
|
-
method,
|
|
13
|
-
type: 'fetch'
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function isRequest(input) {
|
|
17
|
-
return !!input && typeof input === 'object' && !(input instanceof URL);
|
|
18
|
-
}
|
|
19
|
-
let isFetchIntercepted = false;
|
|
20
|
-
let originalFetch = null;
|
|
21
|
-
function createFetchRequestTracker(global) {
|
|
22
|
-
if (isFetchIntercepted) {
|
|
23
|
-
console.warn('[Pulse] Fetch already intercepted');
|
|
24
|
-
return new RequestTracker();
|
|
25
|
-
}
|
|
26
|
-
if (originalFetch && global.fetch !== originalFetch) {
|
|
27
|
-
console.warn('[Pulse] Fetch already wrapped by another interceptor');
|
|
28
|
-
isFetchIntercepted = true;
|
|
29
|
-
return new RequestTracker();
|
|
30
|
-
}
|
|
31
|
-
if (global.fetch?._pulseIntercepted) {
|
|
32
|
-
console.warn('[Pulse] Fetch already wrapped by Pulse');
|
|
33
|
-
isFetchIntercepted = true;
|
|
34
|
-
return new RequestTracker();
|
|
35
|
-
}
|
|
36
|
-
const requestTracker = new RequestTracker();
|
|
37
|
-
originalFetch = global.fetch;
|
|
38
|
-
isFetchIntercepted = true;
|
|
39
|
-
const fetchWrapper = function fetch(input, init) {
|
|
40
|
-
const startContext = createStartContext(input, init);
|
|
41
|
-
const span = createNetworkSpan(startContext, 'fetch');
|
|
42
|
-
const {
|
|
43
|
-
onRequestEnd
|
|
44
|
-
} = requestTracker.start(startContext);
|
|
45
|
-
const fetchToCall = originalFetch;
|
|
46
|
-
return fetchToCall.call(global, input, init).then(response => {
|
|
47
|
-
// Determine if response is successful based on status code
|
|
48
|
-
// 2xx and 3xx are successful, 4xx and 5xx are errors
|
|
49
|
-
const isSuccess = response.status >= 200 && response.status < 400;
|
|
50
|
-
const endContext = {
|
|
51
|
-
status: response.status,
|
|
52
|
-
state: isSuccess ? 'success' : 'error'
|
|
53
|
-
};
|
|
54
|
-
completeNetworkSpan(span, startContext, endContext, !isSuccess);
|
|
55
|
-
onRequestEnd(endContext);
|
|
56
|
-
return response;
|
|
57
|
-
}).catch(error => {
|
|
58
|
-
const endContext = {
|
|
59
|
-
error,
|
|
60
|
-
state: 'error'
|
|
61
|
-
};
|
|
62
|
-
completeNetworkSpan(span, startContext, endContext, true);
|
|
63
|
-
onRequestEnd(endContext);
|
|
64
|
-
throw error;
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
fetchWrapper._pulseIntercepted = true;
|
|
68
|
-
global.fetch = fetchWrapper;
|
|
69
|
-
return requestTracker;
|
|
70
|
-
}
|
|
71
|
-
export default createFetchRequestTracker;
|
|
72
|
-
//# sourceMappingURL=request-tracker-fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["RequestTracker","getAbsoluteUrl","createNetworkSpan","completeNetworkSpan","createStartContext","input","init","inputIsRequest","isRequest","url","String","method","type","URL","isFetchIntercepted","originalFetch","createFetchRequestTracker","global","console","warn","fetch","_pulseIntercepted","requestTracker","fetchWrapper","startContext","span","onRequestEnd","start","fetchToCall","call","then","response","isSuccess","status","endContext","state","catch","error"],"sourceRoot":"../../../src","sources":["network-interceptor/request-tracker-fetch.ts"],"mappings":";;AAIA,SAASA,cAAc,QAAQ,sBAA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AI;EAC9CJ,MAAM,CAACG,KAAK,GAAGG,YAAY;EAE3B,OAAOD,cAAc;AACvB;AAEA,eAAeN,yBAAyB","ignoreList":[]}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { Pulse } from "./index.js";
|
|
4
|
-
const NAVIGATION_HISTORY_MAX_SIZE = 200;
|
|
5
|
-
export function createReactNavigationIntegration() {
|
|
6
|
-
let navigationContainer;
|
|
7
|
-
let latestRoute;
|
|
8
|
-
let recentRouteKeys = [];
|
|
9
|
-
let isInitialized = false;
|
|
10
|
-
let span;
|
|
11
|
-
const onNavigationDispatch = () => {
|
|
12
|
-
try {
|
|
13
|
-
span = Pulse.startSpan('Navigated', {
|
|
14
|
-
attributes: {
|
|
15
|
-
'pulse.type': 'screen_load',
|
|
16
|
-
'phase': 'start'
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
console.log('[Pulse Navigation] Navigation dispatch span started', span);
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.warn('[Pulse Navigation] Error in onNavigationDispatch:', error);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const onStateChange = () => {
|
|
25
|
-
try {
|
|
26
|
-
if (!navigationContainer) {
|
|
27
|
-
console.warn('[Pulse Navigation] Navigation container not registered');
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const currentRoute = navigationContainer.getCurrentRoute();
|
|
31
|
-
if (!currentRoute) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!span) {
|
|
35
|
-
latestRoute = currentRoute;
|
|
36
|
-
pushRecentRouteKey(currentRoute.key);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const previousRoute = latestRoute;
|
|
40
|
-
if (previousRoute && previousRoute.key === currentRoute.key) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
latestRoute = currentRoute;
|
|
44
|
-
const routeHasBeenSeen = recentRouteKeys.includes(currentRoute.key);
|
|
45
|
-
pushRecentRouteKey(currentRoute.key);
|
|
46
|
-
span?.setAttributes({
|
|
47
|
-
'screen.name': currentRoute.name,
|
|
48
|
-
'last.screen.name': previousRoute?.name || undefined,
|
|
49
|
-
'routeHasBeenSeen': routeHasBeenSeen,
|
|
50
|
-
'routeKey': currentRoute.key
|
|
51
|
-
});
|
|
52
|
-
span?.end();
|
|
53
|
-
console.log('[Pulse Navigation] Navigation dispatch span ended', span);
|
|
54
|
-
span = undefined;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.warn('[Pulse Navigation] Error in onStateChange:', error);
|
|
57
|
-
span = undefined;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const registerNavigationContainer = maybeNavigationContainer => {
|
|
61
|
-
try {
|
|
62
|
-
let container;
|
|
63
|
-
if (typeof maybeNavigationContainer === 'object' && maybeNavigationContainer !== null && 'current' in maybeNavigationContainer) {
|
|
64
|
-
container = maybeNavigationContainer.current;
|
|
65
|
-
} else {
|
|
66
|
-
container = maybeNavigationContainer;
|
|
67
|
-
}
|
|
68
|
-
if (!container) {
|
|
69
|
-
console.warn('[Pulse Navigation] Invalid navigation container ref');
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (isInitialized && navigationContainer === container) {
|
|
73
|
-
console.log('[Pulse Navigation] Container already registered');
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
navigationContainer = container;
|
|
77
|
-
navigationContainer.addListener('__unsafe_action__', onNavigationDispatch);
|
|
78
|
-
navigationContainer.addListener('state', onStateChange);
|
|
79
|
-
const currentRoute = navigationContainer.getCurrentRoute();
|
|
80
|
-
if (currentRoute) {
|
|
81
|
-
latestRoute = currentRoute;
|
|
82
|
-
pushRecentRouteKey(currentRoute.key);
|
|
83
|
-
}
|
|
84
|
-
isInitialized = true;
|
|
85
|
-
console.log('[Pulse Navigation] Integration initialized successfully');
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error('[Pulse Navigation] Error registering container:', error);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const pushRecentRouteKey = key => {
|
|
91
|
-
recentRouteKeys.push(key);
|
|
92
|
-
if (recentRouteKeys.length > NAVIGATION_HISTORY_MAX_SIZE) {
|
|
93
|
-
recentRouteKeys = recentRouteKeys.slice(recentRouteKeys.length - NAVIGATION_HISTORY_MAX_SIZE);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
registerNavigationContainer
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=reactNavigation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Pulse","NAVIGATION_HISTORY_MAX_SIZE","createReactNavigationIntegration","navigationContainer","latestRoute","recentRouteKeys","isInitialized","span","onNavigationDispatch","startSpan","attributes","console","log","error","warn","onStateChange","currentRoute","getCurrentRoute","pushRecentRouteKey","key","previousRoute","routeHasBeenSeen","includes","setAttributes","name","undefined","end","registerNavigationContainer","maybeNavigationContainer","container","current","addListener","push","length","slice"],"sourceRoot":"../../src","sources":["reactNavigation.tsx"],"mappings":";;AAAA,SAASA,KAAK,QAAmB,YAAS;AAE1C,MAAMC,2BAA2B,GAAG,GAAG;AAavC,OAAO,SAASC,gCAAgCA,CAAA,EAAG;EACjD,IAAIC,mBAAoD;EACxD,IAAIC,WAAwC;EAC5C,IAAIC,eAAyB,GAAG,EAAE;EAClC,IAAIC,aAAa,GAAG,KAAK;EACzB,IAAIC,IAAsB;EAE1B,MAAMC,oBAAoB,GAAGA,CAAA,KAAY;IACvC,IAAI;MACFD,IAAI,GAAGP,KAAK,CAACS,SAAS,CAAC,WAAW,EAAE;QAClCC,UAAU,EAAE;UACV,YAAY,EAAE,aAAa;UAC3B,OAAO,EAAE;QACX;MACF,CAAC,CAAC;MAEFC,OAAO,CAACC,GAAG,CAAC,qDAAqD,EAAEL,IAAI,CAAC;IAC1E,CAAC,CAAC,OAAOM,KAAK,EAA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@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RequestTracker } from './request-tracker';
|
|
2
|
-
interface GlobalWithFetch {
|
|
3
|
-
fetch: typeof fetch;
|
|
4
|
-
}
|
|
5
|
-
declare function createFetchRequestTracker(global: GlobalWithFetch): RequestTracker;
|
|
6
|
-
export default createFetchRequestTracker;
|
|
7
|
-
//# sourceMappingURL=request-tracker-fetch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-tracker-fetch.d.ts","sourceRoot":"","sources":["../../../../src/network-interceptor/request-tracker-fetch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,UAAU,eAAe;IACvB,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB;AAsBD,iBAAS,yBAAyB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CA6D1E;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface NavigationRoute {
|
|
2
|
-
name: string;
|
|
3
|
-
key: string;
|
|
4
|
-
params?: Record<string, any>;
|
|
5
|
-
}
|
|
6
|
-
export declare function createReactNavigationIntegration(): {
|
|
7
|
-
registerNavigationContainer: (maybeNavigationContainer: unknown) => void;
|
|
8
|
-
};
|
|
9
|
-
export type ReactNavigationIntegration = ReturnType<typeof createReactNavigationIntegration>;
|
|
10
|
-
//# sourceMappingURL=reactNavigation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reactNavigation.d.ts","sourceRoot":"","sources":["../../../src/reactNavigation.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAOD,wBAAgB,gCAAgC;4DAoElB,OAAO,KAChC,IAAI;EAyDR;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CACjD,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RequestStartContext,
|
|
3
|
-
RequestEndContext,
|
|
4
|
-
} from './network.interface';
|
|
5
|
-
import { RequestTracker } from './request-tracker';
|
|
6
|
-
import { getAbsoluteUrl } from '../utility';
|
|
7
|
-
import { createNetworkSpan, completeNetworkSpan } from './span-helpers';
|
|
8
|
-
|
|
9
|
-
interface GlobalWithFetch {
|
|
10
|
-
fetch: typeof fetch;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function createStartContext(
|
|
14
|
-
input: unknown,
|
|
15
|
-
init?: unknown
|
|
16
|
-
): RequestStartContext {
|
|
17
|
-
const inputIsRequest = isRequest(input);
|
|
18
|
-
const url = inputIsRequest ? input.url : String(input);
|
|
19
|
-
const method =
|
|
20
|
-
(!!init && (init as RequestInit).method) ||
|
|
21
|
-
(inputIsRequest && input.method) ||
|
|
22
|
-
'GET';
|
|
23
|
-
return { url: getAbsoluteUrl(url), method, type: 'fetch' };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isRequest(input: unknown): input is Request {
|
|
27
|
-
return !!input && typeof input === 'object' && !(input instanceof URL);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let isFetchIntercepted = false;
|
|
31
|
-
let originalFetch: typeof fetch | null = null;
|
|
32
|
-
|
|
33
|
-
function createFetchRequestTracker(global: GlobalWithFetch): RequestTracker {
|
|
34
|
-
if (isFetchIntercepted) {
|
|
35
|
-
console.warn('[Pulse] Fetch already intercepted');
|
|
36
|
-
return new RequestTracker();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (originalFetch && global.fetch !== originalFetch) {
|
|
40
|
-
console.warn('[Pulse] Fetch already wrapped by another interceptor');
|
|
41
|
-
isFetchIntercepted = true;
|
|
42
|
-
return new RequestTracker();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if ((global.fetch as any)?._pulseIntercepted) {
|
|
46
|
-
console.warn('[Pulse] Fetch already wrapped by Pulse');
|
|
47
|
-
isFetchIntercepted = true;
|
|
48
|
-
return new RequestTracker();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const requestTracker = new RequestTracker();
|
|
52
|
-
originalFetch = global.fetch;
|
|
53
|
-
isFetchIntercepted = true;
|
|
54
|
-
|
|
55
|
-
const fetchWrapper = function fetch(input: unknown, init?: unknown) {
|
|
56
|
-
const startContext = createStartContext(input, init);
|
|
57
|
-
|
|
58
|
-
const span = createNetworkSpan(startContext, 'fetch');
|
|
59
|
-
const { onRequestEnd } = requestTracker.start(startContext);
|
|
60
|
-
|
|
61
|
-
const fetchToCall = originalFetch!;
|
|
62
|
-
return fetchToCall
|
|
63
|
-
.call(global, input as RequestInfo, init as RequestInit)
|
|
64
|
-
.then((response) => {
|
|
65
|
-
// Determine if response is successful based on status code
|
|
66
|
-
// 2xx and 3xx are successful, 4xx and 5xx are errors
|
|
67
|
-
const isSuccess = response.status >= 200 && response.status < 400;
|
|
68
|
-
|
|
69
|
-
const endContext: RequestEndContext = {
|
|
70
|
-
status: response.status,
|
|
71
|
-
state: isSuccess ? 'success' : 'error',
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
completeNetworkSpan(span, startContext, endContext, !isSuccess);
|
|
75
|
-
onRequestEnd(endContext);
|
|
76
|
-
return response;
|
|
77
|
-
})
|
|
78
|
-
.catch((error) => {
|
|
79
|
-
const endContext: RequestEndContext = {
|
|
80
|
-
error,
|
|
81
|
-
state: 'error',
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
completeNetworkSpan(span, startContext, endContext, true);
|
|
85
|
-
onRequestEnd(endContext);
|
|
86
|
-
throw error;
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
(fetchWrapper as any)._pulseIntercepted = true;
|
|
91
|
-
global.fetch = fetchWrapper;
|
|
92
|
-
|
|
93
|
-
return requestTracker;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export default createFetchRequestTracker;
|
package/src/reactNavigation.tsx
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Pulse, type Span } from './index';
|
|
2
|
-
|
|
3
|
-
const NAVIGATION_HISTORY_MAX_SIZE = 200;
|
|
4
|
-
|
|
5
|
-
export interface NavigationRoute {
|
|
6
|
-
name: string;
|
|
7
|
-
key: string;
|
|
8
|
-
params?: Record<string, any>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface NavigationContainer {
|
|
12
|
-
addListener: (type: string, listener: (event?: unknown) => void) => void;
|
|
13
|
-
getCurrentRoute: () => NavigationRoute | undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function createReactNavigationIntegration() {
|
|
17
|
-
let navigationContainer: NavigationContainer | undefined;
|
|
18
|
-
let latestRoute: NavigationRoute | undefined;
|
|
19
|
-
let recentRouteKeys: string[] = [];
|
|
20
|
-
let isInitialized = false;
|
|
21
|
-
let span: Span | undefined;
|
|
22
|
-
|
|
23
|
-
const onNavigationDispatch = (): void => {
|
|
24
|
-
try {
|
|
25
|
-
span = Pulse.startSpan('Navigated', {
|
|
26
|
-
attributes: {
|
|
27
|
-
'pulse.type': 'screen_load',
|
|
28
|
-
'phase': 'start',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
console.log('[Pulse Navigation] Navigation dispatch span started', span);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.warn('[Pulse Navigation] Error in onNavigationDispatch:', error);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const onStateChange = (): void => {
|
|
39
|
-
try {
|
|
40
|
-
if (!navigationContainer) {
|
|
41
|
-
console.warn('[Pulse Navigation] Navigation container not registered');
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const currentRoute = navigationContainer.getCurrentRoute();
|
|
46
|
-
if (!currentRoute) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!span) {
|
|
51
|
-
latestRoute = currentRoute;
|
|
52
|
-
pushRecentRouteKey(currentRoute.key);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const previousRoute = latestRoute;
|
|
57
|
-
|
|
58
|
-
if (previousRoute && previousRoute.key === currentRoute.key) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
latestRoute = currentRoute;
|
|
63
|
-
|
|
64
|
-
const routeHasBeenSeen = recentRouteKeys.includes(currentRoute.key);
|
|
65
|
-
pushRecentRouteKey(currentRoute.key);
|
|
66
|
-
|
|
67
|
-
span?.setAttributes({
|
|
68
|
-
'screen.name': currentRoute.name,
|
|
69
|
-
'last.screen.name': previousRoute?.name || undefined,
|
|
70
|
-
'routeHasBeenSeen': routeHasBeenSeen,
|
|
71
|
-
'routeKey': currentRoute.key,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
span?.end();
|
|
75
|
-
console.log('[Pulse Navigation] Navigation dispatch span ended', span);
|
|
76
|
-
span = undefined;
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.warn('[Pulse Navigation] Error in onStateChange:', error);
|
|
79
|
-
span = undefined;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const registerNavigationContainer = (
|
|
84
|
-
maybeNavigationContainer: unknown
|
|
85
|
-
): void => {
|
|
86
|
-
try {
|
|
87
|
-
let container: NavigationContainer | undefined;
|
|
88
|
-
if (
|
|
89
|
-
typeof maybeNavigationContainer === 'object' &&
|
|
90
|
-
maybeNavigationContainer !== null &&
|
|
91
|
-
'current' in maybeNavigationContainer
|
|
92
|
-
) {
|
|
93
|
-
container = maybeNavigationContainer.current as NavigationContainer;
|
|
94
|
-
} else {
|
|
95
|
-
container = maybeNavigationContainer as NavigationContainer;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (!container) {
|
|
99
|
-
console.warn('[Pulse Navigation] Invalid navigation container ref');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (isInitialized && navigationContainer === container) {
|
|
104
|
-
console.log('[Pulse Navigation] Container already registered');
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
navigationContainer = container;
|
|
109
|
-
|
|
110
|
-
navigationContainer.addListener(
|
|
111
|
-
'__unsafe_action__',
|
|
112
|
-
onNavigationDispatch
|
|
113
|
-
);
|
|
114
|
-
navigationContainer.addListener('state', onStateChange);
|
|
115
|
-
|
|
116
|
-
const currentRoute = navigationContainer.getCurrentRoute();
|
|
117
|
-
if (currentRoute) {
|
|
118
|
-
latestRoute = currentRoute;
|
|
119
|
-
pushRecentRouteKey(currentRoute.key);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
isInitialized = true;
|
|
123
|
-
console.log('[Pulse Navigation] Integration initialized successfully');
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error('[Pulse Navigation] Error registering container:', error);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const pushRecentRouteKey = (key: string): void => {
|
|
130
|
-
recentRouteKeys.push(key);
|
|
131
|
-
|
|
132
|
-
if (recentRouteKeys.length > NAVIGATION_HISTORY_MAX_SIZE) {
|
|
133
|
-
recentRouteKeys = recentRouteKeys.slice(
|
|
134
|
-
recentRouteKeys.length - NAVIGATION_HISTORY_MAX_SIZE
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return {
|
|
140
|
-
registerNavigationContainer,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export type ReactNavigationIntegration = ReturnType<
|
|
145
|
-
typeof createReactNavigationIntegration
|
|
146
|
-
>;
|