react-native-inapp-inspector 2.0.0 → 2.0.2
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 +10 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/reports/problems/problems-report.html +659 -0
- package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +33 -24
- package/dist/commonjs/components/ConsoleLogCard.js +5 -5
- package/dist/commonjs/components/EndOfListFooter.js +1 -1
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +19 -71
- package/dist/commonjs/components/Inspector/BundleTab.js +670 -188
- package/dist/commonjs/components/Inspector/ConsoleTab.js +109 -98
- package/dist/commonjs/components/Inspector/CrashTab.js +2 -1
- package/dist/commonjs/components/Inspector/InspectorHeader.js +102 -19
- package/dist/commonjs/components/Inspector/MainScreen.js +151 -17
- package/dist/commonjs/components/Inspector/NetworkTab.js +104 -20
- package/dist/commonjs/components/Inspector/SettingsPanel.js +1111 -1385
- package/dist/commonjs/components/Inspector/TabBar.js +3 -4
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.js +212 -0
- package/dist/commonjs/components/JsonViewer.js +9 -4
- package/dist/commonjs/components/LogCard.js +31 -1
- package/dist/commonjs/components/LogSyntaxHighlighter.d.ts +16 -0
- package/dist/commonjs/components/LogSyntaxHighlighter.js +130 -0
- package/dist/commonjs/components/NetworkIcons.d.ts +2 -0
- package/dist/commonjs/components/NetworkIcons.js +10 -1
- package/dist/commonjs/components/Slider.d.ts +13 -0
- package/dist/commonjs/components/Slider.js +261 -0
- 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/crashHandler.js +1 -1
- package/dist/commonjs/helpers/index.d.ts +2 -0
- package/dist/commonjs/helpers/index.js +16 -0
- package/dist/commonjs/helpers/searchQueryParser.d.ts +6 -0
- package/dist/commonjs/helpers/searchQueryParser.js +236 -0
- package/dist/commonjs/helpers/settingsStore.js +13 -13
- package/dist/commonjs/helpers/telemetry.d.ts +99 -0
- package/dist/commonjs/helpers/telemetry.js +398 -0
- package/dist/commonjs/index.d.ts +2 -0
- package/dist/commonjs/index.js +30 -21
- package/dist/commonjs/native/NativeInspector.d.ts +5 -0
- package/dist/commonjs/native/NativeInspector.js +3 -2
- package/dist/commonjs/styles/index.js +35 -35
- package/dist/esm/components/ConsoleLogCard.js +5 -5
- package/dist/esm/components/EndOfListFooter.js +2 -2
- package/dist/esm/components/Inspector/AnalyticsTab.js +21 -73
- package/dist/esm/components/Inspector/BundleTab.js +670 -188
- package/dist/esm/components/Inspector/ConsoleTab.js +110 -99
- package/dist/esm/components/Inspector/CrashTab.js +2 -1
- package/dist/esm/components/Inspector/InspectorHeader.js +103 -20
- package/dist/esm/components/Inspector/MainScreen.js +119 -18
- package/dist/esm/components/Inspector/NetworkTab.js +105 -21
- package/dist/esm/components/Inspector/SettingsPanel.js +1114 -1388
- package/dist/esm/components/Inspector/TabBar.js +4 -5
- package/dist/esm/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/esm/components/Inspector/TelemetryConsentModal.js +175 -0
- package/dist/esm/components/JsonViewer.js +9 -4
- package/dist/esm/components/LogCard.js +32 -2
- package/dist/esm/components/LogSyntaxHighlighter.d.ts +16 -0
- package/dist/esm/components/LogSyntaxHighlighter.js +123 -0
- package/dist/esm/components/NetworkIcons.d.ts +2 -0
- package/dist/esm/components/NetworkIcons.js +7 -0
- package/dist/esm/components/Slider.d.ts +13 -0
- package/dist/esm/components/Slider.js +222 -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/crashHandler.js +1 -1
- package/dist/esm/helpers/index.d.ts +2 -0
- package/dist/esm/helpers/index.js +2 -0
- package/dist/esm/helpers/searchQueryParser.d.ts +6 -0
- package/dist/esm/helpers/searchQueryParser.js +233 -0
- package/dist/esm/helpers/settingsStore.js +13 -13
- package/dist/esm/helpers/telemetry.d.ts +99 -0
- package/dist/esm/helpers/telemetry.js +380 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +20 -21
- package/dist/esm/native/NativeInspector.d.ts +5 -0
- package/dist/esm/native/NativeInspector.js +3 -2
- package/dist/esm/styles/index.js +35 -35
- package/ios/{NetworkInspectorModule.m → NetworkInspectorModule.mm} +193 -97
- package/package.json +2 -2
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// ─── Google Analytics 4 (GA4) Measurement Protocol Telemetry ───────────────
|
|
2
|
+
//
|
|
3
|
+
// Comprehensive, anonymous usage telemetry for react-native-inapp-inspector.
|
|
4
|
+
//
|
|
5
|
+
// - NEVER collects user PII, auth tokens, device names, or network payload bodies.
|
|
6
|
+
// - Zero main-thread blocking; 100% fail-safe fire-and-forget.
|
|
7
|
+
// - Full environment diagnostics (Hermes, New Arch, RN version, screen size, UI mode).
|
|
8
|
+
// - Tracks developer interactions: tab switches, page views, search, exports, retries.
|
|
9
|
+
// - Supports opt-out via `telemetry={false}` or `DO_NOT_TRACK=1`.
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
import { Platform, Dimensions, Appearance } from 'react-native';
|
|
12
|
+
import { LIB_VERSION } from '../constants';
|
|
13
|
+
import { getNativeStorageItem, setNativeStorageItem, isNativeModuleAvailable, getNativeDeviceMetrics, } from '../native/NativeInspector';
|
|
14
|
+
// ─── GA4 Measurement Protocol Configuration ──────────────────────────────────
|
|
15
|
+
// Automatically replaced at build-time from .env by scripts/inject-telemetry.js
|
|
16
|
+
export const GA4_MEASUREMENT_ID = 'G-3QGMQVZX5V';
|
|
17
|
+
export const GA4_API_SECRET = 'C46RQZ3PTfmHDnLnvU3KIg';
|
|
18
|
+
const GA4_ENDPOINT = 'https://www.google-analytics.com/mp/collect';
|
|
19
|
+
const CLIENT_ID_KEY = 'telemetry_client_id';
|
|
20
|
+
// Stable session ID created once per JavaScript runtime instance
|
|
21
|
+
const CURRENT_SESSION_ID = String(Math.floor(Date.now() / 1000));
|
|
22
|
+
let hasPingedSession = false;
|
|
23
|
+
let cachedClientId = null;
|
|
24
|
+
let lastModalOpenTimestamp = 0;
|
|
25
|
+
let cachedAppDiagnostics = null;
|
|
26
|
+
/**
|
|
27
|
+
* Generates an anonymous, pseudorandom UUIDv4-like string for client grouping.
|
|
28
|
+
* Contains zero hardware or personal identifiers.
|
|
29
|
+
*/
|
|
30
|
+
function generateAnonymousClientId() {
|
|
31
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
32
|
+
const r = (Math.random() * 16) | 0;
|
|
33
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
34
|
+
return v.toString(16);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves or generates the anonymous client identifier.
|
|
39
|
+
*/
|
|
40
|
+
async function getOrCreateClientId() {
|
|
41
|
+
if (cachedClientId)
|
|
42
|
+
return cachedClientId;
|
|
43
|
+
try {
|
|
44
|
+
const stored = await getNativeStorageItem(CLIENT_ID_KEY);
|
|
45
|
+
if (stored && typeof stored === 'string' && stored.length > 0) {
|
|
46
|
+
cachedClientId = stored;
|
|
47
|
+
return stored;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Fallback to memory
|
|
52
|
+
}
|
|
53
|
+
const newId = generateAnonymousClientId();
|
|
54
|
+
cachedClientId = newId;
|
|
55
|
+
try {
|
|
56
|
+
await setNativeStorageItem(CLIENT_ID_KEY, newId);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Silently ignore storage errors
|
|
60
|
+
}
|
|
61
|
+
return newId;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Asynchronously loads host application and device metadata (strictly non-PII/technical).
|
|
65
|
+
*/
|
|
66
|
+
export async function loadAppDiagnosticsAsync() {
|
|
67
|
+
if (cachedAppDiagnostics)
|
|
68
|
+
return cachedAppDiagnostics;
|
|
69
|
+
try {
|
|
70
|
+
const metrics = await getNativeDeviceMetrics();
|
|
71
|
+
cachedAppDiagnostics = {
|
|
72
|
+
app_name: metrics?.appName ||
|
|
73
|
+
Platform.constants?.appName ||
|
|
74
|
+
'unknown',
|
|
75
|
+
app_version: metrics?.appVersion ||
|
|
76
|
+
Platform.constants?.appVersion ||
|
|
77
|
+
'unknown',
|
|
78
|
+
app_build: metrics?.appBuild || 'unknown',
|
|
79
|
+
app_bundle_id: metrics?.appBundleId || metrics?.appPackageName || 'unknown',
|
|
80
|
+
device_brand: metrics?.deviceBrand ||
|
|
81
|
+
Platform.constants?.Brand ||
|
|
82
|
+
Platform.constants?.systemName ||
|
|
83
|
+
'unknown',
|
|
84
|
+
device_model: metrics?.deviceModel ||
|
|
85
|
+
Platform.constants?.Model ||
|
|
86
|
+
Platform.constants?.interfaceIdiom ||
|
|
87
|
+
'unknown',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
cachedAppDiagnostics = {
|
|
92
|
+
app_name: Platform.constants?.appName || 'unknown',
|
|
93
|
+
app_version: Platform.constants?.appVersion || 'unknown',
|
|
94
|
+
app_build: 'unknown',
|
|
95
|
+
app_bundle_id: 'unknown',
|
|
96
|
+
device_brand: Platform.constants?.Brand || 'unknown',
|
|
97
|
+
device_model: Platform.constants?.Model || 'unknown',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return cachedAppDiagnostics;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extracts React Native framework version string (e.g. "0.81.4").
|
|
104
|
+
*/
|
|
105
|
+
function getReactNativeVersion() {
|
|
106
|
+
try {
|
|
107
|
+
const constants = Platform.constants;
|
|
108
|
+
if (constants && constants.reactNativeVersion) {
|
|
109
|
+
const { major, minor, patch, prerelease } = constants.reactNativeVersion;
|
|
110
|
+
return `${major}.${minor}.${patch}${prerelease ? `-${prerelease}` : ''}`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// Fallback
|
|
115
|
+
}
|
|
116
|
+
return 'unknown';
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Collects complete anonymous device, host app & runtime environment diagnostics.
|
|
120
|
+
*/
|
|
121
|
+
function getEnvironmentDiagnostics(extraParams = {}) {
|
|
122
|
+
const isHermes = Boolean(global.HermesInternal);
|
|
123
|
+
const isNewArch = Boolean(global._RN_FABRIC_ENABLED || global.__turboModuleProxy);
|
|
124
|
+
const isNativeLinked = isNativeModuleAvailable();
|
|
125
|
+
const rnVersion = getReactNativeVersion();
|
|
126
|
+
const isExpo = Boolean(global?.expo?.modules?.ExponentConstants ||
|
|
127
|
+
global?.__expo ||
|
|
128
|
+
(typeof process !== 'undefined' &&
|
|
129
|
+
process?.env?.EXPO_PUBLIC_PROJECT_ROOT));
|
|
130
|
+
let screenResolution = 'unknown';
|
|
131
|
+
let fontScale = 1;
|
|
132
|
+
try {
|
|
133
|
+
const { width, height, scale, fontScale: fs } = Dimensions.get('window');
|
|
134
|
+
screenResolution = `${Math.round(width)}x${Math.round(height)}@${scale}x`;
|
|
135
|
+
fontScale = fs || 1;
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Ignore dimension errors
|
|
139
|
+
}
|
|
140
|
+
let colorScheme = 'unknown';
|
|
141
|
+
try {
|
|
142
|
+
colorScheme = Appearance.getColorScheme() || 'unspecified';
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Ignore appearance errors
|
|
146
|
+
}
|
|
147
|
+
const appMeta = cachedAppDiagnostics || {
|
|
148
|
+
app_name: Platform.constants?.appName || 'unknown',
|
|
149
|
+
app_version: Platform.constants?.appVersion || 'unknown',
|
|
150
|
+
app_build: 'unknown',
|
|
151
|
+
app_bundle_id: 'unknown',
|
|
152
|
+
device_brand: Platform.constants?.Brand ||
|
|
153
|
+
Platform.constants?.systemName ||
|
|
154
|
+
'unknown',
|
|
155
|
+
device_model: Platform.constants?.Model ||
|
|
156
|
+
Platform.constants?.interfaceIdiom ||
|
|
157
|
+
'unknown',
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
session_id: CURRENT_SESSION_ID,
|
|
161
|
+
engagement_time_msec: 100,
|
|
162
|
+
lib_version: LIB_VERSION,
|
|
163
|
+
platform: Platform.OS,
|
|
164
|
+
os_version: String(Platform.Version),
|
|
165
|
+
rn_version: rnVersion,
|
|
166
|
+
is_hermes: isHermes,
|
|
167
|
+
is_new_arch: isNewArch,
|
|
168
|
+
is_native_linked: isNativeLinked,
|
|
169
|
+
is_expo: isExpo,
|
|
170
|
+
is_dev: Boolean(typeof __DEV__ !== 'undefined' && __DEV__),
|
|
171
|
+
screen_resolution: screenResolution,
|
|
172
|
+
font_scale: fontScale,
|
|
173
|
+
color_scheme: colorScheme,
|
|
174
|
+
...appMeta,
|
|
175
|
+
...extraParams,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const CONSENT_STORAGE_KEY = 'telemetry_consent_status';
|
|
179
|
+
let cachedConsentStatus = null;
|
|
180
|
+
/**
|
|
181
|
+
* Returns the developer's telemetry consent status.
|
|
182
|
+
*/
|
|
183
|
+
export async function getTelemetryConsentStatus() {
|
|
184
|
+
if (cachedConsentStatus)
|
|
185
|
+
return cachedConsentStatus;
|
|
186
|
+
try {
|
|
187
|
+
const stored = await getNativeStorageItem(CONSENT_STORAGE_KEY);
|
|
188
|
+
if (stored === 'granted' || stored === 'declined') {
|
|
189
|
+
cachedConsentStatus = stored;
|
|
190
|
+
return stored;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// Fallback
|
|
195
|
+
}
|
|
196
|
+
return 'undetermined';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Saves the developer's telemetry consent choice.
|
|
200
|
+
*/
|
|
201
|
+
export async function setTelemetryConsent(granted) {
|
|
202
|
+
const status = granted ? 'granted' : 'declined';
|
|
203
|
+
cachedConsentStatus = status;
|
|
204
|
+
try {
|
|
205
|
+
await setNativeStorageItem(CONSENT_STORAGE_KEY, status);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
// Ignore storage errors
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Checks if the user or environment has opted out of telemetry.
|
|
213
|
+
*/
|
|
214
|
+
export function isTelemetryOptedOut(explicitSetting) {
|
|
215
|
+
if (explicitSetting === false)
|
|
216
|
+
return true;
|
|
217
|
+
if (cachedConsentStatus === 'declined')
|
|
218
|
+
return true;
|
|
219
|
+
try {
|
|
220
|
+
if (typeof process !== 'undefined' &&
|
|
221
|
+
process?.env &&
|
|
222
|
+
(process.env.DO_NOT_TRACK === '1' || process.env.DISABLE_TELEMETRY === '1')) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// Ignore environments where process is undefined or restricted
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Track an anonymous event via GA4 Measurement Protocol.
|
|
233
|
+
*/
|
|
234
|
+
export async function trackTelemetryEvent(eventName, params = {}, options) {
|
|
235
|
+
if (isTelemetryOptedOut(options?.telemetry))
|
|
236
|
+
return;
|
|
237
|
+
// Don't send if credentials haven't been configured yet
|
|
238
|
+
if (!GA4_MEASUREMENT_ID ||
|
|
239
|
+
GA4_MEASUREMENT_ID === 'G-3QGMQVZX5V' ||
|
|
240
|
+
!GA4_API_SECRET ||
|
|
241
|
+
GA4_API_SECRET === 'C46RQZ3PTfmHDnLnvU3KIg') {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const clientId = await getOrCreateClientId();
|
|
246
|
+
await loadAppDiagnosticsAsync();
|
|
247
|
+
const eventParams = getEnvironmentDiagnostics(params);
|
|
248
|
+
const payload = {
|
|
249
|
+
client_id: clientId,
|
|
250
|
+
events: [
|
|
251
|
+
{
|
|
252
|
+
name: eventName,
|
|
253
|
+
params: eventParams,
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
const url = `${GA4_ENDPOINT}?measurement_id=${encodeURIComponent(GA4_MEASUREMENT_ID)}&api_secret=${encodeURIComponent(GA4_API_SECRET)}`;
|
|
258
|
+
fetch(url, {
|
|
259
|
+
method: 'POST',
|
|
260
|
+
headers: {
|
|
261
|
+
'Content-Type': 'application/json',
|
|
262
|
+
},
|
|
263
|
+
body: JSON.stringify(payload),
|
|
264
|
+
}).catch(() => {
|
|
265
|
+
// If offline on initial cold start, allow a single delayed retry
|
|
266
|
+
if (eventName === 'inspector_session_init') {
|
|
267
|
+
hasPingedSession = false;
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
sendSessionTelemetryPing(options);
|
|
270
|
+
}, 8000);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// Fail silently
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* 1. Session initialization heartbeat ping.
|
|
280
|
+
*/
|
|
281
|
+
export async function sendSessionTelemetryPing(options) {
|
|
282
|
+
if (hasPingedSession && !options?.force)
|
|
283
|
+
return;
|
|
284
|
+
if (isTelemetryOptedOut(options?.telemetry))
|
|
285
|
+
return;
|
|
286
|
+
hasPingedSession = true;
|
|
287
|
+
await trackTelemetryEvent('inspector_session_init', {
|
|
288
|
+
environment: options?.environment || 'unknown',
|
|
289
|
+
has_navigation: Boolean(options?.hasNavigation),
|
|
290
|
+
has_app_icon: Boolean(options?.hasAppIcon),
|
|
291
|
+
}, options);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 2. Track when the inspector modal is opened.
|
|
295
|
+
*/
|
|
296
|
+
export function trackInspectorOpen(options) {
|
|
297
|
+
lastModalOpenTimestamp = Date.now();
|
|
298
|
+
trackTelemetryEvent('inspector_open', {
|
|
299
|
+
open_source: options?.openSource || 'fab',
|
|
300
|
+
active_tab: options?.activeTab || 'apis',
|
|
301
|
+
}, options);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* 3. Track when the inspector modal is closed.
|
|
305
|
+
*/
|
|
306
|
+
export function trackInspectorClose(options) {
|
|
307
|
+
const durationSec = lastModalOpenTimestamp > 0
|
|
308
|
+
? Math.round((Date.now() - lastModalOpenTimestamp) / 1000)
|
|
309
|
+
: 0;
|
|
310
|
+
trackTelemetryEvent('inspector_close', {
|
|
311
|
+
open_duration_seconds: durationSec,
|
|
312
|
+
}, options);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 4. Track tab / page view navigation inside the inspector.
|
|
316
|
+
*/
|
|
317
|
+
export function trackTabSwitch(tabName, options) {
|
|
318
|
+
trackTelemetryEvent('page_view', {
|
|
319
|
+
page_title: `Tab: ${tabName}`,
|
|
320
|
+
page_location: `inapp-inspector://tab/${tabName}`,
|
|
321
|
+
tab_name: tabName,
|
|
322
|
+
from_tab: options?.fromTab || 'unknown',
|
|
323
|
+
}, options);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 5. Track network API interaction (inspect details, copy cURL, retry).
|
|
327
|
+
*/
|
|
328
|
+
export function trackNetworkInteraction(action, options) {
|
|
329
|
+
trackTelemetryEvent('network_interaction', {
|
|
330
|
+
action_type: action,
|
|
331
|
+
http_method: options?.method || 'GET',
|
|
332
|
+
status_code: options?.statusCode || 0,
|
|
333
|
+
duration_ms: options?.durationMs || 0,
|
|
334
|
+
}, options);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* 6. Track Redux / State management interaction.
|
|
338
|
+
*/
|
|
339
|
+
export function trackReduxInteraction(action, options) {
|
|
340
|
+
trackTelemetryEvent('redux_interaction', {
|
|
341
|
+
action_type: action,
|
|
342
|
+
reducer_name: options?.reducerName || 'root',
|
|
343
|
+
}, options);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* 7. Track Crash & Exception interaction.
|
|
347
|
+
*/
|
|
348
|
+
export function trackCrashInteraction(action, options) {
|
|
349
|
+
trackTelemetryEvent('crash_interaction', {
|
|
350
|
+
action_type: action,
|
|
351
|
+
crash_type: options?.crashType || 'js_exception',
|
|
352
|
+
}, options);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* 8. Track Performance monitoring tab interaction.
|
|
356
|
+
*/
|
|
357
|
+
export function trackPerformanceInteraction(subTab, options) {
|
|
358
|
+
trackTelemetryEvent('performance_interaction', {
|
|
359
|
+
sub_tab: subTab,
|
|
360
|
+
}, options);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 9. Track search queries and filter applications.
|
|
364
|
+
*/
|
|
365
|
+
export function trackSearchOrFilter(target, actionType, options) {
|
|
366
|
+
trackTelemetryEvent('search_and_filter', {
|
|
367
|
+
target_tab: target,
|
|
368
|
+
action_type: actionType,
|
|
369
|
+
filter_value: options?.filterValue || 'all',
|
|
370
|
+
}, options);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* 10. Track when logs / reports are exported or shared.
|
|
374
|
+
*/
|
|
375
|
+
export function trackLogExport(exportType, options) {
|
|
376
|
+
trackTelemetryEvent('log_export', {
|
|
377
|
+
export_type: exportType,
|
|
378
|
+
item_count: options?.count || 1,
|
|
379
|
+
}, options);
|
|
380
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import ErrorBoundary from './components/ErrorBoundary';
|
|
|
8
8
|
import MainScreen from './components/Inspector/MainScreen';
|
|
9
9
|
import { InspectorContext, animateNextLayout, } from './components/Inspector/InspectorContext';
|
|
10
10
|
// Helpers
|
|
11
|
-
import { formatDisplayUrl, getNavigationInfo, deduplicateLogs, getDomainColor, getEventCategory, } from './helpers';
|
|
11
|
+
import { formatDisplayUrl, getNavigationInfo, deduplicateLogs, getDomainColor, getEventCategory, matchNetworkLogQuery, sendSessionTelemetryPing, trackInspectorOpen, } from './helpers';
|
|
12
12
|
// #5 — settings persistence
|
|
13
13
|
import { loadSettings, saveSettings, setCustomStorage, clearPersistedSettings, calculateRamBasedLimits, } from './helpers/settingsStore';
|
|
14
14
|
import { getNativeSystemMetrics, pushNativeLogRecord, fetchNativeCachedPage, } from './native/NativeInspector';
|
|
@@ -99,7 +99,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
99
99
|
// ─── Crash state ───────────────────────────────────────────────────────────
|
|
100
100
|
const [crashRecords, setCrashRecords] = useState(() => getCrashRecords());
|
|
101
101
|
const [selectedCrash, setSelectedCrash] = useState(null);
|
|
102
|
-
const [maxCrashLogs, setMaxCrashLogs] = useState(
|
|
102
|
+
const [maxCrashLogs, setMaxCrashLogs] = useState(50);
|
|
103
103
|
useEffect(() => {
|
|
104
104
|
setMaxCrashLogsLimit(maxCrashLogs);
|
|
105
105
|
}, [maxCrashLogs]);
|
|
@@ -131,7 +131,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
131
131
|
setLastReadCrashesCount(crashRecords.length);
|
|
132
132
|
}
|
|
133
133
|
}, [activeTab, crashRecords.length]);
|
|
134
|
-
const [maxConsoleLogs, setMaxConsoleLogs] = useState(
|
|
134
|
+
const [maxConsoleLogs, setMaxConsoleLogs] = useState(100);
|
|
135
135
|
const [showConsoleLevels, setShowConsoleLevels] = useState({
|
|
136
136
|
info: true,
|
|
137
137
|
warn: false,
|
|
@@ -176,7 +176,7 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
176
176
|
crash: false,
|
|
177
177
|
});
|
|
178
178
|
const [maxNetworkLogs, setMaxNetworkLogs] = useState(100);
|
|
179
|
-
const [maxAnalyticsEventsLimit, setMaxAnalyticsEventsLimit] = useState(
|
|
179
|
+
const [maxAnalyticsEventsLimit, setMaxAnalyticsEventsLimit] = useState(75);
|
|
180
180
|
const [isAutoRamLimitEnabled, setIsAutoRamLimitEnabled] = useState(true);
|
|
181
181
|
const [deviceFreeRamMb, setDeviceFreeRamMb] = useState(1800);
|
|
182
182
|
const [reduxAutoRefresh, setReduxAutoRefreshState] = useState(true);
|
|
@@ -699,6 +699,14 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
699
699
|
}, [unreadPulseAnim]);
|
|
700
700
|
const isNativeModule = useMemo(() => isNativeModuleAvailable(), []);
|
|
701
701
|
const useNativeFab = (Platform.OS === 'ios' || Platform.OS === 'android') && isNativeModule;
|
|
702
|
+
// Send anonymous initialization heartbeat to GA4 Measurement Protocol
|
|
703
|
+
useEffect(() => {
|
|
704
|
+
sendSessionTelemetryPing({
|
|
705
|
+
environment,
|
|
706
|
+
hasNavigation: Boolean(navigationRef),
|
|
707
|
+
hasAppIcon: Boolean(appIcon),
|
|
708
|
+
});
|
|
709
|
+
}, [environment, navigationRef, appIcon]);
|
|
702
710
|
// 100% Native Main-Thread Floating Button Lifecycle
|
|
703
711
|
useEffect(() => {
|
|
704
712
|
if (!useNativeFab || !isEnabled || !enabled) {
|
|
@@ -753,6 +761,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
753
761
|
? defaultTab
|
|
754
762
|
: 'apis';
|
|
755
763
|
setActiveTab(target);
|
|
764
|
+
// Track inspector opened event in GA4
|
|
765
|
+
trackInspectorOpen({ activeTab: target });
|
|
756
766
|
// Instant synchronization of data collected while modal was closed
|
|
757
767
|
if (latestNetworkLogsRef.current.length > 0) {
|
|
758
768
|
const deduped = deduplicateLogs(latestNetworkLogsRef.current);
|
|
@@ -1006,23 +1016,10 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
1006
1016
|
if (!matchedMethod)
|
|
1007
1017
|
return false;
|
|
1008
1018
|
}
|
|
1009
|
-
//
|
|
1019
|
+
// Advanced Search Query Engine Check (Supports method:POST, is:error, slow:>1s, status:200, headers, body, etc.)
|
|
1010
1020
|
if (search && search.trim().length > 0) {
|
|
1011
|
-
const queryTokens = search.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
1012
1021
|
const routePath = logRouteMapRef.current.get(log.id)?.path || '';
|
|
1013
|
-
const
|
|
1014
|
-
const resStr = typeof log.response === 'string' ? log.response : JSON.stringify(log.response || '');
|
|
1015
|
-
const searchTarget = [
|
|
1016
|
-
log.method || '',
|
|
1017
|
-
log.url || '',
|
|
1018
|
-
String(log.status ?? ''),
|
|
1019
|
-
routePath,
|
|
1020
|
-
reqStr,
|
|
1021
|
-
resStr,
|
|
1022
|
-
JSON.stringify(log.requestHeaders || ''),
|
|
1023
|
-
JSON.stringify(log.responseHeaders || ''),
|
|
1024
|
-
].join(' ').toLowerCase();
|
|
1025
|
-
const isMatch = queryTokens.every(token => searchTarget.includes(token));
|
|
1022
|
+
const isMatch = matchNetworkLogQuery(log, search, routePath);
|
|
1026
1023
|
if (!isMatch)
|
|
1027
1024
|
return false;
|
|
1028
1025
|
}
|
|
@@ -1326,8 +1323,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
1326
1323
|
else if (analyticsFilters.sortBy === 'count_desc') {
|
|
1327
1324
|
result = [...result].sort((a, b) => (b.count || 1) - (a.count || 1));
|
|
1328
1325
|
}
|
|
1329
|
-
return result;
|
|
1330
|
-
}, [analyticsEvents, analyticsSearch, analyticsFilters]);
|
|
1326
|
+
return result.slice(0, maxAnalyticsEventsLimit);
|
|
1327
|
+
}, [analyticsEvents, analyticsSearch, analyticsFilters, maxAnalyticsEventsLimit]);
|
|
1331
1328
|
const filteredConsoleLogs = useMemo(() => {
|
|
1332
1329
|
let result = visibleConsoleLogs;
|
|
1333
1330
|
// Filters check
|
|
@@ -1752,4 +1749,6 @@ export { getEventCategory, registerGAPlugin, } from './helpers/gaAnalyticsRegist
|
|
|
1752
1749
|
export { usePerformanceTracker, useComponentProfiler, useNavigationProfiler, trackComponentRender, trackNavigationTransition, trackHeavyTask, measureAsync, getHermesMemoryStats, registerComponentProfile, subscribeRenderProfiles, getRenderProfiles, logPerformanceEvent, clearPerformanceEvents, subscribePerformanceEvents, getPerformanceEvents, getInitialRenderProfiles, getInitialPerformanceEvents, generateFixSnippet, } from './customHooks/performanceTracker';
|
|
1753
1750
|
export { InspectLog, InspectTrackTime, InspectCatch, } from './decorators';
|
|
1754
1751
|
export { getNativeDeviceMetrics, enableNativeCrashProtection, subscribeNativeCrashes, showNativeFloatingButton, hideNativeFloatingButton, setNativeFloatingButtonBadge, subscribeNativeFloatingButtonPress, subscribeNativeDeviceShake, startNativeFpsMonitoring, stopNativeFpsMonitoring, getNativeFpsMetrics, getNativeStorageItem, setNativeStorageItem, isNativeModuleAvailable, } from './native/NativeInspector';
|
|
1752
|
+
export { sendSessionTelemetryPing, trackTelemetryEvent, trackInspectorOpen, trackTabSwitch, trackLogExport, GA4_MEASUREMENT_ID, GA4_API_SECRET, } from './helpers';
|
|
1753
|
+
export { BrandSquareIcon, BrandCircleIcon, } from './components/NetworkIcons';
|
|
1755
1754
|
export { ActiveTab, Method, StatusFilter, SortOrder, LocalFilter, ModalAnimationType, SettingsPage, SettingsSubTab, LogFilter, ConsoleLogType, AnalyticsEventSource, GAEventCategory, StackFrameType, DiffResultType, BundleSubTab, PerformanceSubTab, CrashType, CrashExportFormat, CrashDetailSubTab, CrashFilterType, BreadcrumbType, } from './types';
|
|
@@ -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';
|
|
@@ -5,8 +5,9 @@ const NativeModule = NativeNetworkInspector || NativeModules.NetworkInspectorMod
|
|
|
5
5
|
export const isNativeModuleAvailable = () => {
|
|
6
6
|
return !!NativeModule;
|
|
7
7
|
};
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const eventTarget = NativeModules.NetworkInspectorModule || NativeNetworkInspector;
|
|
9
|
+
const nativeEmitter = eventTarget
|
|
10
|
+
? new NativeEventEmitter(eventTarget)
|
|
10
11
|
: null;
|
|
11
12
|
/**
|
|
12
13
|
* Retrieves low-level native hardware and system metrics (RAM, Heap, Disk, Battery, CPU).
|