react-native-inapp-inspector 2.3.14 → 2.3.16
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/README.md +1 -0
- package/dist/commonjs/components/AnimatedEntrance.js +3 -3
- package/dist/commonjs/components/ConsoleLogCard.js +174 -100
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +0 -22
- package/dist/commonjs/components/Inspector/ConsoleTab.js +25 -38
- package/dist/commonjs/components/Inspector/CrashTab.js +19 -28
- package/dist/commonjs/components/Inspector/DeviceInfoTab.js +198 -98
- package/dist/commonjs/components/Inspector/FeedbackModal.d.ts +7 -0
- package/dist/commonjs/components/Inspector/FeedbackModal.js +552 -0
- package/dist/commonjs/components/Inspector/InspectorHeader.js +58 -6
- package/dist/commonjs/components/Inspector/MainScreen.js +100 -58
- package/dist/commonjs/components/Inspector/NetworkTab.js +26 -371
- package/dist/commonjs/components/Inspector/NpmStarPrompt.d.ts +3 -0
- package/dist/commonjs/components/Inspector/NpmStarPrompt.js +494 -0
- package/dist/commonjs/components/Inspector/PerformanceTab.js +40 -7
- package/dist/commonjs/components/Inspector/ReduxTab.js +3 -23
- package/dist/commonjs/components/Inspector/SettingsPanel.js +1035 -173
- package/dist/commonjs/components/Inspector/StorageTab.js +23 -28
- package/dist/commonjs/components/Inspector/TabBar.js +50 -15
- package/dist/commonjs/components/JsonViewer.js +14 -2
- package/dist/commonjs/components/LogCard.js +428 -227
- package/dist/commonjs/components/NetworkIcons.d.ts +5 -0
- package/dist/commonjs/components/NetworkIcons.js +33 -2
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/analyticsLogger.js +1 -1
- package/dist/commonjs/customHooks/consoleLogger.js +34 -2
- package/dist/commonjs/customHooks/crashHandler.js +1 -1
- package/dist/commonjs/customHooks/networkLogger.js +184 -26
- package/dist/commonjs/helpers/index.d.ts +1 -0
- package/dist/commonjs/helpers/index.js +1 -0
- package/dist/commonjs/helpers/remoteConfig.d.ts +4 -0
- package/dist/commonjs/helpers/remoteConfig.js +165 -0
- package/dist/commonjs/helpers/searchQueryParser.d.ts +1 -1
- package/dist/commonjs/helpers/searchQueryParser.js +39 -291
- package/dist/commonjs/helpers/telemetry.d.ts +5 -0
- package/dist/commonjs/helpers/telemetry.js +339 -8
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.js +173 -29
- package/dist/commonjs/styles/AppFonts.d.ts +2 -0
- package/dist/commonjs/styles/AppFonts.js +1 -0
- package/dist/commonjs/styles/index.d.ts +22 -0
- package/dist/commonjs/styles/index.js +19 -0
- package/dist/commonjs/types/enums.d.ts +1 -0
- package/dist/commonjs/types/enums.js +1 -0
- package/dist/commonjs/types/interfaces.d.ts +12 -0
- package/dist/esm/components/AnimatedEntrance.js +3 -3
- package/dist/esm/components/ConsoleLogCard.js +141 -100
- package/dist/esm/components/Inspector/AnalyticsTab.js +1 -23
- package/dist/esm/components/Inspector/ConsoleTab.js +26 -39
- package/dist/esm/components/Inspector/CrashTab.js +20 -29
- package/dist/esm/components/Inspector/DeviceInfoTab.js +198 -98
- package/dist/esm/components/Inspector/FeedbackModal.d.ts +7 -0
- package/dist/esm/components/Inspector/FeedbackModal.js +515 -0
- package/dist/esm/components/Inspector/InspectorHeader.js +60 -8
- package/dist/esm/components/Inspector/MainScreen.js +101 -59
- package/dist/esm/components/Inspector/NetworkTab.js +27 -372
- package/dist/esm/components/Inspector/NpmStarPrompt.d.ts +3 -0
- package/dist/esm/components/Inspector/NpmStarPrompt.js +454 -0
- package/dist/esm/components/Inspector/PerformanceTab.js +40 -7
- package/dist/esm/components/Inspector/ReduxTab.js +4 -24
- package/dist/esm/components/Inspector/SettingsPanel.js +1038 -176
- package/dist/esm/components/Inspector/StorageTab.js +23 -28
- package/dist/esm/components/Inspector/TabBar.js +50 -15
- package/dist/esm/components/JsonViewer.js +14 -2
- package/dist/esm/components/LogCard.js +422 -221
- package/dist/esm/components/NetworkIcons.d.ts +5 -0
- package/dist/esm/components/NetworkIcons.js +26 -0
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/analyticsLogger.js +1 -1
- package/dist/esm/customHooks/consoleLogger.js +34 -2
- package/dist/esm/customHooks/crashHandler.js +1 -1
- package/dist/esm/customHooks/networkLogger.js +184 -26
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/helpers/remoteConfig.d.ts +4 -0
- package/dist/esm/helpers/remoteConfig.js +160 -0
- package/dist/esm/helpers/searchQueryParser.d.ts +1 -1
- package/dist/esm/helpers/searchQueryParser.js +39 -291
- package/dist/esm/helpers/telemetry.d.ts +5 -0
- package/dist/esm/helpers/telemetry.js +332 -9
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +171 -29
- package/dist/esm/styles/AppFonts.d.ts +2 -0
- package/dist/esm/styles/AppFonts.js +1 -0
- package/dist/esm/styles/index.d.ts +22 -0
- package/dist/esm/styles/index.js +19 -0
- package/dist/esm/types/enums.d.ts +1 -0
- package/dist/esm/types/enums.js +1 -0
- package/dist/esm/types/interfaces.d.ts +12 -0
- package/package.json +1 -1
- package/src/components/AnimatedEntrance.tsx +3 -3
- package/src/components/ConsoleLogCard.tsx +154 -103
- package/src/components/Inspector/AnalyticsTab.tsx +0 -23
- package/src/components/Inspector/ConsoleTab.tsx +27 -41
- package/src/components/Inspector/CrashTab.tsx +19 -28
- package/src/components/Inspector/DeviceInfoTab.tsx +224 -102
- package/src/components/Inspector/FeedbackModal.tsx +626 -0
- package/src/components/Inspector/InspectorHeader.tsx +83 -5
- package/src/components/Inspector/MainScreen.tsx +61 -6
- package/src/components/Inspector/NetworkTab.tsx +70 -480
- package/src/components/Inspector/NpmStarPrompt.tsx +532 -0
- package/src/components/Inspector/PerformanceTab.tsx +44 -8
- package/src/components/Inspector/ReduxTab.tsx +9 -24
- package/src/components/Inspector/SettingsPanel.tsx +1162 -197
- package/src/components/Inspector/StorageTab.tsx +27 -30
- package/src/components/Inspector/TabBar.tsx +57 -20
- package/src/components/JsonViewer.tsx +15 -2
- package/src/components/LogCard.tsx +528 -339
- package/src/components/NetworkIcons.tsx +92 -0
- package/src/constants/version.ts +1 -1
- package/src/customHooks/analyticsLogger.ts +1 -1
- package/src/customHooks/consoleLogger.ts +36 -3
- package/src/customHooks/crashHandler.ts +1 -1
- package/src/customHooks/networkLogger.ts +214 -26
- package/src/helpers/index.ts +1 -0
- package/src/helpers/remoteConfig.ts +212 -0
- package/src/helpers/searchQueryParser.ts +42 -284
- package/src/helpers/telemetry.ts +381 -10
- package/src/index.tsx +374 -211
- package/src/styles/AppFonts.ts +2 -0
- package/src/styles/index.ts +20 -1
- package/src/types/enums.ts +1 -0
- package/src/types/interfaces.ts +12 -0
|
@@ -91,6 +91,7 @@ export declare const CartIcon: ({ color, size }: IconProps) => React.JSX.Element
|
|
|
91
91
|
export declare const MoneyIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
92
92
|
export declare const ExternalLinkIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
93
93
|
export declare const PackageBoxIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
94
|
+
export declare const StarIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
94
95
|
export declare const GitHubIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
95
96
|
export declare const LinkChainIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
96
97
|
export declare const AppleIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
@@ -138,3 +139,7 @@ export declare const QrCodeIcon: ({ color, size, }: IconProps) => React.JSX.Elem
|
|
|
138
139
|
export declare const UnlockIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
139
140
|
export declare const RocketIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
140
141
|
export declare const TurtleIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
142
|
+
export declare const HeadphonesIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
143
|
+
export declare const HelpCircleIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
144
|
+
export declare const SendIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
145
|
+
export declare const LifeBuoyIcon: ({ color, size, }: IconProps) => React.JSX.Element;
|
|
@@ -510,6 +510,11 @@ export const PackageBoxIcon = ({ color = AppColors.grayTextWeak, size = 14, }) =
|
|
|
510
510
|
<Path d="M3.27 6.96L12 12.01l8.73-5.05M12 22.08V12" stroke={color} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/>
|
|
511
511
|
</Svg>);
|
|
512
512
|
};
|
|
513
|
+
export const StarIcon = ({ color = '#F59E0B', size = 14, }) => {
|
|
514
|
+
return (<Svg width={size} height={size} viewBox="0 0 24 24" fill={color}>
|
|
515
|
+
<Path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" stroke={color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
|
|
516
|
+
</Svg>);
|
|
517
|
+
};
|
|
513
518
|
export const GitHubIcon = ({ color = AppColors.grayTextWeak, size = 14, }) => {
|
|
514
519
|
return (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
515
520
|
<Path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22" stroke={color} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/>
|
|
@@ -760,3 +765,24 @@ export const TurtleIcon = ({ color = AppColors.grayTextWeak, size = 14, }) => (<
|
|
|
760
765
|
<Circle cx="12" cy="6" r="3" stroke={color} strokeWidth="2"/>
|
|
761
766
|
<Path d="M5 12l-2-2M19 12l2-2M6 18l-2 2M18 18l2 2" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
762
767
|
</Svg>);
|
|
768
|
+
export const HeadphonesIcon = ({ color = AppColors.white, size = 20, }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
769
|
+
<Path d="M3 18v-6a9 9 0 0 1 18 0v6" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
770
|
+
<Path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3v5zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3v5z" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
771
|
+
</Svg>);
|
|
772
|
+
export const HelpCircleIcon = ({ color = AppColors.white, size = 20, }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
773
|
+
<Circle cx="12" cy="12" r="10" stroke={color} strokeWidth="2"/>
|
|
774
|
+
<Path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
775
|
+
<Line x1="12" y1="17" x2="12.01" y2="17" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
776
|
+
</Svg>);
|
|
777
|
+
export const SendIcon = ({ color = AppColors.white, size = 18, }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
778
|
+
<Path d="M22 2L11 13" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
779
|
+
<Path d="M22 2L15 22L11 13L2 9L22 2Z" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
780
|
+
</Svg>);
|
|
781
|
+
export const LifeBuoyIcon = ({ color = AppColors.white, size = 20, }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
782
|
+
<Circle cx="12" cy="12" r="10" stroke={color} strokeWidth="2"/>
|
|
783
|
+
<Circle cx="12" cy="12" r="4" stroke={color} strokeWidth="2"/>
|
|
784
|
+
<Line x1="4.93" y1="4.93" x2="9.17" y2="9.17" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
785
|
+
<Line x1="14.83" y1="9.17" x2="19.07" y2="4.93" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
786
|
+
<Line x1="14.83" y1="14.83" x2="19.07" y2="19.07" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
787
|
+
<Line x1="4.93" y1="19.07" x2="9.17" y2="14.83" stroke={color} strokeWidth="2" strokeLinecap="round"/>
|
|
788
|
+
</Svg>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "2.3.
|
|
1
|
+
export declare const LIB_VERSION = "2.3.16";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '2.3.
|
|
1
|
+
export const LIB_VERSION = '2.3.16';
|
|
@@ -10,7 +10,7 @@ let currentUserProperties = {};
|
|
|
10
10
|
let currentUserId;
|
|
11
11
|
let currentDefaultEventParameters = {};
|
|
12
12
|
let isCollectionEnabled = true;
|
|
13
|
-
let maxAnalyticsLogsLimit =
|
|
13
|
+
let maxAnalyticsLogsLimit = 150;
|
|
14
14
|
export const setMaxAnalyticsLogsLimit = (limit) => {
|
|
15
15
|
maxAnalyticsLogsLimit = Math.max(10, limit);
|
|
16
16
|
if (events.length > maxAnalyticsLogsLimit) {
|
|
@@ -10,7 +10,7 @@ export const setConsoleModuleEnabled = (enabled) => {
|
|
|
10
10
|
isConsoleModuleEnabled = enabled;
|
|
11
11
|
};
|
|
12
12
|
export const getConsoleModuleEnabled = () => isConsoleModuleEnabled;
|
|
13
|
-
let maxConsoleLogsLimit =
|
|
13
|
+
let maxConsoleLogsLimit = 250;
|
|
14
14
|
export const setMaxConsoleLogsLimit = (limit) => {
|
|
15
15
|
maxConsoleLogsLimit = Math.max(10, limit);
|
|
16
16
|
if (logs.length > maxConsoleLogsLimit) {
|
|
@@ -237,7 +237,7 @@ const addLog = (type, args, sourceMethod) => {
|
|
|
237
237
|
logs = logs.slice(0, maxConsoleLogsLimit);
|
|
238
238
|
notify();
|
|
239
239
|
const stackToSymbolicate = errorStack || stackToUse || stack;
|
|
240
|
-
if (stackToSymbolicate && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
240
|
+
if (type === 'error' && stackToSymbolicate && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
241
241
|
const currentLogId = newLog.id;
|
|
242
242
|
symbolicateStack(stackToSymbolicate)
|
|
243
243
|
.then(symFrames => {
|
|
@@ -355,6 +355,8 @@ export const setupConsoleLogger = () => {
|
|
|
355
355
|
info: console.info,
|
|
356
356
|
warn: console.warn,
|
|
357
357
|
error: console.error,
|
|
358
|
+
debug: console.debug,
|
|
359
|
+
trace: console.trace,
|
|
358
360
|
};
|
|
359
361
|
console.log = (...args) => {
|
|
360
362
|
try {
|
|
@@ -370,6 +372,30 @@ export const setupConsoleLogger = () => {
|
|
|
370
372
|
catch { }
|
|
371
373
|
originalConsole.info(...args);
|
|
372
374
|
};
|
|
375
|
+
console.debug = (...args) => {
|
|
376
|
+
try {
|
|
377
|
+
addLog('info', args, 'info');
|
|
378
|
+
}
|
|
379
|
+
catch { }
|
|
380
|
+
if (typeof originalConsole.debug === 'function') {
|
|
381
|
+
originalConsole.debug(...args);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
originalConsole.log(...args);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
console.trace = (...args) => {
|
|
388
|
+
try {
|
|
389
|
+
addLog('info', args, 'info');
|
|
390
|
+
}
|
|
391
|
+
catch { }
|
|
392
|
+
if (typeof originalConsole.trace === 'function') {
|
|
393
|
+
originalConsole.trace(...args);
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
originalConsole.log(...args);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
373
399
|
console.warn = (...args) => {
|
|
374
400
|
try {
|
|
375
401
|
addLog('warn', args, 'warn');
|
|
@@ -398,3 +424,9 @@ export const setupConsoleLogger = () => {
|
|
|
398
424
|
catch { }
|
|
399
425
|
globalThis.__CONSOLE_LOGGER_INITIALIZED__ = true;
|
|
400
426
|
};
|
|
427
|
+
if (typeof globalThis !== 'undefined') {
|
|
428
|
+
try {
|
|
429
|
+
setupConsoleLogger();
|
|
430
|
+
}
|
|
431
|
+
catch { }
|
|
432
|
+
}
|
|
@@ -10,7 +10,7 @@ let lastHandledErrorTimestamp = 0;
|
|
|
10
10
|
let crashRecordsStore = [];
|
|
11
11
|
let breadcrumbsStore = [];
|
|
12
12
|
const MAX_BREADCRUMBS = 50;
|
|
13
|
-
let maxStoredCrashes =
|
|
13
|
+
let maxStoredCrashes = 100;
|
|
14
14
|
const appStartTime = Date.now();
|
|
15
15
|
let isCrashModuleEnabled = false;
|
|
16
16
|
export const setCrashModuleEnabled = (enabled) => {
|
|
@@ -12,16 +12,22 @@ export const setNetworkModuleEnabled = (enabled) => {
|
|
|
12
12
|
isNetworkModuleEnabled = enabled;
|
|
13
13
|
};
|
|
14
14
|
export const getNetworkModuleEnabled = () => isNetworkModuleEnabled;
|
|
15
|
-
const ALLOWED_METHODS = [
|
|
15
|
+
const ALLOWED_METHODS = [
|
|
16
|
+
"GET",
|
|
17
|
+
"POST",
|
|
18
|
+
"PUT",
|
|
19
|
+
"PATCH",
|
|
20
|
+
"DELETE",
|
|
21
|
+
"HEAD",
|
|
22
|
+
"OPTIONS",
|
|
23
|
+
"CONNECT",
|
|
24
|
+
"TRACE",
|
|
25
|
+
];
|
|
16
26
|
const IGNORED_URL_PATTERNS = [
|
|
17
|
-
/\/symbolicate(
|
|
27
|
+
/\/symbolicate(?:\?|$)/i,
|
|
18
28
|
/\/index\.bundle(?:\?|$)/i,
|
|
19
|
-
/\/hot(?:\?|$)/i,
|
|
20
|
-
/\/message(?:\?|$)/i,
|
|
21
29
|
/\/open-debugger(?:\?|$)/i,
|
|
22
|
-
|
|
23
|
-
/127\.0\.0\.1:(?:8081|8082|8083|19000|19001|19002|3000|8000)/i,
|
|
24
|
-
/localhost:(?:8081|8082|8083|19000|19001|19002|3000|8000)\/index\.bundle/i,
|
|
30
|
+
/:(?:8081|8082|8083|19000|19001)\/(?:index\.bundle|symbolicate|hot|message|status)/i,
|
|
25
31
|
/google-analytics\.com\/mp\/collect/i,
|
|
26
32
|
/analytics\.google\.com/i,
|
|
27
33
|
];
|
|
@@ -30,6 +36,21 @@ function shouldIgnoreUrl(url) {
|
|
|
30
36
|
return false;
|
|
31
37
|
return IGNORED_URL_PATTERNS.some((re) => re.test(url));
|
|
32
38
|
}
|
|
39
|
+
function parseXHRResponseHeaders(headerStr) {
|
|
40
|
+
if (!headerStr || typeof headerStr !== "string")
|
|
41
|
+
return undefined;
|
|
42
|
+
const lines = headerStr.trim().split(/[\r\n]+/);
|
|
43
|
+
const result = {};
|
|
44
|
+
lines.forEach((line) => {
|
|
45
|
+
const idx = line.indexOf(":");
|
|
46
|
+
if (idx > 0) {
|
|
47
|
+
const key = line.substring(0, idx).trim().toLowerCase();
|
|
48
|
+
const val = line.substring(idx + 1).trim();
|
|
49
|
+
result[key] = val;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
53
|
+
}
|
|
33
54
|
function normaliseHeaders(raw) {
|
|
34
55
|
if (!raw)
|
|
35
56
|
return undefined;
|
|
@@ -112,7 +133,7 @@ export const clearNetworkLogs = () => {
|
|
|
112
133
|
notify();
|
|
113
134
|
};
|
|
114
135
|
export const getNetworkLogs = () => [...logs];
|
|
115
|
-
let maxNetworkLogsLimit =
|
|
136
|
+
let maxNetworkLogsLimit = 250;
|
|
116
137
|
export const setMaxNetworkLogsLimit = (limit) => {
|
|
117
138
|
maxNetworkLogsLimit = Math.max(10, limit);
|
|
118
139
|
if (logs.length > maxNetworkLogsLimit) {
|
|
@@ -138,7 +159,7 @@ const addOrUpdateLog = (log) => {
|
|
|
138
159
|
if (!isNetworkModuleEnabled)
|
|
139
160
|
return;
|
|
140
161
|
const method = log.method?.toUpperCase();
|
|
141
|
-
if (!ALLOWED_METHODS.includes(method))
|
|
162
|
+
if (method && !ALLOWED_METHODS.includes(method))
|
|
142
163
|
return;
|
|
143
164
|
if (shouldIgnoreUrl(log.url))
|
|
144
165
|
return;
|
|
@@ -152,18 +173,143 @@ const addOrUpdateLog = (log) => {
|
|
|
152
173
|
logs = logs.slice(0, maxNetworkLogsLimit);
|
|
153
174
|
notify();
|
|
154
175
|
};
|
|
176
|
+
let isInsideFetch = false;
|
|
155
177
|
export const setupNetworkLogger = () => {
|
|
156
178
|
if (globalThis.__NETWORK_LOGGER_INITIALIZED__)
|
|
157
179
|
return;
|
|
158
180
|
globalThis.__NETWORK_LOGGER__ = addOrUpdateLog;
|
|
181
|
+
const globalXHR = globalThis.XMLHttpRequest;
|
|
182
|
+
if (globalXHR && globalXHR.prototype && !globalThis.__XHR_LOGGER_INITIALIZED__) {
|
|
183
|
+
globalThis.__XHR_LOGGER_INITIALIZED__ = true;
|
|
184
|
+
const originalOpen = globalXHR.prototype.open;
|
|
185
|
+
const originalSend = globalXHR.prototype.send;
|
|
186
|
+
const originalSetRequestHeader = globalXHR.prototype.setRequestHeader;
|
|
187
|
+
globalXHR.prototype.open = function (method, url, async, user, password) {
|
|
188
|
+
this.__logMethod = (method || "GET").toUpperCase();
|
|
189
|
+
this.__logUrl = typeof url === "string" ? url : String(url);
|
|
190
|
+
this.__logRequestHeaders = {};
|
|
191
|
+
this.__logStartTime = Date.now();
|
|
192
|
+
this.__logCaller = getCallerFromStack();
|
|
193
|
+
return originalOpen.apply(this, [method, url, async !== false, user, password]);
|
|
194
|
+
};
|
|
195
|
+
globalXHR.prototype.setRequestHeader = function (header, value) {
|
|
196
|
+
if (header && value != null) {
|
|
197
|
+
if (!this.__logRequestHeaders)
|
|
198
|
+
this.__logRequestHeaders = {};
|
|
199
|
+
this.__logRequestHeaders[header.toLowerCase()] = String(value);
|
|
200
|
+
}
|
|
201
|
+
return originalSetRequestHeader.apply(this, [header, value]);
|
|
202
|
+
};
|
|
203
|
+
globalXHR.prototype.send = function (body) {
|
|
204
|
+
if (!isNetworkModuleEnabled || isInsideFetch || this.__inAppInspectorTracked) {
|
|
205
|
+
return originalSend.apply(this, [body]);
|
|
206
|
+
}
|
|
207
|
+
const url = this.__logUrl || "";
|
|
208
|
+
const method = this.__logMethod || "GET";
|
|
209
|
+
if (shouldIgnoreUrl(url)) {
|
|
210
|
+
return originalSend.apply(this, [body]);
|
|
211
|
+
}
|
|
212
|
+
const id = counter++;
|
|
213
|
+
this.__logId = id;
|
|
214
|
+
const start = this.__logStartTime || Date.now();
|
|
215
|
+
const caller = this.__logCaller || "Unknown";
|
|
216
|
+
const requestHeaders = this.__logRequestHeaders;
|
|
217
|
+
let client = "xhr";
|
|
218
|
+
if (requestHeaders?.["apollographql-client-name"] ||
|
|
219
|
+
url.toLowerCase().includes("/graphql")) {
|
|
220
|
+
client = "apollo";
|
|
221
|
+
}
|
|
222
|
+
else if (caller.toLowerCase().includes("axios")) {
|
|
223
|
+
client = "axios";
|
|
224
|
+
}
|
|
225
|
+
const currentRoute = currentRouteProvider ? currentRouteProvider() : null;
|
|
226
|
+
addOrUpdateLog({
|
|
227
|
+
id,
|
|
228
|
+
url,
|
|
229
|
+
method,
|
|
230
|
+
startTime: start,
|
|
231
|
+
caller,
|
|
232
|
+
client,
|
|
233
|
+
routeInfo: currentRoute || undefined,
|
|
234
|
+
request: method === "GET" ? undefined : parseRequestData(body),
|
|
235
|
+
requestHeaders: Object.keys(requestHeaders || {}).length > 0 ? requestHeaders : undefined,
|
|
236
|
+
});
|
|
237
|
+
const onFinished = () => {
|
|
238
|
+
if (this.__logFinished)
|
|
239
|
+
return;
|
|
240
|
+
this.__logFinished = true;
|
|
241
|
+
const duration = Date.now() - start;
|
|
242
|
+
let responseData = null;
|
|
243
|
+
try {
|
|
244
|
+
if (this.responseType === "" || this.responseType === "text") {
|
|
245
|
+
const raw = this.responseText;
|
|
246
|
+
try {
|
|
247
|
+
responseData = JSON.parse(raw);
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
responseData = raw;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (this.responseType === "json") {
|
|
254
|
+
responseData = this.response;
|
|
255
|
+
}
|
|
256
|
+
else if (this.responseType === "blob") {
|
|
257
|
+
responseData = `[Blob: ${this.response?.size || 0} bytes]`;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
responseData = `[${this.responseType || "Unknown"} Data]`;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
responseData = this.response || null;
|
|
265
|
+
}
|
|
266
|
+
const rawRespHeaders = this.getAllResponseHeaders
|
|
267
|
+
? this.getAllResponseHeaders()
|
|
268
|
+
: "";
|
|
269
|
+
const responseHeaders = parseXHRResponseHeaders(rawRespHeaders);
|
|
270
|
+
addOrUpdateLog({
|
|
271
|
+
id,
|
|
272
|
+
url,
|
|
273
|
+
method,
|
|
274
|
+
status: this.status,
|
|
275
|
+
response: responseData,
|
|
276
|
+
duration,
|
|
277
|
+
startTime: start,
|
|
278
|
+
caller,
|
|
279
|
+
client,
|
|
280
|
+
responseHeaders,
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
const onErrorOrAbort = () => {
|
|
284
|
+
if (this.__logFinished)
|
|
285
|
+
return;
|
|
286
|
+
this.__logFinished = true;
|
|
287
|
+
const duration = Date.now() - start;
|
|
288
|
+
addOrUpdateLog({
|
|
289
|
+
id,
|
|
290
|
+
url,
|
|
291
|
+
method,
|
|
292
|
+
status: this.status || 0,
|
|
293
|
+
response: "Network request failed",
|
|
294
|
+
duration,
|
|
295
|
+
startTime: start,
|
|
296
|
+
caller,
|
|
297
|
+
client,
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
this.addEventListener("load", onFinished);
|
|
301
|
+
this.addEventListener("error", onErrorOrAbort);
|
|
302
|
+
this.addEventListener("abort", onErrorOrAbort);
|
|
303
|
+
this.addEventListener("timeout", onErrorOrAbort);
|
|
304
|
+
return originalSend.apply(this, [body]);
|
|
305
|
+
};
|
|
306
|
+
}
|
|
159
307
|
const originalFetch = globalThis.fetch;
|
|
160
308
|
if (originalFetch) {
|
|
161
309
|
globalThis.fetch = async (url, options = {}) => {
|
|
162
310
|
if (!isNetworkModuleEnabled)
|
|
163
311
|
return originalFetch(url, options);
|
|
164
312
|
const method = (options?.method || "GET").toUpperCase();
|
|
165
|
-
if (!ALLOWED_METHODS.includes(method))
|
|
166
|
-
return originalFetch(url, options);
|
|
167
313
|
const id = counter++;
|
|
168
314
|
const start = Date.now();
|
|
169
315
|
const finalUrl = typeof url === "string" ? url : url?.url;
|
|
@@ -171,18 +317,19 @@ export const setupNetworkLogger = () => {
|
|
|
171
317
|
return originalFetch(url, options);
|
|
172
318
|
let caller = "Unknown";
|
|
173
319
|
let requestHeaders;
|
|
174
|
-
let client =
|
|
320
|
+
let client = "fetch";
|
|
175
321
|
try {
|
|
176
322
|
requestHeaders = normaliseHeaders(options?.headers);
|
|
177
323
|
caller = getCallerFromStack();
|
|
178
|
-
if (requestHeaders?.[
|
|
179
|
-
|
|
324
|
+
if (requestHeaders?.["apollographql-client-name"] ||
|
|
325
|
+
finalUrl?.toLowerCase().includes("/graphql")) {
|
|
326
|
+
client = "apollo";
|
|
180
327
|
}
|
|
181
|
-
else if (requestHeaders?.[
|
|
182
|
-
client =
|
|
328
|
+
else if (requestHeaders?.["x-requested-with"]?.toLowerCase().includes("xmlhttprequest")) {
|
|
329
|
+
client = "xhr";
|
|
183
330
|
}
|
|
184
|
-
else if (caller?.toLowerCase().includes(
|
|
185
|
-
client =
|
|
331
|
+
else if (caller?.toLowerCase().includes("axios")) {
|
|
332
|
+
client = "axios";
|
|
186
333
|
}
|
|
187
334
|
const currentRoute = currentRouteProvider ? currentRouteProvider() : null;
|
|
188
335
|
addOrUpdateLog({
|
|
@@ -199,7 +346,14 @@ export const setupNetworkLogger = () => {
|
|
|
199
346
|
}
|
|
200
347
|
catch { }
|
|
201
348
|
try {
|
|
202
|
-
|
|
349
|
+
isInsideFetch = true;
|
|
350
|
+
let response;
|
|
351
|
+
try {
|
|
352
|
+
response = await originalFetch(url, options);
|
|
353
|
+
}
|
|
354
|
+
finally {
|
|
355
|
+
isInsideFetch = false;
|
|
356
|
+
}
|
|
203
357
|
const duration = Date.now() - start;
|
|
204
358
|
try {
|
|
205
359
|
const responseHeaders = normaliseHeaders(response.headers);
|
|
@@ -282,8 +436,6 @@ export const setupNetworkLogger = () => {
|
|
|
282
436
|
export const addAxiosInterceptors = (axiosInstance) => {
|
|
283
437
|
axiosInstance.interceptors.request.use(async (config) => {
|
|
284
438
|
const method = (config.method || "GET").toUpperCase();
|
|
285
|
-
if (!ALLOWED_METHODS.includes(method))
|
|
286
|
-
return config;
|
|
287
439
|
const id = counter++;
|
|
288
440
|
const start = Date.now();
|
|
289
441
|
const caller = getCallerFromStack();
|
|
@@ -302,7 +454,7 @@ export const addAxiosInterceptors = (axiosInstance) => {
|
|
|
302
454
|
method,
|
|
303
455
|
startTime: start,
|
|
304
456
|
caller,
|
|
305
|
-
client:
|
|
457
|
+
client: "axios",
|
|
306
458
|
routeInfo: currentRoute || undefined,
|
|
307
459
|
request: method === "GET" ? undefined : parseRequestData(config.data),
|
|
308
460
|
requestHeaders: normaliseHeaders(config.headers),
|
|
@@ -315,7 +467,7 @@ export const addAxiosInterceptors = (axiosInstance) => {
|
|
|
315
467
|
const start = config.__logStart;
|
|
316
468
|
const caller = config.__logCaller;
|
|
317
469
|
const method = (config.method || "GET").toUpperCase();
|
|
318
|
-
if (id == null
|
|
470
|
+
if (id == null)
|
|
319
471
|
return response;
|
|
320
472
|
let url = config.url ?? "";
|
|
321
473
|
if (!url.startsWith("http"))
|
|
@@ -329,7 +481,7 @@ export const addAxiosInterceptors = (axiosInstance) => {
|
|
|
329
481
|
startTime: start || Date.now(),
|
|
330
482
|
duration: start != null ? Date.now() - start : undefined,
|
|
331
483
|
caller,
|
|
332
|
-
client:
|
|
484
|
+
client: "axios",
|
|
333
485
|
responseHeaders: normaliseHeaders(response.headers),
|
|
334
486
|
});
|
|
335
487
|
return response;
|
|
@@ -339,7 +491,7 @@ export const addAxiosInterceptors = (axiosInstance) => {
|
|
|
339
491
|
const start = config.__logStart;
|
|
340
492
|
const caller = config.__logCaller;
|
|
341
493
|
const method = (config.method || "GET").toUpperCase();
|
|
342
|
-
if (id != null
|
|
494
|
+
if (id != null) {
|
|
343
495
|
let url = config.url ?? "";
|
|
344
496
|
if (!url.startsWith("http"))
|
|
345
497
|
url = `${config.baseURL ?? ""}${url}`;
|
|
@@ -352,10 +504,16 @@ export const addAxiosInterceptors = (axiosInstance) => {
|
|
|
352
504
|
startTime: start || Date.now(),
|
|
353
505
|
duration: start != null ? Date.now() - start : undefined,
|
|
354
506
|
caller,
|
|
355
|
-
client:
|
|
507
|
+
client: "axios",
|
|
356
508
|
responseHeaders: normaliseHeaders(error.response?.headers),
|
|
357
509
|
});
|
|
358
510
|
}
|
|
359
511
|
return Promise.reject(error);
|
|
360
512
|
});
|
|
361
513
|
};
|
|
514
|
+
if (typeof globalThis !== "undefined") {
|
|
515
|
+
try {
|
|
516
|
+
setupNetworkLogger();
|
|
517
|
+
}
|
|
518
|
+
catch { }
|
|
519
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NetworkLog, RouteInfo, DiffResult, JsonContent, StackFrameType } from '../types';
|
|
2
2
|
export * from './searchQueryParser';
|
|
3
3
|
export * from './memoryManager';
|
|
4
|
+
export * from './toast';
|
|
4
5
|
export declare const isLocalDebugEnvironment: () => boolean;
|
|
5
6
|
export declare const getDomainColor: (domain: string) => string;
|
|
6
7
|
export declare const formatDateTime: (timestamp: number) => string;
|
|
@@ -5,6 +5,7 @@ import { AppColors } from '../styles/AppColors';
|
|
|
5
5
|
import { DOMAIN_COLORS, DURATION_FAST_MS, DURATION_SLOW_MS } from '../constants';
|
|
6
6
|
export * from './searchQueryParser';
|
|
7
7
|
export * from './memoryManager';
|
|
8
|
+
export * from './toast';
|
|
8
9
|
export const isLocalDebugEnvironment = () => {
|
|
9
10
|
const isDev = typeof __DEV__ !== 'undefined' && Boolean(__DEV__);
|
|
10
11
|
const scriptURL = NativeModules.SourceCode?.scriptURL || '';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActiveTab } from '../types';
|
|
2
|
+
export declare function getFirebaseRemoteConfig(customInstance?: any): any;
|
|
3
|
+
export declare function isFirebaseRemoteConfigAvailable(customInstance?: any): boolean;
|
|
4
|
+
export declare function fetchRemoteConfigModuleStatus(customInstance?: any, fetchTimeoutMs?: number): Promise<Partial<Record<ActiveTab, boolean>> | null>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const MODULE_KEYS = [
|
|
2
|
+
'apis',
|
|
3
|
+
'logs',
|
|
4
|
+
'analytics',
|
|
5
|
+
'redux',
|
|
6
|
+
'storage',
|
|
7
|
+
'device',
|
|
8
|
+
'crash',
|
|
9
|
+
'bundle',
|
|
10
|
+
'performance',
|
|
11
|
+
'debugging',
|
|
12
|
+
];
|
|
13
|
+
let cachedRemoteConfigInstance = null;
|
|
14
|
+
export function getFirebaseRemoteConfig(customInstance) {
|
|
15
|
+
if (customInstance && typeof customInstance === 'object') {
|
|
16
|
+
cachedRemoteConfigInstance = customInstance;
|
|
17
|
+
return customInstance;
|
|
18
|
+
}
|
|
19
|
+
if (cachedRemoteConfigInstance) {
|
|
20
|
+
return cachedRemoteConfigInstance;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const rcModule = require('@react-native-firebase/remote-config');
|
|
24
|
+
const instance = typeof rcModule.default === 'function'
|
|
25
|
+
? rcModule.default()
|
|
26
|
+
: typeof rcModule === 'function'
|
|
27
|
+
? rcModule()
|
|
28
|
+
: rcModule;
|
|
29
|
+
cachedRemoteConfigInstance = instance;
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function isFirebaseRemoteConfigAvailable(customInstance) {
|
|
37
|
+
return Boolean(getFirebaseRemoteConfig(customInstance));
|
|
38
|
+
}
|
|
39
|
+
function extractValue(val) {
|
|
40
|
+
if (val === null || val === undefined)
|
|
41
|
+
return undefined;
|
|
42
|
+
if (typeof val === 'boolean')
|
|
43
|
+
return val;
|
|
44
|
+
if (typeof val === 'number')
|
|
45
|
+
return val !== 0;
|
|
46
|
+
if (typeof val === 'string') {
|
|
47
|
+
const lower = val.trim().toLowerCase();
|
|
48
|
+
if (lower === 'true' || lower === '1' || lower === 'enabled' || lower === 'on')
|
|
49
|
+
return true;
|
|
50
|
+
if (lower === 'false' || lower === '0' || lower === 'disabled' || lower === 'off')
|
|
51
|
+
return false;
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(val);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (typeof val.asBoolean === 'function') {
|
|
60
|
+
return val.asBoolean();
|
|
61
|
+
}
|
|
62
|
+
if (typeof val.asString === 'function') {
|
|
63
|
+
const str = val.asString();
|
|
64
|
+
const lower = str.trim().toLowerCase();
|
|
65
|
+
if (lower === 'true' || lower === '1' || lower === 'enabled' || lower === 'on')
|
|
66
|
+
return true;
|
|
67
|
+
if (lower === 'false' || lower === '0' || lower === 'disabled' || lower === 'off')
|
|
68
|
+
return false;
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(str);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
export async function fetchRemoteConfigModuleStatus(customInstance, fetchTimeoutMs = 8000) {
|
|
79
|
+
const rc = getFirebaseRemoteConfig(customInstance);
|
|
80
|
+
if (!rc) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const fetchPromise = (async () => {
|
|
85
|
+
if (typeof rc.fetchAndActivate === 'function') {
|
|
86
|
+
await rc.fetchAndActivate();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (typeof rc.fetch === 'function') {
|
|
90
|
+
await rc.fetch();
|
|
91
|
+
}
|
|
92
|
+
if (typeof rc.activate === 'function') {
|
|
93
|
+
await rc.activate();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})();
|
|
97
|
+
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error('Remote Config fetch timeout')), fetchTimeoutMs));
|
|
98
|
+
await Promise.race([fetchPromise, timeoutPromise]).catch(() => {
|
|
99
|
+
});
|
|
100
|
+
const result = {};
|
|
101
|
+
const jsonKeys = [
|
|
102
|
+
'inspector_modules',
|
|
103
|
+
'inapp_inspector_modules',
|
|
104
|
+
'react_native_inapp_inspector_modules',
|
|
105
|
+
];
|
|
106
|
+
for (const jKey of jsonKeys) {
|
|
107
|
+
let rawVal;
|
|
108
|
+
if (typeof rc.getValue === 'function') {
|
|
109
|
+
try {
|
|
110
|
+
rawVal = rc.getValue(jKey);
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
}
|
|
114
|
+
else if (rc[jKey] !== undefined) {
|
|
115
|
+
rawVal = rc[jKey];
|
|
116
|
+
}
|
|
117
|
+
const parsed = extractValue(rawVal);
|
|
118
|
+
if (parsed && typeof parsed === 'object') {
|
|
119
|
+
for (const modKey of MODULE_KEYS) {
|
|
120
|
+
if (typeof parsed[modKey] === 'boolean') {
|
|
121
|
+
result[modKey] = parsed[modKey];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const modKey of MODULE_KEYS) {
|
|
127
|
+
const paramKeys = [
|
|
128
|
+
`inspector_module_${modKey}`,
|
|
129
|
+
`inapp_inspector_${modKey}`,
|
|
130
|
+
`inspector_${modKey}`,
|
|
131
|
+
`inapp_inspector_module_${modKey}`,
|
|
132
|
+
`rn_inspector_${modKey}`,
|
|
133
|
+
];
|
|
134
|
+
for (const pKey of paramKeys) {
|
|
135
|
+
let rawVal;
|
|
136
|
+
if (typeof rc.getValue === 'function') {
|
|
137
|
+
try {
|
|
138
|
+
rawVal = rc.getValue(pKey);
|
|
139
|
+
}
|
|
140
|
+
catch { }
|
|
141
|
+
}
|
|
142
|
+
else if (rc[pKey] !== undefined) {
|
|
143
|
+
rawVal = rc[pKey];
|
|
144
|
+
}
|
|
145
|
+
const boolVal = extractValue(rawVal);
|
|
146
|
+
if (typeof boolVal === 'boolean') {
|
|
147
|
+
result[modKey] = boolVal;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (result.apis === undefined) {
|
|
153
|
+
result.apis = true;
|
|
154
|
+
}
|
|
155
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -4,4 +4,4 @@ export interface SearchQueryOptions {
|
|
|
4
4
|
isRegex?: boolean;
|
|
5
5
|
isCaseSensitive?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function matchNetworkLogQuery(log: NetworkLog, searchQuery: string, routePath?: string,
|
|
7
|
+
export declare function matchNetworkLogQuery(log: NetworkLog, searchQuery: string, routePath?: string, _options?: SearchQueryOptions): boolean;
|