react-native-inapp-inspector 1.1.25 → 1.1.26
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/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/inappinspector/NetworkInspectorModule.java +114 -0
- package/android/src/main/java/com/inappinspector/NetworkInspectorPackage.java +28 -0
- package/dist/commonjs/components/ErrorBoundary.d.ts +1 -1
- package/dist/commonjs/components/ErrorBoundary.js +9 -145
- package/dist/commonjs/components/Inspector/CrashDetail.d.ts +3 -0
- package/dist/commonjs/components/Inspector/CrashDetail.js +796 -0
- package/dist/commonjs/components/Inspector/CrashFilterModal.d.ts +20 -0
- package/dist/commonjs/components/Inspector/CrashFilterModal.js +597 -0
- package/dist/commonjs/components/Inspector/CrashTab.d.ts +3 -0
- package/dist/commonjs/components/Inspector/CrashTab.js +727 -0
- package/dist/commonjs/components/Inspector/InspectorHeader.js +52 -23
- package/dist/commonjs/components/Inspector/LogDetail.js +4 -3
- package/dist/commonjs/components/Inspector/MainScreen.js +12 -3
- package/dist/commonjs/components/Inspector/SettingsPanel.js +90 -1
- package/dist/commonjs/components/Inspector/TabBar.js +15 -3
- package/dist/commonjs/components/NetworkIcons.d.ts +11 -0
- package/dist/commonjs/components/NetworkIcons.js +96 -1
- package/dist/commonjs/components/SegmentedTabs.js +2 -1
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/analyticsLogger.js +70 -44
- package/dist/commonjs/customHooks/consoleLogger.d.ts +1 -0
- package/dist/commonjs/customHooks/consoleLogger.js +70 -6
- package/dist/commonjs/customHooks/crashHandler.d.ts +64 -0
- package/dist/commonjs/customHooks/crashHandler.js +681 -0
- package/dist/commonjs/customHooks/networkLogger.js +64 -48
- package/dist/commonjs/helpers/gaAnalyticsRegistry.js +1 -1
- package/dist/commonjs/i18n/locales/en.json +131 -0
- package/dist/commonjs/index.d.ts +3 -1
- package/dist/commonjs/index.js +95 -1
- package/dist/commonjs/types/enums.d.ts +41 -0
- package/dist/commonjs/types/enums.js +37 -1
- package/dist/commonjs/types/interfaces.d.ts +51 -1
- package/dist/esm/components/ErrorBoundary.d.ts +1 -1
- package/dist/esm/components/ErrorBoundary.js +10 -113
- package/dist/esm/components/Inspector/CrashDetail.d.ts +3 -0
- package/dist/esm/components/Inspector/CrashDetail.js +758 -0
- package/dist/esm/components/Inspector/CrashFilterModal.d.ts +20 -0
- package/dist/esm/components/Inspector/CrashFilterModal.js +557 -0
- package/dist/esm/components/Inspector/CrashTab.d.ts +3 -0
- package/dist/esm/components/Inspector/CrashTab.js +689 -0
- package/dist/esm/components/Inspector/InspectorHeader.js +52 -23
- package/dist/esm/components/Inspector/LogDetail.js +4 -3
- package/dist/esm/components/Inspector/MainScreen.js +12 -3
- package/dist/esm/components/Inspector/SettingsPanel.js +91 -2
- package/dist/esm/components/Inspector/TabBar.js +16 -4
- package/dist/esm/components/NetworkIcons.d.ts +11 -0
- package/dist/esm/components/NetworkIcons.js +83 -0
- package/dist/esm/components/SegmentedTabs.js +2 -1
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/analyticsLogger.js +70 -44
- package/dist/esm/customHooks/consoleLogger.d.ts +1 -0
- package/dist/esm/customHooks/consoleLogger.js +68 -5
- package/dist/esm/customHooks/crashHandler.d.ts +64 -0
- package/dist/esm/customHooks/crashHandler.js +659 -0
- package/dist/esm/customHooks/networkLogger.js +64 -48
- package/dist/esm/helpers/gaAnalyticsRegistry.js +1 -1
- package/dist/esm/i18n/locales/en.json +131 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +73 -1
- package/dist/esm/types/enums.d.ts +41 -0
- package/dist/esm/types/enums.js +36 -0
- package/dist/esm/types/interfaces.d.ts +51 -1
- package/ios/NetworkInspectorModule.h +6 -0
- package/ios/NetworkInspectorModule.m +125 -0
- package/package.json +5 -2
- package/react-native-inapp-inspector.podspec +18 -0
|
@@ -98,70 +98,90 @@ export const setupAnalyticsLogger = (analyticsInstance) => {
|
|
|
98
98
|
// ── logEvent ──────────────────────────────────────────────────────────────
|
|
99
99
|
const originalLogEvent = analyticsInstance.logEvent.bind(analyticsInstance);
|
|
100
100
|
analyticsInstance.logEvent = async (name, params) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
try {
|
|
102
|
+
addEvent({
|
|
103
|
+
id: counter++,
|
|
104
|
+
name,
|
|
105
|
+
params: params ?? {},
|
|
106
|
+
userProperties: { ...currentUserProperties },
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
source: 'firebase',
|
|
109
|
+
userId: currentUserId ?? '',
|
|
110
|
+
screenName: '',
|
|
111
|
+
screenClass: '',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
112
115
|
return originalLogEvent(name, params);
|
|
113
116
|
};
|
|
114
117
|
// ── logScreenView ─────────────────────────────────────────────────────────
|
|
115
118
|
const originalLogScreenView = analyticsInstance.logScreenView.bind(analyticsInstance);
|
|
116
119
|
analyticsInstance.logScreenView = async (params) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
try {
|
|
121
|
+
addEvent({
|
|
122
|
+
id: counter++,
|
|
123
|
+
name: 'screen_view',
|
|
124
|
+
params: params ?? {},
|
|
125
|
+
userProperties: { ...currentUserProperties },
|
|
126
|
+
timestamp: Date.now(),
|
|
127
|
+
source: 'firebase',
|
|
128
|
+
screenName: params?.screen_name ?? '',
|
|
129
|
+
screenClass: params?.screen_class ?? '',
|
|
130
|
+
userId: currentUserId ?? '',
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
catch { }
|
|
128
134
|
return originalLogScreenView(params);
|
|
129
135
|
};
|
|
130
136
|
// ── setUserProperty ───────────────────────────────────────────────────────
|
|
131
137
|
const originalSetUserProperty = analyticsInstance.setUserProperty.bind(analyticsInstance);
|
|
132
138
|
analyticsInstance.setUserProperty = async (name, value) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
try {
|
|
140
|
+
if (value === null) {
|
|
141
|
+
delete currentUserProperties[name];
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
currentUserProperties[name] = value;
|
|
145
|
+
}
|
|
138
146
|
}
|
|
147
|
+
catch { }
|
|
139
148
|
return originalSetUserProperty(name, value);
|
|
140
149
|
};
|
|
141
150
|
// ── setUserProperties ─────────────────────────────────────────────────────
|
|
142
151
|
const originalSetUserProperties = analyticsInstance.setUserProperties.bind(analyticsInstance);
|
|
143
152
|
analyticsInstance.setUserProperties = async (properties) => {
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
try {
|
|
154
|
+
if (properties && typeof properties === 'object') {
|
|
155
|
+
Object.entries(properties).forEach(([k, v]) => {
|
|
156
|
+
if (v === null)
|
|
157
|
+
delete currentUserProperties[k];
|
|
158
|
+
else
|
|
159
|
+
currentUserProperties[k] = v;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch { }
|
|
150
164
|
return originalSetUserProperties(properties);
|
|
151
165
|
};
|
|
152
166
|
// ── setUserId ─────────────────────────────────────────────────────────────
|
|
153
167
|
const originalSetUserId = analyticsInstance.setUserId.bind(analyticsInstance);
|
|
154
168
|
analyticsInstance.setUserId = async (id) => {
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
try {
|
|
170
|
+
currentUserId = id ?? undefined;
|
|
171
|
+
notify();
|
|
172
|
+
}
|
|
173
|
+
catch { }
|
|
157
174
|
return originalSetUserId(id);
|
|
158
175
|
};
|
|
159
176
|
// ── setDefaultEventParameters ──────────────────────────────────────────────
|
|
160
177
|
if (typeof analyticsInstance.setDefaultEventParameters === 'function') {
|
|
161
178
|
const originalSetDefaultEventParameters = analyticsInstance.setDefaultEventParameters.bind(analyticsInstance);
|
|
162
179
|
analyticsInstance.setDefaultEventParameters = async (params) => {
|
|
163
|
-
|
|
164
|
-
|
|
180
|
+
try {
|
|
181
|
+
currentDefaultEventParameters = params ?? {};
|
|
182
|
+
notify();
|
|
183
|
+
}
|
|
184
|
+
catch { }
|
|
165
185
|
return originalSetDefaultEventParameters(params);
|
|
166
186
|
};
|
|
167
187
|
}
|
|
@@ -169,8 +189,11 @@ export const setupAnalyticsLogger = (analyticsInstance) => {
|
|
|
169
189
|
if (typeof analyticsInstance.setAnalyticsCollectionEnabled === 'function') {
|
|
170
190
|
const originalSetAnalyticsCollectionEnabled = analyticsInstance.setAnalyticsCollectionEnabled.bind(analyticsInstance);
|
|
171
191
|
analyticsInstance.setAnalyticsCollectionEnabled = async (enabled) => {
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
try {
|
|
193
|
+
isCollectionEnabled = enabled;
|
|
194
|
+
notify();
|
|
195
|
+
}
|
|
196
|
+
catch { }
|
|
174
197
|
return originalSetAnalyticsCollectionEnabled(enabled);
|
|
175
198
|
};
|
|
176
199
|
}
|
|
@@ -178,11 +201,14 @@ export const setupAnalyticsLogger = (analyticsInstance) => {
|
|
|
178
201
|
if (typeof analyticsInstance.resetAnalyticsData === 'function') {
|
|
179
202
|
const originalResetAnalyticsData = analyticsInstance.resetAnalyticsData.bind(analyticsInstance);
|
|
180
203
|
analyticsInstance.resetAnalyticsData = async () => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
204
|
+
try {
|
|
205
|
+
clearAnalyticsEvents();
|
|
206
|
+
currentUserProperties = {};
|
|
207
|
+
currentUserId = undefined;
|
|
208
|
+
currentDefaultEventParameters = {};
|
|
209
|
+
notify();
|
|
210
|
+
}
|
|
211
|
+
catch { }
|
|
186
212
|
return originalResetAnalyticsData();
|
|
187
213
|
};
|
|
188
214
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConsoleLog } from '../types';
|
|
2
|
+
export declare const addLogFromCrash: (error: any, message: string, stack?: string, isFatal?: boolean) => ConsoleLog;
|
|
2
3
|
export declare const subscribeConsoleLogs: (callback: (logs: ConsoleLog[]) => void) => () => void;
|
|
3
4
|
export declare const clearConsoleLogs: () => void;
|
|
4
5
|
export declare const getConsoleLogs: () => ConsoleLog[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
2
|
import { IGNORED_LOG_PREFIXES } from './logFilters';
|
|
3
|
+
import { setupGlobalCrashHandler } from './crashHandler';
|
|
3
4
|
let logs = [];
|
|
4
5
|
let listeners = [];
|
|
5
6
|
let counter = 0;
|
|
@@ -279,6 +280,43 @@ const addLog = (type, args, sourceMethod) => {
|
|
|
279
280
|
}
|
|
280
281
|
};
|
|
281
282
|
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
283
|
+
export const addLogFromCrash = (error, message, stack, isFatal) => {
|
|
284
|
+
const { caller, errorStack } = getStackDetails([error]);
|
|
285
|
+
const newLog = {
|
|
286
|
+
id: counter++,
|
|
287
|
+
type: 'error',
|
|
288
|
+
message: message || (error?.message ?? 'Runtime Crash'),
|
|
289
|
+
timestamp: Date.now(),
|
|
290
|
+
caller: caller !== 'Unknown'
|
|
291
|
+
? caller
|
|
292
|
+
: isFatal
|
|
293
|
+
? 'Fatal Crash'
|
|
294
|
+
: 'Unhandled Exception',
|
|
295
|
+
stack: stack || error?.stack || errorStack,
|
|
296
|
+
errorStack: stack || error?.stack,
|
|
297
|
+
rawArgs: [error],
|
|
298
|
+
sourceMethod: 'error',
|
|
299
|
+
};
|
|
300
|
+
logs.unshift(newLog);
|
|
301
|
+
logs = logs.slice(0, MAX_LOGS);
|
|
302
|
+
notify();
|
|
303
|
+
const stackToSym = stack || error?.stack || errorStack;
|
|
304
|
+
if (stackToSym && typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
305
|
+
symbolicateStack(stackToSym)
|
|
306
|
+
.then(symFrames => {
|
|
307
|
+
if (symFrames && Array.isArray(symFrames) && symFrames.length > 0) {
|
|
308
|
+
const symLines = symFrames.map(f => `at ${f.methodName || '<anonymous>'} (${(f.file || '').replace(/^webpack:\/\/\/?/, '')}:${f.lineNumber ?? 0}:${f.column ?? 0})`);
|
|
309
|
+
const target = logs.find(l => l.id === newLog.id);
|
|
310
|
+
if (target) {
|
|
311
|
+
target.stack = symLines.join('\n');
|
|
312
|
+
notify();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
.catch(() => { });
|
|
317
|
+
}
|
|
318
|
+
return newLog;
|
|
319
|
+
};
|
|
282
320
|
export const subscribeConsoleLogs = (callback) => {
|
|
283
321
|
listeners.push(callback);
|
|
284
322
|
callback([...logs]);
|
|
@@ -302,23 +340,48 @@ export const setupConsoleLogger = () => {
|
|
|
302
340
|
};
|
|
303
341
|
// Intercept console.log
|
|
304
342
|
console.log = (...args) => {
|
|
305
|
-
|
|
343
|
+
try {
|
|
344
|
+
addLog('info', args, 'log');
|
|
345
|
+
}
|
|
346
|
+
catch { }
|
|
306
347
|
originalConsole.log(...args);
|
|
307
348
|
};
|
|
308
349
|
// Intercept console.info
|
|
309
350
|
console.info = (...args) => {
|
|
310
|
-
|
|
351
|
+
try {
|
|
352
|
+
addLog('info', args, 'info');
|
|
353
|
+
}
|
|
354
|
+
catch { }
|
|
311
355
|
originalConsole.info(...args);
|
|
312
356
|
};
|
|
313
357
|
// Intercept console.warn
|
|
314
358
|
console.warn = (...args) => {
|
|
315
|
-
|
|
359
|
+
try {
|
|
360
|
+
addLog('warn', args, 'warn');
|
|
361
|
+
}
|
|
362
|
+
catch { }
|
|
316
363
|
originalConsole.warn(...args);
|
|
317
364
|
};
|
|
318
365
|
// Intercept console.error
|
|
319
366
|
console.error = (...args) => {
|
|
320
|
-
|
|
321
|
-
|
|
367
|
+
try {
|
|
368
|
+
addLog('error', args, 'error');
|
|
369
|
+
}
|
|
370
|
+
catch { }
|
|
371
|
+
const firstArg = args && args[0];
|
|
372
|
+
const isRenderError = typeof firstArg === 'string' &&
|
|
373
|
+
(firstArg.includes('The above error occurred in') ||
|
|
374
|
+
firstArg.includes('Render Error') ||
|
|
375
|
+
firstArg.includes('ReferenceError') ||
|
|
376
|
+
firstArg.includes('TypeError'));
|
|
377
|
+
// Suppress console.error if it's a React render crash to prevent RedBox dialog
|
|
378
|
+
if (!isRenderError) {
|
|
379
|
+
originalConsole.error(...args);
|
|
380
|
+
}
|
|
322
381
|
};
|
|
382
|
+
try {
|
|
383
|
+
setupGlobalCrashHandler();
|
|
384
|
+
}
|
|
385
|
+
catch { }
|
|
323
386
|
globalThis.__CONSOLE_LOGGER_INITIALIZED__ = true;
|
|
324
387
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CrashRecord, ParsedStackFrame, CrashBreadcrumb } from '../types';
|
|
2
|
+
import { CrashExportFormat, CrashType } from '../types/enums';
|
|
3
|
+
export interface CrashEventPayload {
|
|
4
|
+
error: Error | any;
|
|
5
|
+
isFatal?: boolean;
|
|
6
|
+
message: string;
|
|
7
|
+
stack?: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
logId?: number;
|
|
10
|
+
crashRecord?: CrashRecord;
|
|
11
|
+
}
|
|
12
|
+
export { CrashExportFormat };
|
|
13
|
+
type CrashListener = (payload: CrashEventPayload) => void;
|
|
14
|
+
export declare const setMaxCrashLogsLimit: (max: number) => void;
|
|
15
|
+
export declare const addCrashBreadcrumb: (type: CrashBreadcrumb["type"], message: string, data?: any) => void;
|
|
16
|
+
export declare const recordNavigationBreadcrumb: (fromRoute: string, toRoute: string) => void;
|
|
17
|
+
export declare const recordNetworkBreadcrumb: (url: string, method: string, status?: number, duration?: number) => void;
|
|
18
|
+
export declare const recordReduxBreadcrumb: (actionType: string, payload?: any) => void;
|
|
19
|
+
export declare const recordUserActionBreadcrumb: (action: string, metadata?: any) => void;
|
|
20
|
+
export declare const clearCrashBreadcrumbs: () => void;
|
|
21
|
+
export declare const getCrashBreadcrumbs: () => CrashBreadcrumb[];
|
|
22
|
+
/**
|
|
23
|
+
* Intelligent stack trace parser with multi-engine support:
|
|
24
|
+
* - Hermes bytecode & source maps
|
|
25
|
+
* - Android Java / Kotlin native frames
|
|
26
|
+
* - iOS Objective-C / Swift symbols
|
|
27
|
+
* - JavaScript standard V8 & SpiderMonkey
|
|
28
|
+
*/
|
|
29
|
+
export declare const parseCrashStackTrace: (stack?: string) => ParsedStackFrame[];
|
|
30
|
+
/**
|
|
31
|
+
* Computes a unique fingerprint signature to group recurring crash occurrences.
|
|
32
|
+
*/
|
|
33
|
+
export declare const computeCrashFingerprint: (crash: CrashRecord) => string;
|
|
34
|
+
export declare const getCrashRecords: () => CrashRecord[];
|
|
35
|
+
export declare const clearCrashRecords: () => void;
|
|
36
|
+
export declare const subscribeCrashEvents: (listener: CrashListener) => (() => void);
|
|
37
|
+
export declare const emitCrashEvent: (payload: CrashEventPayload) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Core exception interceptor. Ingests all forms of errors, parses call stacks,
|
|
40
|
+
* collects device telemetry, records breadcrumbs, and updates the store.
|
|
41
|
+
*/
|
|
42
|
+
export declare const handleInterceptedCrash: (errorOrTitle: any, rawStack?: any, isFatal?: boolean, customType?: CrashType, componentStack?: string) => CrashRecord;
|
|
43
|
+
/**
|
|
44
|
+
* Manually report a caught error with custom metadata.
|
|
45
|
+
*/
|
|
46
|
+
export declare const recordCustomCrash: (error: Error | string, options?: {
|
|
47
|
+
isFatal?: boolean;
|
|
48
|
+
type?: CrashType;
|
|
49
|
+
componentStack?: string;
|
|
50
|
+
}) => CrashRecord;
|
|
51
|
+
/**
|
|
52
|
+
* Simulates a crash for developer testing without crashing the host app.
|
|
53
|
+
* Uses real runtime Error objects — no mocked file paths or fake stacks.
|
|
54
|
+
*/
|
|
55
|
+
export declare const simulateTestCrash: (type?: CrashType, customMessage?: string, customStack?: string) => CrashRecord;
|
|
56
|
+
/**
|
|
57
|
+
* Formats a crash into Text, Markdown, or JSON.
|
|
58
|
+
*/
|
|
59
|
+
export declare const exportCrashReport: (crash: CrashRecord, format?: CrashExportFormat) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Natively intercepts and prevents crashes, native RedBox dialogues,
|
|
62
|
+
* unhandled JS errors, and unhandled promise rejections.
|
|
63
|
+
*/
|
|
64
|
+
export declare const setupGlobalCrashHandler: () => void;
|