react-native-inapp-inspector 2.0.1 → 2.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.
Files changed (42) hide show
  1. package/README.md +10 -0
  2. package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +23 -0
  3. package/dist/commonjs/components/AppHeaderLogo.js +21 -2
  4. package/dist/commonjs/components/Inspector/InspectorHeader.js +84 -11
  5. package/dist/commonjs/components/Inspector/MainScreen.js +8 -0
  6. package/dist/commonjs/components/Inspector/NpmUpdateToast.d.ts +3 -0
  7. package/dist/commonjs/components/Inspector/NpmUpdateToast.js +288 -0
  8. package/dist/commonjs/components/Inspector/SettingsPanel.js +192 -1
  9. package/dist/commonjs/components/Inspector/TelemetryConsentModal.d.ts +3 -0
  10. package/dist/commonjs/components/Inspector/TelemetryConsentModal.js +359 -0
  11. package/dist/commonjs/constants/version.d.ts +1 -1
  12. package/dist/commonjs/constants/version.js +1 -1
  13. package/dist/commonjs/helpers/index.d.ts +1 -0
  14. package/dist/commonjs/helpers/index.js +1 -0
  15. package/dist/commonjs/helpers/telemetry.d.ts +99 -0
  16. package/dist/commonjs/helpers/telemetry.js +398 -0
  17. package/dist/commonjs/index.d.ts +2 -0
  18. package/dist/commonjs/index.js +37 -3
  19. package/dist/commonjs/native/NativeInspector.d.ts +5 -0
  20. package/dist/commonjs/native/NativeInspector.js +3 -2
  21. package/dist/commonjs/types/interfaces.d.ts +5 -0
  22. package/dist/esm/components/AppHeaderLogo.js +21 -2
  23. package/dist/esm/components/Inspector/InspectorHeader.js +85 -12
  24. package/dist/esm/components/Inspector/MainScreen.js +8 -0
  25. package/dist/esm/components/Inspector/NpmUpdateToast.d.ts +3 -0
  26. package/dist/esm/components/Inspector/NpmUpdateToast.js +251 -0
  27. package/dist/esm/components/Inspector/SettingsPanel.js +192 -1
  28. package/dist/esm/components/Inspector/TelemetryConsentModal.d.ts +3 -0
  29. package/dist/esm/components/Inspector/TelemetryConsentModal.js +322 -0
  30. package/dist/esm/constants/version.d.ts +1 -1
  31. package/dist/esm/constants/version.js +1 -1
  32. package/dist/esm/helpers/index.d.ts +1 -0
  33. package/dist/esm/helpers/index.js +1 -0
  34. package/dist/esm/helpers/telemetry.d.ts +99 -0
  35. package/dist/esm/helpers/telemetry.js +380 -0
  36. package/dist/esm/index.d.ts +2 -0
  37. package/dist/esm/index.js +27 -3
  38. package/dist/esm/native/NativeInspector.d.ts +5 -0
  39. package/dist/esm/native/NativeInspector.js +3 -2
  40. package/dist/esm/types/interfaces.d.ts +5 -0
  41. package/ios/{NetworkInspectorModule.m → NetworkInspectorModule.mm} +175 -119
  42. package/package.json +2 -2
@@ -0,0 +1,99 @@
1
+ export declare const GA4_MEASUREMENT_ID = "G-XXXXXXXXXX";
2
+ export declare const GA4_API_SECRET = "YOUR_GA4_API_SECRET";
3
+ /**
4
+ * Asynchronously loads host application and device metadata (strictly non-PII/technical).
5
+ */
6
+ export declare function loadAppDiagnosticsAsync(): Promise<Record<string, any>>;
7
+ /**
8
+ * Returns the developer's telemetry consent status.
9
+ */
10
+ export declare function getTelemetryConsentStatus(): Promise<'granted' | 'declined' | 'undetermined'>;
11
+ /**
12
+ * Saves the developer's telemetry consent choice.
13
+ */
14
+ export declare function setTelemetryConsent(granted: boolean): Promise<void>;
15
+ /**
16
+ * Checks if the user or environment has opted out of telemetry.
17
+ */
18
+ export declare function isTelemetryOptedOut(explicitSetting?: boolean): boolean;
19
+ /**
20
+ * Track an anonymous event via GA4 Measurement Protocol.
21
+ */
22
+ export declare function trackTelemetryEvent(eventName: string, params?: Record<string, any>, options?: {
23
+ telemetry?: boolean;
24
+ force?: boolean;
25
+ }): Promise<void>;
26
+ /**
27
+ * 1. Session initialization heartbeat ping.
28
+ */
29
+ export declare function sendSessionTelemetryPing(options?: {
30
+ telemetry?: boolean;
31
+ environment?: string;
32
+ hasNavigation?: boolean;
33
+ hasAppIcon?: boolean;
34
+ force?: boolean;
35
+ }): Promise<void>;
36
+ /**
37
+ * 2. Track when the inspector modal is opened.
38
+ */
39
+ export declare function trackInspectorOpen(options?: {
40
+ activeTab?: string;
41
+ openSource?: 'fab' | 'shake' | 'programmatic';
42
+ telemetry?: boolean;
43
+ }): void;
44
+ /**
45
+ * 3. Track when the inspector modal is closed.
46
+ */
47
+ export declare function trackInspectorClose(options?: {
48
+ telemetry?: boolean;
49
+ }): void;
50
+ /**
51
+ * 4. Track tab / page view navigation inside the inspector.
52
+ */
53
+ export declare function trackTabSwitch(tabName: string, options?: {
54
+ telemetry?: boolean;
55
+ fromTab?: string;
56
+ }): void;
57
+ /**
58
+ * 5. Track network API interaction (inspect details, copy cURL, retry).
59
+ */
60
+ export declare function trackNetworkInteraction(action: 'view_detail' | 'copy_curl' | 'retry_request' | 'copy_url' | 'clear_logs' | 'export_har', options?: {
61
+ method?: string;
62
+ statusCode?: number;
63
+ durationMs?: number;
64
+ telemetry?: boolean;
65
+ }): void;
66
+ /**
67
+ * 6. Track Redux / State management interaction.
68
+ */
69
+ export declare function trackReduxInteraction(action: 'view_diff' | 'view_state' | 'view_action' | 'filter_reducer', options?: {
70
+ reducerName?: string;
71
+ telemetry?: boolean;
72
+ }): void;
73
+ /**
74
+ * 7. Track Crash & Exception interaction.
75
+ */
76
+ export declare function trackCrashInteraction(action: 'view_crash_detail' | 'share_crash_report' | 'copy_stacktrace' | 'clear_crashes', options?: {
77
+ crashType?: string;
78
+ telemetry?: boolean;
79
+ }): void;
80
+ /**
81
+ * 8. Track Performance monitoring tab interaction.
82
+ */
83
+ export declare function trackPerformanceInteraction(subTab: 'fps' | 'memory' | 'rerenders' | 'bundles', options?: {
84
+ telemetry?: boolean;
85
+ }): void;
86
+ /**
87
+ * 9. Track search queries and filter applications.
88
+ */
89
+ export declare function trackSearchOrFilter(target: 'apis' | 'console' | 'redux' | 'crashes' | 'analytics', actionType: 'search_query' | 'status_filter' | 'method_filter' | 'tag_filter', options?: {
90
+ filterValue?: string;
91
+ telemetry?: boolean;
92
+ }): void;
93
+ /**
94
+ * 10. Track when logs / reports are exported or shared.
95
+ */
96
+ export declare function trackLogExport(exportType: 'logs_json' | 'logs_har' | 'curl' | 'crash_report', options?: {
97
+ telemetry?: boolean;
98
+ count?: number;
99
+ }): void;
@@ -0,0 +1,398 @@
1
+ "use strict";
2
+ // ─── Google Analytics 4 (GA4) Measurement Protocol Telemetry ───────────────
3
+ //
4
+ // Comprehensive, anonymous usage telemetry for react-native-inapp-inspector.
5
+ //
6
+ // - NEVER collects user PII, auth tokens, device names, or network payload bodies.
7
+ // - Zero main-thread blocking; 100% fail-safe fire-and-forget.
8
+ // - Full environment diagnostics (Hermes, New Arch, RN version, screen size, UI mode).
9
+ // - Tracks developer interactions: tab switches, page views, search, exports, retries.
10
+ // - Supports opt-out via `telemetry={false}` or `DO_NOT_TRACK=1`.
11
+ // ─────────────────────────────────────────────────────────────────────────────
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.GA4_API_SECRET = exports.GA4_MEASUREMENT_ID = void 0;
14
+ exports.loadAppDiagnosticsAsync = loadAppDiagnosticsAsync;
15
+ exports.getTelemetryConsentStatus = getTelemetryConsentStatus;
16
+ exports.setTelemetryConsent = setTelemetryConsent;
17
+ exports.isTelemetryOptedOut = isTelemetryOptedOut;
18
+ exports.trackTelemetryEvent = trackTelemetryEvent;
19
+ exports.sendSessionTelemetryPing = sendSessionTelemetryPing;
20
+ exports.trackInspectorOpen = trackInspectorOpen;
21
+ exports.trackInspectorClose = trackInspectorClose;
22
+ exports.trackTabSwitch = trackTabSwitch;
23
+ exports.trackNetworkInteraction = trackNetworkInteraction;
24
+ exports.trackReduxInteraction = trackReduxInteraction;
25
+ exports.trackCrashInteraction = trackCrashInteraction;
26
+ exports.trackPerformanceInteraction = trackPerformanceInteraction;
27
+ exports.trackSearchOrFilter = trackSearchOrFilter;
28
+ exports.trackLogExport = trackLogExport;
29
+ const react_native_1 = require("react-native");
30
+ const constants_1 = require("../constants");
31
+ const NativeInspector_1 = require("../native/NativeInspector");
32
+ // ─── GA4 Measurement Protocol Configuration ──────────────────────────────────
33
+ // Automatically replaced at build-time from .env by scripts/inject-telemetry.js
34
+ exports.GA4_MEASUREMENT_ID = 'G-XXXXXXXXXX';
35
+ exports.GA4_API_SECRET = 'YOUR_GA4_API_SECRET';
36
+ const GA4_ENDPOINT = 'https://www.google-analytics.com/mp/collect';
37
+ const CLIENT_ID_KEY = 'telemetry_client_id';
38
+ // Stable session ID created once per JavaScript runtime instance
39
+ const CURRENT_SESSION_ID = String(Math.floor(Date.now() / 1000));
40
+ let hasPingedSession = false;
41
+ let cachedClientId = null;
42
+ let lastModalOpenTimestamp = 0;
43
+ let cachedAppDiagnostics = null;
44
+ /**
45
+ * Generates an anonymous, pseudorandom UUIDv4-like string for client grouping.
46
+ * Contains zero hardware or personal identifiers.
47
+ */
48
+ function generateAnonymousClientId() {
49
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
50
+ const r = (Math.random() * 16) | 0;
51
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
52
+ return v.toString(16);
53
+ });
54
+ }
55
+ /**
56
+ * Retrieves or generates the anonymous client identifier.
57
+ */
58
+ async function getOrCreateClientId() {
59
+ if (cachedClientId)
60
+ return cachedClientId;
61
+ try {
62
+ const stored = await (0, NativeInspector_1.getNativeStorageItem)(CLIENT_ID_KEY);
63
+ if (stored && typeof stored === 'string' && stored.length > 0) {
64
+ cachedClientId = stored;
65
+ return stored;
66
+ }
67
+ }
68
+ catch {
69
+ // Fallback to memory
70
+ }
71
+ const newId = generateAnonymousClientId();
72
+ cachedClientId = newId;
73
+ try {
74
+ await (0, NativeInspector_1.setNativeStorageItem)(CLIENT_ID_KEY, newId);
75
+ }
76
+ catch {
77
+ // Silently ignore storage errors
78
+ }
79
+ return newId;
80
+ }
81
+ /**
82
+ * Asynchronously loads host application and device metadata (strictly non-PII/technical).
83
+ */
84
+ async function loadAppDiagnosticsAsync() {
85
+ if (cachedAppDiagnostics)
86
+ return cachedAppDiagnostics;
87
+ try {
88
+ const metrics = await (0, NativeInspector_1.getNativeDeviceMetrics)();
89
+ cachedAppDiagnostics = {
90
+ app_name: metrics?.appName ||
91
+ react_native_1.Platform.constants?.appName ||
92
+ 'unknown',
93
+ app_version: metrics?.appVersion ||
94
+ react_native_1.Platform.constants?.appVersion ||
95
+ 'unknown',
96
+ app_build: metrics?.appBuild || 'unknown',
97
+ app_bundle_id: metrics?.appBundleId || metrics?.appPackageName || 'unknown',
98
+ device_brand: metrics?.deviceBrand ||
99
+ react_native_1.Platform.constants?.Brand ||
100
+ react_native_1.Platform.constants?.systemName ||
101
+ 'unknown',
102
+ device_model: metrics?.deviceModel ||
103
+ react_native_1.Platform.constants?.Model ||
104
+ react_native_1.Platform.constants?.interfaceIdiom ||
105
+ 'unknown',
106
+ };
107
+ }
108
+ catch {
109
+ cachedAppDiagnostics = {
110
+ app_name: react_native_1.Platform.constants?.appName || 'unknown',
111
+ app_version: react_native_1.Platform.constants?.appVersion || 'unknown',
112
+ app_build: 'unknown',
113
+ app_bundle_id: 'unknown',
114
+ device_brand: react_native_1.Platform.constants?.Brand || 'unknown',
115
+ device_model: react_native_1.Platform.constants?.Model || 'unknown',
116
+ };
117
+ }
118
+ return cachedAppDiagnostics;
119
+ }
120
+ /**
121
+ * Extracts React Native framework version string (e.g. "0.81.4").
122
+ */
123
+ function getReactNativeVersion() {
124
+ try {
125
+ const constants = react_native_1.Platform.constants;
126
+ if (constants && constants.reactNativeVersion) {
127
+ const { major, minor, patch, prerelease } = constants.reactNativeVersion;
128
+ return `${major}.${minor}.${patch}${prerelease ? `-${prerelease}` : ''}`;
129
+ }
130
+ }
131
+ catch {
132
+ // Fallback
133
+ }
134
+ return 'unknown';
135
+ }
136
+ /**
137
+ * Collects complete anonymous device, host app & runtime environment diagnostics.
138
+ */
139
+ function getEnvironmentDiagnostics(extraParams = {}) {
140
+ const isHermes = Boolean(global.HermesInternal);
141
+ const isNewArch = Boolean(global._RN_FABRIC_ENABLED || global.__turboModuleProxy);
142
+ const isNativeLinked = (0, NativeInspector_1.isNativeModuleAvailable)();
143
+ const rnVersion = getReactNativeVersion();
144
+ const isExpo = Boolean(global?.expo?.modules?.ExponentConstants ||
145
+ global?.__expo ||
146
+ (typeof process !== 'undefined' &&
147
+ process?.env?.EXPO_PUBLIC_PROJECT_ROOT));
148
+ let screenResolution = 'unknown';
149
+ let fontScale = 1;
150
+ try {
151
+ const { width, height, scale, fontScale: fs } = react_native_1.Dimensions.get('window');
152
+ screenResolution = `${Math.round(width)}x${Math.round(height)}@${scale}x`;
153
+ fontScale = fs || 1;
154
+ }
155
+ catch {
156
+ // Ignore dimension errors
157
+ }
158
+ let colorScheme = 'unknown';
159
+ try {
160
+ colorScheme = react_native_1.Appearance.getColorScheme() || 'unspecified';
161
+ }
162
+ catch {
163
+ // Ignore appearance errors
164
+ }
165
+ const appMeta = cachedAppDiagnostics || {
166
+ app_name: react_native_1.Platform.constants?.appName || 'unknown',
167
+ app_version: react_native_1.Platform.constants?.appVersion || 'unknown',
168
+ app_build: 'unknown',
169
+ app_bundle_id: 'unknown',
170
+ device_brand: react_native_1.Platform.constants?.Brand ||
171
+ react_native_1.Platform.constants?.systemName ||
172
+ 'unknown',
173
+ device_model: react_native_1.Platform.constants?.Model ||
174
+ react_native_1.Platform.constants?.interfaceIdiom ||
175
+ 'unknown',
176
+ };
177
+ return {
178
+ session_id: CURRENT_SESSION_ID,
179
+ engagement_time_msec: 100,
180
+ lib_version: constants_1.LIB_VERSION,
181
+ platform: react_native_1.Platform.OS,
182
+ os_version: String(react_native_1.Platform.Version),
183
+ rn_version: rnVersion,
184
+ is_hermes: isHermes,
185
+ is_new_arch: isNewArch,
186
+ is_native_linked: isNativeLinked,
187
+ is_expo: isExpo,
188
+ is_dev: Boolean(typeof __DEV__ !== 'undefined' && __DEV__),
189
+ screen_resolution: screenResolution,
190
+ font_scale: fontScale,
191
+ color_scheme: colorScheme,
192
+ ...appMeta,
193
+ ...extraParams,
194
+ };
195
+ }
196
+ const CONSENT_STORAGE_KEY = 'telemetry_consent_status';
197
+ let cachedConsentStatus = null;
198
+ /**
199
+ * Returns the developer's telemetry consent status.
200
+ */
201
+ async function getTelemetryConsentStatus() {
202
+ if (cachedConsentStatus)
203
+ return cachedConsentStatus;
204
+ try {
205
+ const stored = await (0, NativeInspector_1.getNativeStorageItem)(CONSENT_STORAGE_KEY);
206
+ if (stored === 'granted' || stored === 'declined') {
207
+ cachedConsentStatus = stored;
208
+ return stored;
209
+ }
210
+ }
211
+ catch {
212
+ // Fallback
213
+ }
214
+ return 'undetermined';
215
+ }
216
+ /**
217
+ * Saves the developer's telemetry consent choice.
218
+ */
219
+ async function setTelemetryConsent(granted) {
220
+ const status = granted ? 'granted' : 'declined';
221
+ cachedConsentStatus = status;
222
+ try {
223
+ await (0, NativeInspector_1.setNativeStorageItem)(CONSENT_STORAGE_KEY, status);
224
+ }
225
+ catch {
226
+ // Ignore storage errors
227
+ }
228
+ }
229
+ /**
230
+ * Checks if the user or environment has opted out of telemetry.
231
+ */
232
+ function isTelemetryOptedOut(explicitSetting) {
233
+ if (explicitSetting === false)
234
+ return true;
235
+ if (cachedConsentStatus === 'declined')
236
+ return true;
237
+ try {
238
+ if (typeof process !== 'undefined' &&
239
+ process?.env &&
240
+ (process.env.DO_NOT_TRACK === '1' || process.env.DISABLE_TELEMETRY === '1')) {
241
+ return true;
242
+ }
243
+ }
244
+ catch {
245
+ // Ignore environments where process is undefined or restricted
246
+ }
247
+ return false;
248
+ }
249
+ /**
250
+ * Track an anonymous event via GA4 Measurement Protocol.
251
+ */
252
+ async function trackTelemetryEvent(eventName, params = {}, options) {
253
+ if (isTelemetryOptedOut(options?.telemetry))
254
+ return;
255
+ // Don't send if credentials haven't been configured yet
256
+ if (!exports.GA4_MEASUREMENT_ID ||
257
+ exports.GA4_MEASUREMENT_ID === 'G-XXXXXXXXXX' ||
258
+ !exports.GA4_API_SECRET ||
259
+ exports.GA4_API_SECRET === 'YOUR_GA4_API_SECRET') {
260
+ return;
261
+ }
262
+ try {
263
+ const clientId = await getOrCreateClientId();
264
+ await loadAppDiagnosticsAsync();
265
+ const eventParams = getEnvironmentDiagnostics(params);
266
+ const payload = {
267
+ client_id: clientId,
268
+ events: [
269
+ {
270
+ name: eventName,
271
+ params: eventParams,
272
+ },
273
+ ],
274
+ };
275
+ const url = `${GA4_ENDPOINT}?measurement_id=${encodeURIComponent(exports.GA4_MEASUREMENT_ID)}&api_secret=${encodeURIComponent(exports.GA4_API_SECRET)}`;
276
+ fetch(url, {
277
+ method: 'POST',
278
+ headers: {
279
+ 'Content-Type': 'application/json',
280
+ },
281
+ body: JSON.stringify(payload),
282
+ }).catch(() => {
283
+ // If offline on initial cold start, allow a single delayed retry
284
+ if (eventName === 'inspector_session_init') {
285
+ hasPingedSession = false;
286
+ setTimeout(() => {
287
+ sendSessionTelemetryPing(options);
288
+ }, 8000);
289
+ }
290
+ });
291
+ }
292
+ catch {
293
+ // Fail silently
294
+ }
295
+ }
296
+ /**
297
+ * 1. Session initialization heartbeat ping.
298
+ */
299
+ async function sendSessionTelemetryPing(options) {
300
+ if (hasPingedSession && !options?.force)
301
+ return;
302
+ if (isTelemetryOptedOut(options?.telemetry))
303
+ return;
304
+ hasPingedSession = true;
305
+ await trackTelemetryEvent('inspector_session_init', {
306
+ environment: options?.environment || 'unknown',
307
+ has_navigation: Boolean(options?.hasNavigation),
308
+ has_app_icon: Boolean(options?.hasAppIcon),
309
+ }, options);
310
+ }
311
+ /**
312
+ * 2. Track when the inspector modal is opened.
313
+ */
314
+ function trackInspectorOpen(options) {
315
+ lastModalOpenTimestamp = Date.now();
316
+ trackTelemetryEvent('inspector_open', {
317
+ open_source: options?.openSource || 'fab',
318
+ active_tab: options?.activeTab || 'apis',
319
+ }, options);
320
+ }
321
+ /**
322
+ * 3. Track when the inspector modal is closed.
323
+ */
324
+ function trackInspectorClose(options) {
325
+ const durationSec = lastModalOpenTimestamp > 0
326
+ ? Math.round((Date.now() - lastModalOpenTimestamp) / 1000)
327
+ : 0;
328
+ trackTelemetryEvent('inspector_close', {
329
+ open_duration_seconds: durationSec,
330
+ }, options);
331
+ }
332
+ /**
333
+ * 4. Track tab / page view navigation inside the inspector.
334
+ */
335
+ function trackTabSwitch(tabName, options) {
336
+ trackTelemetryEvent('page_view', {
337
+ page_title: `Tab: ${tabName}`,
338
+ page_location: `inapp-inspector://tab/${tabName}`,
339
+ tab_name: tabName,
340
+ from_tab: options?.fromTab || 'unknown',
341
+ }, options);
342
+ }
343
+ /**
344
+ * 5. Track network API interaction (inspect details, copy cURL, retry).
345
+ */
346
+ function trackNetworkInteraction(action, options) {
347
+ trackTelemetryEvent('network_interaction', {
348
+ action_type: action,
349
+ http_method: options?.method || 'GET',
350
+ status_code: options?.statusCode || 0,
351
+ duration_ms: options?.durationMs || 0,
352
+ }, options);
353
+ }
354
+ /**
355
+ * 6. Track Redux / State management interaction.
356
+ */
357
+ function trackReduxInteraction(action, options) {
358
+ trackTelemetryEvent('redux_interaction', {
359
+ action_type: action,
360
+ reducer_name: options?.reducerName || 'root',
361
+ }, options);
362
+ }
363
+ /**
364
+ * 7. Track Crash & Exception interaction.
365
+ */
366
+ function trackCrashInteraction(action, options) {
367
+ trackTelemetryEvent('crash_interaction', {
368
+ action_type: action,
369
+ crash_type: options?.crashType || 'js_exception',
370
+ }, options);
371
+ }
372
+ /**
373
+ * 8. Track Performance monitoring tab interaction.
374
+ */
375
+ function trackPerformanceInteraction(subTab, options) {
376
+ trackTelemetryEvent('performance_interaction', {
377
+ sub_tab: subTab,
378
+ }, options);
379
+ }
380
+ /**
381
+ * 9. Track search queries and filter applications.
382
+ */
383
+ function trackSearchOrFilter(target, actionType, options) {
384
+ trackTelemetryEvent('search_and_filter', {
385
+ target_tab: target,
386
+ action_type: actionType,
387
+ filter_value: options?.filterValue || 'all',
388
+ }, options);
389
+ }
390
+ /**
391
+ * 10. Track when logs / reports are exported or shared.
392
+ */
393
+ function trackLogExport(exportType, options) {
394
+ trackTelemetryEvent('log_export', {
395
+ export_type: exportType,
396
+ item_count: options?.count || 1,
397
+ }, options);
398
+ }
@@ -13,4 +13,6 @@ export { getEventCategory, registerGAPlugin, type GAPlugin, } from './helpers/ga
13
13
  export { usePerformanceTracker, useComponentProfiler, useNavigationProfiler, trackComponentRender, trackNavigationTransition, trackHeavyTask, measureAsync, getHermesMemoryStats, registerComponentProfile, subscribeRenderProfiles, getRenderProfiles, logPerformanceEvent, clearPerformanceEvents, subscribePerformanceEvents, getPerformanceEvents, getInitialRenderProfiles, getInitialPerformanceEvents, generateFixSnippet, } from './customHooks/performanceTracker';
14
14
  export { InspectLog, InspectTrackTime, InspectCatch, type InspectLogOptions, } from './decorators';
15
15
  export { getNativeDeviceMetrics, enableNativeCrashProtection, subscribeNativeCrashes, showNativeFloatingButton, hideNativeFloatingButton, setNativeFloatingButtonBadge, subscribeNativeFloatingButtonPress, subscribeNativeDeviceShake, startNativeFpsMonitoring, stopNativeFpsMonitoring, getNativeFpsMetrics, getNativeStorageItem, setNativeStorageItem, isNativeModuleAvailable, type NativeDeviceMetrics, type NativeCrashEvent, type FloatingButtonOptions, type NativeFpsMetrics, } from './native/NativeInspector';
16
+ export { sendSessionTelemetryPing, trackTelemetryEvent, trackInspectorOpen, trackTabSwitch, trackLogExport, GA4_MEASUREMENT_ID, GA4_API_SECRET, } from './helpers';
17
+ export { BrandSquareIcon, BrandCircleIcon, } from './components/NetworkIcons';
16
18
  export { ActiveTab, Method, StatusFilter, SortOrder, LocalFilter, ModalAnimationType, SettingsPage, SettingsSubTab, LogFilter, ConsoleLogType, AnalyticsEventSource, GAEventCategory, StackFrameType, DiffResultType, BundleSubTab, PerformanceSubTab, CrashType, CrashExportFormat, CrashDetailSubTab, CrashFilterType, BreadcrumbType, } from './types';
@@ -37,7 +37,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.registerComponentProfile = exports.getHermesMemoryStats = exports.measureAsync = exports.trackHeavyTask = exports.trackNavigationTransition = exports.trackComponentRender = exports.useNavigationProfiler = exports.useComponentProfiler = exports.usePerformanceTracker = exports.registerGAPlugin = exports.getEventCategory = exports.getLastActionForReducer = exports.clearActionHistory = exports.getActionHistory = exports.subscribeReduxState = exports.getReduxState = exports.inspectorReduxMiddleware = exports.connectReduxStore = exports.ErrorBoundary = exports.CrashTab = exports.computeCrashFingerprint = exports.recordUserActionBreadcrumb = exports.recordReduxBreadcrumb = exports.recordNetworkBreadcrumb = exports.recordNavigationBreadcrumb = exports.addCrashBreadcrumb = exports.recordCustomCrash = exports.parseCrashStackTrace = exports.exportCrashReport = exports.simulateTestCrash = exports.clearCrashRecords = exports.getCrashRecords = exports.emitCrashEvent = exports.subscribeCrashEvents = exports.setupGlobalCrashHandler = exports.getCollectionEnabled = exports.getDefaultEventParameters = exports.getCurrentUserId = exports.getCurrentUserProperties = exports.clearAnalyticsEvents = exports.subscribeAnalyticsEvents = exports.logAnalyticsEvent = exports.setupAnalyticsLogger = exports.subscribeConsoleLogs = exports.clearConsoleLogs = exports.setupConsoleLogger = exports.addAxiosInterceptors = exports.subscribeNetworkLogs = exports.clearNetworkLogs = exports.setupNetworkLogger = void 0;
40
- exports.BreadcrumbType = exports.CrashFilterType = exports.CrashDetailSubTab = exports.CrashExportFormat = exports.CrashType = exports.PerformanceSubTab = exports.BundleSubTab = exports.DiffResultType = exports.StackFrameType = exports.GAEventCategory = exports.AnalyticsEventSource = exports.ConsoleLogType = exports.LogFilter = exports.SettingsSubTab = exports.SettingsPage = exports.ModalAnimationType = exports.LocalFilter = exports.SortOrder = exports.StatusFilter = exports.Method = exports.ActiveTab = exports.isNativeModuleAvailable = exports.setNativeStorageItem = exports.getNativeStorageItem = exports.getNativeFpsMetrics = exports.stopNativeFpsMonitoring = exports.startNativeFpsMonitoring = exports.subscribeNativeDeviceShake = exports.subscribeNativeFloatingButtonPress = exports.setNativeFloatingButtonBadge = exports.hideNativeFloatingButton = exports.showNativeFloatingButton = exports.subscribeNativeCrashes = exports.enableNativeCrashProtection = exports.getNativeDeviceMetrics = exports.InspectCatch = exports.InspectTrackTime = exports.InspectLog = exports.generateFixSnippet = exports.getInitialPerformanceEvents = exports.getInitialRenderProfiles = exports.getPerformanceEvents = exports.subscribePerformanceEvents = exports.clearPerformanceEvents = exports.logPerformanceEvent = exports.getRenderProfiles = exports.subscribeRenderProfiles = void 0;
40
+ exports.BundleSubTab = exports.DiffResultType = exports.StackFrameType = exports.GAEventCategory = exports.AnalyticsEventSource = exports.ConsoleLogType = exports.LogFilter = exports.SettingsSubTab = exports.SettingsPage = exports.ModalAnimationType = exports.LocalFilter = exports.SortOrder = exports.StatusFilter = exports.Method = exports.ActiveTab = exports.BrandCircleIcon = exports.BrandSquareIcon = exports.GA4_API_SECRET = exports.GA4_MEASUREMENT_ID = exports.trackLogExport = exports.trackTabSwitch = exports.trackInspectorOpen = exports.trackTelemetryEvent = exports.sendSessionTelemetryPing = exports.isNativeModuleAvailable = exports.setNativeStorageItem = exports.getNativeStorageItem = exports.getNativeFpsMetrics = exports.stopNativeFpsMonitoring = exports.startNativeFpsMonitoring = exports.subscribeNativeDeviceShake = exports.subscribeNativeFloatingButtonPress = exports.setNativeFloatingButtonBadge = exports.hideNativeFloatingButton = exports.showNativeFloatingButton = exports.subscribeNativeCrashes = exports.enableNativeCrashProtection = exports.getNativeDeviceMetrics = exports.InspectCatch = exports.InspectTrackTime = exports.InspectLog = exports.generateFixSnippet = exports.getInitialPerformanceEvents = exports.getInitialRenderProfiles = exports.getPerformanceEvents = exports.subscribePerformanceEvents = exports.clearPerformanceEvents = exports.logPerformanceEvent = exports.getRenderProfiles = exports.subscribeRenderProfiles = void 0;
41
+ exports.BreadcrumbType = exports.CrashFilterType = exports.CrashDetailSubTab = exports.CrashExportFormat = exports.CrashType = exports.PerformanceSubTab = void 0;
41
42
  const react_1 = __importStar(require("react"));
42
43
  const react_native_1 = require("react-native");
43
44
  const native_1 = require("@react-navigation/native");
@@ -67,7 +68,7 @@ const NativeInspector_2 = require("./native/NativeInspector");
67
68
  const constants_1 = require("./constants");
68
69
  // Stylesheet
69
70
  const styles_1 = require("./styles");
70
- const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigationRef, appIcon, environment, }) => {
71
+ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigationRef, appIcon, environment, initialVisible, visible: controlledVisible, }) => {
71
72
  // Set custom storage synchronously during render phase
72
73
  (0, settingsStore_1.setCustomStorage)(storage || null);
73
74
  const [isDark, setIsDark] = (0, react_1.useState)(false);
@@ -79,7 +80,12 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
79
80
  const [modalHeightPercent, setModalHeightPercent] = (0, react_1.useState)(90);
80
81
  const [modalAnimationType, setModalAnimationType] = (0, react_1.useState)('slide');
81
82
  const [logs, setLogs] = (0, react_1.useState)([]);
82
- const [visible, setVisible] = (0, react_1.useState)(false);
83
+ const [visible, setVisible] = (0, react_1.useState)(initialVisible ?? controlledVisible ?? false);
84
+ (0, react_1.useEffect)(() => {
85
+ if (controlledVisible !== undefined) {
86
+ setVisible(controlledVisible);
87
+ }
88
+ }, [controlledVisible]);
83
89
  const [isReady, setIsReady] = (0, react_1.useState)(false);
84
90
  const [selected, setSelected] = (0, react_1.useState)(null);
85
91
  const [selectedLogs, setSelectedLogs] = (0, react_1.useState)(new Set());
@@ -224,6 +230,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
224
230
  // #6 — tab the inspector opens on. Shown with a DEFAULT badge in Settings.
225
231
  const [defaultTab, setDefaultTab] = (0, react_1.useState)('apis');
226
232
  const [showDuplicateLogs, setShowDuplicateLogs] = (0, react_1.useState)(false);
233
+ const [showUpdateToast, setShowUpdateToast] = (0, react_1.useState)(true);
227
234
  // Synchronize runtime background listeners with active settings
228
235
  (0, react_1.useEffect)(() => {
229
236
  (0, networkLogger_1.setNetworkModuleEnabled)(!!tabVisibility.apis);
@@ -283,6 +290,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
283
290
  setReduxAutoRefreshState(true);
284
291
  setReduxExpandDepth(1);
285
292
  setShowDuplicateLogs(false);
293
+ setShowUpdateToast(true);
286
294
  react_native_1.Alert.alert('Settings Reset', 'All settings have been reset to default values.');
287
295
  };
288
296
  // #5 — hydrate persisted settings once, then auto-save on any change.
@@ -326,6 +334,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
326
334
  setReduxExpandDepth(saved.reduxExpandDepth);
327
335
  if (saved.showDuplicateLogs != null)
328
336
  setShowDuplicateLogs(saved.showDuplicateLogs);
337
+ if (saved.showUpdateToast != null)
338
+ setShowUpdateToast(saved.showUpdateToast);
329
339
  if (saved.defaultTab) {
330
340
  const dt = saved.defaultTab;
331
341
  const vis = {
@@ -367,6 +377,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
367
377
  reduxAutoRefresh,
368
378
  reduxExpandDepth,
369
379
  showDuplicateLogs,
380
+ showUpdateToast,
370
381
  });
371
382
  }, [
372
383
  isDark,
@@ -739,6 +750,14 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
739
750
  }, [unreadPulseAnim]);
740
751
  const isNativeModule = (0, react_1.useMemo)(() => (0, NativeInspector_2.isNativeModuleAvailable)(), []);
741
752
  const useNativeFab = (react_native_1.Platform.OS === 'ios' || react_native_1.Platform.OS === 'android') && isNativeModule;
753
+ // Send anonymous initialization heartbeat to GA4 Measurement Protocol
754
+ (0, react_1.useEffect)(() => {
755
+ (0, helpers_1.sendSessionTelemetryPing)({
756
+ environment,
757
+ hasNavigation: Boolean(navigationRef),
758
+ hasAppIcon: Boolean(appIcon),
759
+ });
760
+ }, [environment, navigationRef, appIcon]);
742
761
  // 100% Native Main-Thread Floating Button Lifecycle
743
762
  (0, react_1.useEffect)(() => {
744
763
  if (!useNativeFab || !isEnabled || !enabled) {
@@ -793,6 +812,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
793
812
  ? defaultTab
794
813
  : 'apis';
795
814
  setActiveTab(target);
815
+ // Track inspector opened event in GA4
816
+ (0, helpers_1.trackInspectorOpen)({ activeTab: target });
796
817
  // Instant synchronization of data collected while modal was closed
797
818
  if (latestNetworkLogsRef.current.length > 0) {
798
819
  const deduped = (0, helpers_1.deduplicateLogs)(latestNetworkLogsRef.current);
@@ -1732,6 +1753,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
1732
1753
  setIsDark,
1733
1754
  showDuplicateLogs,
1734
1755
  setShowDuplicateLogs,
1756
+ showUpdateToast,
1757
+ setShowUpdateToast,
1735
1758
  showConsoleLevels,
1736
1759
  setShowConsoleLevels,
1737
1760
  resetToDefaults,
@@ -1855,6 +1878,17 @@ Object.defineProperty(exports, "getNativeFpsMetrics", { enumerable: true, get: f
1855
1878
  Object.defineProperty(exports, "getNativeStorageItem", { enumerable: true, get: function () { return NativeInspector_3.getNativeStorageItem; } });
1856
1879
  Object.defineProperty(exports, "setNativeStorageItem", { enumerable: true, get: function () { return NativeInspector_3.setNativeStorageItem; } });
1857
1880
  Object.defineProperty(exports, "isNativeModuleAvailable", { enumerable: true, get: function () { return NativeInspector_3.isNativeModuleAvailable; } });
1881
+ var helpers_2 = require("./helpers");
1882
+ Object.defineProperty(exports, "sendSessionTelemetryPing", { enumerable: true, get: function () { return helpers_2.sendSessionTelemetryPing; } });
1883
+ Object.defineProperty(exports, "trackTelemetryEvent", { enumerable: true, get: function () { return helpers_2.trackTelemetryEvent; } });
1884
+ Object.defineProperty(exports, "trackInspectorOpen", { enumerable: true, get: function () { return helpers_2.trackInspectorOpen; } });
1885
+ Object.defineProperty(exports, "trackTabSwitch", { enumerable: true, get: function () { return helpers_2.trackTabSwitch; } });
1886
+ Object.defineProperty(exports, "trackLogExport", { enumerable: true, get: function () { return helpers_2.trackLogExport; } });
1887
+ Object.defineProperty(exports, "GA4_MEASUREMENT_ID", { enumerable: true, get: function () { return helpers_2.GA4_MEASUREMENT_ID; } });
1888
+ Object.defineProperty(exports, "GA4_API_SECRET", { enumerable: true, get: function () { return helpers_2.GA4_API_SECRET; } });
1889
+ var NetworkIcons_1 = require("./components/NetworkIcons");
1890
+ Object.defineProperty(exports, "BrandSquareIcon", { enumerable: true, get: function () { return NetworkIcons_1.BrandSquareIcon; } });
1891
+ Object.defineProperty(exports, "BrandCircleIcon", { enumerable: true, get: function () { return NetworkIcons_1.BrandCircleIcon; } });
1858
1892
  var types_1 = require("./types");
1859
1893
  Object.defineProperty(exports, "ActiveTab", { enumerable: true, get: function () { return types_1.ActiveTab; } });
1860
1894
  Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return types_1.Method; } });
@@ -17,6 +17,11 @@ export interface NativeDeviceMetrics {
17
17
  osVersion?: string;
18
18
  apiLevel?: number;
19
19
  cpuAbi?: string;
20
+ appName?: string;
21
+ appVersion?: string;
22
+ appBuild?: string;
23
+ appBundleId?: string;
24
+ appPackageName?: string;
20
25
  }
21
26
  export interface NativeCrashEvent {
22
27
  platform: 'android' | 'ios';
@@ -12,8 +12,9 @@ const isNativeModuleAvailable = () => {
12
12
  return !!NativeModule;
13
13
  };
14
14
  exports.isNativeModuleAvailable = isNativeModuleAvailable;
15
- const nativeEmitter = (0, exports.isNativeModuleAvailable)()
16
- ? new react_native_1.NativeEventEmitter(NativeModule)
15
+ const eventTarget = react_native_1.NativeModules.NetworkInspectorModule || NativeNetworkInspector_1.default;
16
+ const nativeEmitter = eventTarget
17
+ ? new react_native_1.NativeEventEmitter(eventTarget)
17
18
  : null;
18
19
  /**
19
20
  * Retrieves low-level native hardware and system metrics (RAM, Heap, Disk, Battery, CPU).
@@ -151,6 +151,7 @@ export interface PersistedSettings {
151
151
  reduxAutoRefresh?: boolean;
152
152
  reduxExpandDepth?: number;
153
153
  showDuplicateLogs?: boolean;
154
+ showUpdateToast?: boolean;
154
155
  }
155
156
  export interface NetworkInspectorProps {
156
157
  enabled?: boolean;
@@ -160,6 +161,8 @@ export interface NetworkInspectorProps {
160
161
  navigationRef?: any;
161
162
  appIcon?: any;
162
163
  environment?: 'DEV' | 'UAT' | 'PrePROD' | 'PROD' | 'QA' | 'Staging' | string;
164
+ initialVisible?: boolean;
165
+ visible?: boolean;
163
166
  }
164
167
  export interface NavigationTrackerProps {
165
168
  onStateChange: (state: any) => void;
@@ -301,6 +304,8 @@ export interface InspectorContextValue {
301
304
  setIsDark: React.Dispatch<React.SetStateAction<boolean>>;
302
305
  showDuplicateLogs: boolean;
303
306
  setShowDuplicateLogs: React.Dispatch<React.SetStateAction<boolean>>;
307
+ showUpdateToast: boolean;
308
+ setShowUpdateToast: React.Dispatch<React.SetStateAction<boolean>>;
304
309
  showConsoleLevels: {
305
310
  info: boolean;
306
311
  warn: boolean;