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
@@ -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
- addEvent({
102
- id: counter++,
103
- name,
104
- params: params ?? {},
105
- userProperties: { ...currentUserProperties },
106
- timestamp: Date.now(),
107
- source: 'firebase',
108
- userId: currentUserId ?? '',
109
- screenName: '',
110
- screenClass: '',
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
- addEvent({
118
- id: counter++,
119
- name: 'screen_view',
120
- params: params ?? {},
121
- userProperties: { ...currentUserProperties },
122
- timestamp: Date.now(),
123
- source: 'firebase',
124
- screenName: params?.screen_name ?? '',
125
- screenClass: params?.screen_class ?? '',
126
- userId: currentUserId ?? '',
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
- if (value === null) {
134
- delete currentUserProperties[name];
135
- }
136
- else {
137
- currentUserProperties[name] = value;
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
- Object.entries(properties).forEach(([k, v]) => {
145
- if (v === null)
146
- delete currentUserProperties[k];
147
- else
148
- currentUserProperties[k] = v;
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
- currentUserId = id ?? undefined;
156
- notify();
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
- currentDefaultEventParameters = params ?? {};
164
- notify();
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
- isCollectionEnabled = enabled;
173
- notify();
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
- clearAnalyticsEvents();
182
- currentUserProperties = {};
183
- currentUserId = undefined;
184
- currentDefaultEventParameters = {};
185
- notify();
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
- addLog('info', args, 'log');
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
- addLog('info', args, 'info');
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
- addLog('warn', args, 'warn');
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
- addLog('error', args, 'error');
321
- originalConsole.error(...args);
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;