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.
Files changed (70) hide show
  1. package/android/build.gradle +36 -0
  2. package/android/src/main/AndroidManifest.xml +3 -0
  3. package/android/src/main/java/com/inappinspector/NetworkInspectorModule.java +114 -0
  4. package/android/src/main/java/com/inappinspector/NetworkInspectorPackage.java +28 -0
  5. package/dist/commonjs/components/ErrorBoundary.d.ts +1 -1
  6. package/dist/commonjs/components/ErrorBoundary.js +9 -145
  7. package/dist/commonjs/components/Inspector/CrashDetail.d.ts +3 -0
  8. package/dist/commonjs/components/Inspector/CrashDetail.js +796 -0
  9. package/dist/commonjs/components/Inspector/CrashFilterModal.d.ts +20 -0
  10. package/dist/commonjs/components/Inspector/CrashFilterModal.js +597 -0
  11. package/dist/commonjs/components/Inspector/CrashTab.d.ts +3 -0
  12. package/dist/commonjs/components/Inspector/CrashTab.js +727 -0
  13. package/dist/commonjs/components/Inspector/InspectorHeader.js +52 -23
  14. package/dist/commonjs/components/Inspector/LogDetail.js +4 -3
  15. package/dist/commonjs/components/Inspector/MainScreen.js +12 -3
  16. package/dist/commonjs/components/Inspector/SettingsPanel.js +90 -1
  17. package/dist/commonjs/components/Inspector/TabBar.js +15 -3
  18. package/dist/commonjs/components/NetworkIcons.d.ts +11 -0
  19. package/dist/commonjs/components/NetworkIcons.js +96 -1
  20. package/dist/commonjs/components/SegmentedTabs.js +2 -1
  21. package/dist/commonjs/constants/version.d.ts +1 -1
  22. package/dist/commonjs/constants/version.js +1 -1
  23. package/dist/commonjs/customHooks/analyticsLogger.js +70 -44
  24. package/dist/commonjs/customHooks/consoleLogger.d.ts +1 -0
  25. package/dist/commonjs/customHooks/consoleLogger.js +70 -6
  26. package/dist/commonjs/customHooks/crashHandler.d.ts +64 -0
  27. package/dist/commonjs/customHooks/crashHandler.js +681 -0
  28. package/dist/commonjs/customHooks/networkLogger.js +64 -48
  29. package/dist/commonjs/helpers/gaAnalyticsRegistry.js +1 -1
  30. package/dist/commonjs/i18n/locales/en.json +131 -0
  31. package/dist/commonjs/index.d.ts +3 -1
  32. package/dist/commonjs/index.js +95 -1
  33. package/dist/commonjs/types/enums.d.ts +41 -0
  34. package/dist/commonjs/types/enums.js +37 -1
  35. package/dist/commonjs/types/interfaces.d.ts +51 -1
  36. package/dist/esm/components/ErrorBoundary.d.ts +1 -1
  37. package/dist/esm/components/ErrorBoundary.js +10 -113
  38. package/dist/esm/components/Inspector/CrashDetail.d.ts +3 -0
  39. package/dist/esm/components/Inspector/CrashDetail.js +758 -0
  40. package/dist/esm/components/Inspector/CrashFilterModal.d.ts +20 -0
  41. package/dist/esm/components/Inspector/CrashFilterModal.js +557 -0
  42. package/dist/esm/components/Inspector/CrashTab.d.ts +3 -0
  43. package/dist/esm/components/Inspector/CrashTab.js +689 -0
  44. package/dist/esm/components/Inspector/InspectorHeader.js +52 -23
  45. package/dist/esm/components/Inspector/LogDetail.js +4 -3
  46. package/dist/esm/components/Inspector/MainScreen.js +12 -3
  47. package/dist/esm/components/Inspector/SettingsPanel.js +91 -2
  48. package/dist/esm/components/Inspector/TabBar.js +16 -4
  49. package/dist/esm/components/NetworkIcons.d.ts +11 -0
  50. package/dist/esm/components/NetworkIcons.js +83 -0
  51. package/dist/esm/components/SegmentedTabs.js +2 -1
  52. package/dist/esm/constants/version.d.ts +1 -1
  53. package/dist/esm/constants/version.js +1 -1
  54. package/dist/esm/customHooks/analyticsLogger.js +70 -44
  55. package/dist/esm/customHooks/consoleLogger.d.ts +1 -0
  56. package/dist/esm/customHooks/consoleLogger.js +68 -5
  57. package/dist/esm/customHooks/crashHandler.d.ts +64 -0
  58. package/dist/esm/customHooks/crashHandler.js +659 -0
  59. package/dist/esm/customHooks/networkLogger.js +64 -48
  60. package/dist/esm/helpers/gaAnalyticsRegistry.js +1 -1
  61. package/dist/esm/i18n/locales/en.json +131 -0
  62. package/dist/esm/index.d.ts +3 -1
  63. package/dist/esm/index.js +73 -1
  64. package/dist/esm/types/enums.d.ts +41 -0
  65. package/dist/esm/types/enums.js +36 -0
  66. package/dist/esm/types/interfaces.d.ts +51 -1
  67. package/ios/NetworkInspectorModule.h +6 -0
  68. package/ios/NetworkInspectorModule.m +125 -0
  69. package/package.json +5 -2
  70. package/react-native-inapp-inspector.podspec +18 -0
@@ -109,70 +109,90 @@ const setupAnalyticsLogger = (analyticsInstance) => {
109
109
  // ── logEvent ──────────────────────────────────────────────────────────────
110
110
  const originalLogEvent = analyticsInstance.logEvent.bind(analyticsInstance);
111
111
  analyticsInstance.logEvent = async (name, params) => {
112
- addEvent({
113
- id: counter++,
114
- name,
115
- params: params ?? {},
116
- userProperties: { ...currentUserProperties },
117
- timestamp: Date.now(),
118
- source: 'firebase',
119
- userId: currentUserId ?? '',
120
- screenName: '',
121
- screenClass: '',
122
- });
112
+ try {
113
+ addEvent({
114
+ id: counter++,
115
+ name,
116
+ params: params ?? {},
117
+ userProperties: { ...currentUserProperties },
118
+ timestamp: Date.now(),
119
+ source: 'firebase',
120
+ userId: currentUserId ?? '',
121
+ screenName: '',
122
+ screenClass: '',
123
+ });
124
+ }
125
+ catch { }
123
126
  return originalLogEvent(name, params);
124
127
  };
125
128
  // ── logScreenView ─────────────────────────────────────────────────────────
126
129
  const originalLogScreenView = analyticsInstance.logScreenView.bind(analyticsInstance);
127
130
  analyticsInstance.logScreenView = async (params) => {
128
- addEvent({
129
- id: counter++,
130
- name: 'screen_view',
131
- params: params ?? {},
132
- userProperties: { ...currentUserProperties },
133
- timestamp: Date.now(),
134
- source: 'firebase',
135
- screenName: params?.screen_name ?? '',
136
- screenClass: params?.screen_class ?? '',
137
- userId: currentUserId ?? '',
138
- });
131
+ try {
132
+ addEvent({
133
+ id: counter++,
134
+ name: 'screen_view',
135
+ params: params ?? {},
136
+ userProperties: { ...currentUserProperties },
137
+ timestamp: Date.now(),
138
+ source: 'firebase',
139
+ screenName: params?.screen_name ?? '',
140
+ screenClass: params?.screen_class ?? '',
141
+ userId: currentUserId ?? '',
142
+ });
143
+ }
144
+ catch { }
139
145
  return originalLogScreenView(params);
140
146
  };
141
147
  // ── setUserProperty ───────────────────────────────────────────────────────
142
148
  const originalSetUserProperty = analyticsInstance.setUserProperty.bind(analyticsInstance);
143
149
  analyticsInstance.setUserProperty = async (name, value) => {
144
- if (value === null) {
145
- delete currentUserProperties[name];
146
- }
147
- else {
148
- currentUserProperties[name] = value;
150
+ try {
151
+ if (value === null) {
152
+ delete currentUserProperties[name];
153
+ }
154
+ else {
155
+ currentUserProperties[name] = value;
156
+ }
149
157
  }
158
+ catch { }
150
159
  return originalSetUserProperty(name, value);
151
160
  };
152
161
  // ── setUserProperties ─────────────────────────────────────────────────────
153
162
  const originalSetUserProperties = analyticsInstance.setUserProperties.bind(analyticsInstance);
154
163
  analyticsInstance.setUserProperties = async (properties) => {
155
- Object.entries(properties).forEach(([k, v]) => {
156
- if (v === null)
157
- delete currentUserProperties[k];
158
- else
159
- currentUserProperties[k] = v;
160
- });
164
+ try {
165
+ if (properties && typeof properties === 'object') {
166
+ Object.entries(properties).forEach(([k, v]) => {
167
+ if (v === null)
168
+ delete currentUserProperties[k];
169
+ else
170
+ currentUserProperties[k] = v;
171
+ });
172
+ }
173
+ }
174
+ catch { }
161
175
  return originalSetUserProperties(properties);
162
176
  };
163
177
  // ── setUserId ─────────────────────────────────────────────────────────────
164
178
  const originalSetUserId = analyticsInstance.setUserId.bind(analyticsInstance);
165
179
  analyticsInstance.setUserId = async (id) => {
166
- currentUserId = id ?? undefined;
167
- notify();
180
+ try {
181
+ currentUserId = id ?? undefined;
182
+ notify();
183
+ }
184
+ catch { }
168
185
  return originalSetUserId(id);
169
186
  };
170
187
  // ── setDefaultEventParameters ──────────────────────────────────────────────
171
188
  if (typeof analyticsInstance.setDefaultEventParameters === 'function') {
172
189
  const originalSetDefaultEventParameters = analyticsInstance.setDefaultEventParameters.bind(analyticsInstance);
173
190
  analyticsInstance.setDefaultEventParameters = async (params) => {
174
- currentDefaultEventParameters = params ?? {};
175
- notify();
191
+ try {
192
+ currentDefaultEventParameters = params ?? {};
193
+ notify();
194
+ }
195
+ catch { }
176
196
  return originalSetDefaultEventParameters(params);
177
197
  };
178
198
  }
@@ -180,8 +200,11 @@ const setupAnalyticsLogger = (analyticsInstance) => {
180
200
  if (typeof analyticsInstance.setAnalyticsCollectionEnabled === 'function') {
181
201
  const originalSetAnalyticsCollectionEnabled = analyticsInstance.setAnalyticsCollectionEnabled.bind(analyticsInstance);
182
202
  analyticsInstance.setAnalyticsCollectionEnabled = async (enabled) => {
183
- isCollectionEnabled = enabled;
184
- notify();
203
+ try {
204
+ isCollectionEnabled = enabled;
205
+ notify();
206
+ }
207
+ catch { }
185
208
  return originalSetAnalyticsCollectionEnabled(enabled);
186
209
  };
187
210
  }
@@ -189,11 +212,14 @@ const setupAnalyticsLogger = (analyticsInstance) => {
189
212
  if (typeof analyticsInstance.resetAnalyticsData === 'function') {
190
213
  const originalResetAnalyticsData = analyticsInstance.resetAnalyticsData.bind(analyticsInstance);
191
214
  analyticsInstance.resetAnalyticsData = async () => {
192
- (0, exports.clearAnalyticsEvents)();
193
- currentUserProperties = {};
194
- currentUserId = undefined;
195
- currentDefaultEventParameters = {};
196
- notify();
215
+ try {
216
+ (0, exports.clearAnalyticsEvents)();
217
+ currentUserProperties = {};
218
+ currentUserId = undefined;
219
+ currentDefaultEventParameters = {};
220
+ notify();
221
+ }
222
+ catch { }
197
223
  return originalResetAnalyticsData();
198
224
  };
199
225
  }
@@ -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,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupConsoleLogger = exports.getConsoleLogs = exports.clearConsoleLogs = exports.subscribeConsoleLogs = void 0;
3
+ exports.setupConsoleLogger = exports.getConsoleLogs = exports.clearConsoleLogs = exports.subscribeConsoleLogs = exports.addLogFromCrash = void 0;
4
4
  const react_native_1 = require("react-native");
5
5
  const logFilters_1 = require("./logFilters");
6
+ const crashHandler_1 = require("./crashHandler");
6
7
  let logs = [];
7
8
  let listeners = [];
8
9
  let counter = 0;
@@ -282,6 +283,44 @@ const addLog = (type, args, sourceMethod) => {
282
283
  }
283
284
  };
284
285
  // ─── Public API ───────────────────────────────────────────────────────────────
286
+ const addLogFromCrash = (error, message, stack, isFatal) => {
287
+ const { caller, errorStack } = getStackDetails([error]);
288
+ const newLog = {
289
+ id: counter++,
290
+ type: 'error',
291
+ message: message || (error?.message ?? 'Runtime Crash'),
292
+ timestamp: Date.now(),
293
+ caller: caller !== 'Unknown'
294
+ ? caller
295
+ : isFatal
296
+ ? 'Fatal Crash'
297
+ : 'Unhandled Exception',
298
+ stack: stack || error?.stack || errorStack,
299
+ errorStack: stack || error?.stack,
300
+ rawArgs: [error],
301
+ sourceMethod: 'error',
302
+ };
303
+ logs.unshift(newLog);
304
+ logs = logs.slice(0, MAX_LOGS);
305
+ notify();
306
+ const stackToSym = stack || error?.stack || errorStack;
307
+ if (stackToSym && typeof __DEV__ !== 'undefined' && __DEV__) {
308
+ symbolicateStack(stackToSym)
309
+ .then(symFrames => {
310
+ if (symFrames && Array.isArray(symFrames) && symFrames.length > 0) {
311
+ const symLines = symFrames.map(f => `at ${f.methodName || '<anonymous>'} (${(f.file || '').replace(/^webpack:\/\/\/?/, '')}:${f.lineNumber ?? 0}:${f.column ?? 0})`);
312
+ const target = logs.find(l => l.id === newLog.id);
313
+ if (target) {
314
+ target.stack = symLines.join('\n');
315
+ notify();
316
+ }
317
+ }
318
+ })
319
+ .catch(() => { });
320
+ }
321
+ return newLog;
322
+ };
323
+ exports.addLogFromCrash = addLogFromCrash;
285
324
  const subscribeConsoleLogs = (callback) => {
286
325
  listeners.push(callback);
287
326
  callback([...logs]);
@@ -308,24 +347,49 @@ const setupConsoleLogger = () => {
308
347
  };
309
348
  // Intercept console.log
310
349
  console.log = (...args) => {
311
- addLog('info', args, 'log');
350
+ try {
351
+ addLog('info', args, 'log');
352
+ }
353
+ catch { }
312
354
  originalConsole.log(...args);
313
355
  };
314
356
  // Intercept console.info
315
357
  console.info = (...args) => {
316
- addLog('info', args, 'info');
358
+ try {
359
+ addLog('info', args, 'info');
360
+ }
361
+ catch { }
317
362
  originalConsole.info(...args);
318
363
  };
319
364
  // Intercept console.warn
320
365
  console.warn = (...args) => {
321
- addLog('warn', args, 'warn');
366
+ try {
367
+ addLog('warn', args, 'warn');
368
+ }
369
+ catch { }
322
370
  originalConsole.warn(...args);
323
371
  };
324
372
  // Intercept console.error
325
373
  console.error = (...args) => {
326
- addLog('error', args, 'error');
327
- originalConsole.error(...args);
374
+ try {
375
+ addLog('error', args, 'error');
376
+ }
377
+ catch { }
378
+ const firstArg = args && args[0];
379
+ const isRenderError = typeof firstArg === 'string' &&
380
+ (firstArg.includes('The above error occurred in') ||
381
+ firstArg.includes('Render Error') ||
382
+ firstArg.includes('ReferenceError') ||
383
+ firstArg.includes('TypeError'));
384
+ // Suppress console.error if it's a React render crash to prevent RedBox dialog
385
+ if (!isRenderError) {
386
+ originalConsole.error(...args);
387
+ }
328
388
  };
389
+ try {
390
+ (0, crashHandler_1.setupGlobalCrashHandler)();
391
+ }
392
+ catch { }
329
393
  globalThis.__CONSOLE_LOGGER_INITIALIZED__ = true;
330
394
  };
331
395
  exports.setupConsoleLogger = setupConsoleLogger;
@@ -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;