react-native-inapp-inspector 2.0.1 → 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 +23 -0
- package/dist/commonjs/components/Inspector/MainScreen.js +4 -0
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.js +212 -0
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/helpers/index.d.ts +1 -0
- package/dist/commonjs/helpers/index.js +1 -0
- 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 +23 -1
- package/dist/commonjs/native/NativeInspector.d.ts +5 -0
- package/dist/commonjs/native/NativeInspector.js +3 -2
- package/dist/esm/components/Inspector/MainScreen.js +4 -0
- package/dist/esm/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/esm/components/Inspector/TelemetryConsentModal.js +175 -0
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +1 -0
- 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 +13 -1
- package/dist/esm/native/NativeInspector.d.ts +5 -0
- package/dist/esm/native/NativeInspector.js +3 -2
- package/ios/{NetworkInspectorModule.m → NetworkInspectorModule.mm} +175 -119
- package/package.json +2 -2
|
@@ -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-3QGMQVZX5V';
|
|
35
|
+
exports.GA4_API_SECRET = 'C46RQZ3PTfmHDnLnvU3KIg';
|
|
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-3QGMQVZX5V' ||
|
|
258
|
+
!exports.GA4_API_SECRET ||
|
|
259
|
+
exports.GA4_API_SECRET === 'C46RQZ3PTfmHDnLnvU3KIg') {
|
|
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
|
+
}
|
package/dist/commonjs/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/commonjs/index.js
CHANGED
|
@@ -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.
|
|
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");
|
|
@@ -739,6 +740,14 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
739
740
|
}, [unreadPulseAnim]);
|
|
740
741
|
const isNativeModule = (0, react_1.useMemo)(() => (0, NativeInspector_2.isNativeModuleAvailable)(), []);
|
|
741
742
|
const useNativeFab = (react_native_1.Platform.OS === 'ios' || react_native_1.Platform.OS === 'android') && isNativeModule;
|
|
743
|
+
// Send anonymous initialization heartbeat to GA4 Measurement Protocol
|
|
744
|
+
(0, react_1.useEffect)(() => {
|
|
745
|
+
(0, helpers_1.sendSessionTelemetryPing)({
|
|
746
|
+
environment,
|
|
747
|
+
hasNavigation: Boolean(navigationRef),
|
|
748
|
+
hasAppIcon: Boolean(appIcon),
|
|
749
|
+
});
|
|
750
|
+
}, [environment, navigationRef, appIcon]);
|
|
742
751
|
// 100% Native Main-Thread Floating Button Lifecycle
|
|
743
752
|
(0, react_1.useEffect)(() => {
|
|
744
753
|
if (!useNativeFab || !isEnabled || !enabled) {
|
|
@@ -793,6 +802,8 @@ const NetworkInspector = ({ enabled = true, isEnabled = true, storage, navigatio
|
|
|
793
802
|
? defaultTab
|
|
794
803
|
: 'apis';
|
|
795
804
|
setActiveTab(target);
|
|
805
|
+
// Track inspector opened event in GA4
|
|
806
|
+
(0, helpers_1.trackInspectorOpen)({ activeTab: target });
|
|
796
807
|
// Instant synchronization of data collected while modal was closed
|
|
797
808
|
if (latestNetworkLogsRef.current.length > 0) {
|
|
798
809
|
const deduped = (0, helpers_1.deduplicateLogs)(latestNetworkLogsRef.current);
|
|
@@ -1855,6 +1866,17 @@ Object.defineProperty(exports, "getNativeFpsMetrics", { enumerable: true, get: f
|
|
|
1855
1866
|
Object.defineProperty(exports, "getNativeStorageItem", { enumerable: true, get: function () { return NativeInspector_3.getNativeStorageItem; } });
|
|
1856
1867
|
Object.defineProperty(exports, "setNativeStorageItem", { enumerable: true, get: function () { return NativeInspector_3.setNativeStorageItem; } });
|
|
1857
1868
|
Object.defineProperty(exports, "isNativeModuleAvailable", { enumerable: true, get: function () { return NativeInspector_3.isNativeModuleAvailable; } });
|
|
1869
|
+
var helpers_2 = require("./helpers");
|
|
1870
|
+
Object.defineProperty(exports, "sendSessionTelemetryPing", { enumerable: true, get: function () { return helpers_2.sendSessionTelemetryPing; } });
|
|
1871
|
+
Object.defineProperty(exports, "trackTelemetryEvent", { enumerable: true, get: function () { return helpers_2.trackTelemetryEvent; } });
|
|
1872
|
+
Object.defineProperty(exports, "trackInspectorOpen", { enumerable: true, get: function () { return helpers_2.trackInspectorOpen; } });
|
|
1873
|
+
Object.defineProperty(exports, "trackTabSwitch", { enumerable: true, get: function () { return helpers_2.trackTabSwitch; } });
|
|
1874
|
+
Object.defineProperty(exports, "trackLogExport", { enumerable: true, get: function () { return helpers_2.trackLogExport; } });
|
|
1875
|
+
Object.defineProperty(exports, "GA4_MEASUREMENT_ID", { enumerable: true, get: function () { return helpers_2.GA4_MEASUREMENT_ID; } });
|
|
1876
|
+
Object.defineProperty(exports, "GA4_API_SECRET", { enumerable: true, get: function () { return helpers_2.GA4_API_SECRET; } });
|
|
1877
|
+
var NetworkIcons_1 = require("./components/NetworkIcons");
|
|
1878
|
+
Object.defineProperty(exports, "BrandSquareIcon", { enumerable: true, get: function () { return NetworkIcons_1.BrandSquareIcon; } });
|
|
1879
|
+
Object.defineProperty(exports, "BrandCircleIcon", { enumerable: true, get: function () { return NetworkIcons_1.BrandCircleIcon; } });
|
|
1858
1880
|
var types_1 = require("./types");
|
|
1859
1881
|
Object.defineProperty(exports, "ActiveTab", { enumerable: true, get: function () { return types_1.ActiveTab; } });
|
|
1860
1882
|
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
|
|
16
|
-
|
|
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).
|
|
@@ -18,6 +18,7 @@ import PerformanceTab from './PerformanceTab';
|
|
|
18
18
|
import CrashTab from './CrashTab';
|
|
19
19
|
import CrashDetail from './CrashDetail';
|
|
20
20
|
import SettingsPanel from './SettingsPanel';
|
|
21
|
+
import TelemetryConsentModal from './TelemetryConsentModal';
|
|
21
22
|
import Toast from '../Toast';
|
|
22
23
|
import styles from '../../styles';
|
|
23
24
|
import { AppColors } from '../../styles/AppColors';
|
|
@@ -166,6 +167,9 @@ const MainScreen = () => {
|
|
|
166
167
|
|
|
167
168
|
{/* Bottom floating toast notification */}
|
|
168
169
|
<Toast />
|
|
170
|
+
|
|
171
|
+
{/* Anonymous Telemetry Consent Dialog */}
|
|
172
|
+
<TelemetryConsentModal />
|
|
169
173
|
</View>
|
|
170
174
|
</View>
|
|
171
175
|
</ErrorBoundary>)}
|