react-native-inapp-inspector 1.1.21 → 1.1.22
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/dist/commonjs/components/AnalyticsDetail.js +5 -3
- package/dist/commonjs/components/AnalyticsEventCard.d.ts +0 -1
- package/dist/commonjs/components/AnalyticsEventCard.js +85 -96
- package/dist/commonjs/components/Inspector/BundleTab.js +486 -651
- package/dist/commonjs/components/Inspector/PerformanceTab.js +185 -244
- package/dist/commonjs/components/Inspector/ReduxDetail.js +2 -2
- package/dist/commonjs/components/Inspector/ReduxTab.js +3 -3
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/bundleAnalyzer.d.ts +115 -0
- package/dist/commonjs/customHooks/bundleAnalyzer.js +561 -0
- package/dist/commonjs/customHooks/performanceTracker.d.ts +84 -0
- package/dist/commonjs/customHooks/performanceTracker.js +541 -0
- package/dist/commonjs/helpers/index.d.ts +15 -0
- package/dist/commonjs/helpers/index.js +112 -1
- package/dist/commonjs/i18n/locales/en.json +225 -2
- package/dist/commonjs/styles/AppColors.d.ts +110 -0
- package/dist/commonjs/styles/AppColors.js +114 -0
- package/dist/esm/components/AnalyticsDetail.js +5 -3
- package/dist/esm/components/AnalyticsEventCard.d.ts +0 -1
- package/dist/esm/components/AnalyticsEventCard.js +85 -95
- package/dist/esm/components/Inspector/BundleTab.js +489 -654
- package/dist/esm/components/Inspector/PerformanceTab.js +185 -244
- package/dist/esm/components/Inspector/ReduxDetail.js +2 -2
- package/dist/esm/components/Inspector/ReduxTab.js +3 -3
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/bundleAnalyzer.d.ts +115 -0
- package/dist/esm/customHooks/bundleAnalyzer.js +554 -0
- package/dist/esm/customHooks/performanceTracker.d.ts +84 -0
- package/dist/esm/customHooks/performanceTracker.js +537 -0
- package/dist/esm/helpers/index.d.ts +15 -0
- package/dist/esm/helpers/index.js +107 -0
- package/dist/esm/i18n/locales/en.json +225 -2
- package/dist/esm/styles/AppColors.d.ts +110 -0
- package/dist/esm/styles/AppColors.js +114 -0
- package/package.json +1 -1
|
@@ -2,88 +2,13 @@ import React, { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { Animated, StyleSheet, Text, View } from 'react-native';
|
|
3
3
|
import { AppColors } from '../styles/AppColors';
|
|
4
4
|
import { AppFonts } from '../styles/AppFonts';
|
|
5
|
-
import { formatGap, formatTime } from '../helpers';
|
|
5
|
+
import { formatGap, formatTime, getEventColor, getEventCategory, getCategoryColors, } from '../helpers';
|
|
6
|
+
import { useTranslation } from '../i18n';
|
|
6
7
|
import HighlightText from './HighlightText';
|
|
7
8
|
import TouchableScale from './TouchableScale';
|
|
8
|
-
// ─── Palette (Google Analytics colours) ───────────────────────────────────────
|
|
9
|
-
const EVENT_PALETTE = [
|
|
10
|
-
AppColors.googleBlue, // blue
|
|
11
|
-
AppColors.googleGreen, // green
|
|
12
|
-
AppColors.googlePurple, // purple
|
|
13
|
-
AppColors.googleTeal, // teal
|
|
14
|
-
AppColors.googleRed, // red
|
|
15
|
-
AppColors.googleOrange, // orange
|
|
16
|
-
AppColors.blue700, // dark blue
|
|
17
|
-
AppColors.materialGreen, // dark green
|
|
18
|
-
];
|
|
19
|
-
export function getEventColor(name) {
|
|
20
|
-
const safeName = typeof name === 'string' ? name : String(name || '');
|
|
21
|
-
let hash = 0;
|
|
22
|
-
for (let i = 0; i < safeName.length; i++) {
|
|
23
|
-
hash = (hash * 31 + safeName.charCodeAt(i)) | 0;
|
|
24
|
-
}
|
|
25
|
-
return EVENT_PALETTE[Math.abs(hash) % EVENT_PALETTE.length];
|
|
26
|
-
}
|
|
27
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
28
|
-
function getEventCategory(name) {
|
|
29
|
-
if (!name)
|
|
30
|
-
return 'Custom';
|
|
31
|
-
const lowercaseName = name.toLowerCase();
|
|
32
|
-
if (lowercaseName === 'screen_view' || lowercaseName === 'page_view') {
|
|
33
|
-
return 'Page View';
|
|
34
|
-
}
|
|
35
|
-
// Ecommerce events
|
|
36
|
-
const ecommerceEvents = [
|
|
37
|
-
'purchase', 'add_to_cart', 'begin_checkout', 'view_item',
|
|
38
|
-
'select_item', 'remove_from_cart', 'view_cart',
|
|
39
|
-
'add_shipping_info', 'add_payment_info', 'refund',
|
|
40
|
-
'view_item_list', 'select_promotion', 'view_promotion'
|
|
41
|
-
];
|
|
42
|
-
if (ecommerceEvents.includes(lowercaseName)) {
|
|
43
|
-
return 'Ecommerce';
|
|
44
|
-
}
|
|
45
|
-
// Firebase System Auto-events
|
|
46
|
-
const systemEvents = [
|
|
47
|
-
'first_open', 'session_start', 'user_engagement',
|
|
48
|
-
'app_clear_data', 'app_exception', 'app_update', 'os_update',
|
|
49
|
-
'notification_receive', 'notification_open', 'notification_dismiss',
|
|
50
|
-
'screen_active', 'screen_inactive'
|
|
51
|
-
];
|
|
52
|
-
if (systemEvents.includes(lowercaseName) || lowercaseName.startsWith('firebase_') || lowercaseName.startsWith('_')) {
|
|
53
|
-
return 'System';
|
|
54
|
-
}
|
|
55
|
-
return 'Custom';
|
|
56
|
-
}
|
|
57
|
-
function getCategoryColors(category) {
|
|
58
|
-
switch (category) {
|
|
59
|
-
case 'Page View':
|
|
60
|
-
return {
|
|
61
|
-
bg: AppColors.blueBg,
|
|
62
|
-
border: AppColors.blueBorder,
|
|
63
|
-
text: AppColors.blue800,
|
|
64
|
-
};
|
|
65
|
-
case 'Ecommerce':
|
|
66
|
-
return {
|
|
67
|
-
bg: AppColors.greenBg,
|
|
68
|
-
border: AppColors.greenBorder,
|
|
69
|
-
text: AppColors.materialGreen,
|
|
70
|
-
};
|
|
71
|
-
case 'System':
|
|
72
|
-
return {
|
|
73
|
-
bg: AppColors.greyBg,
|
|
74
|
-
border: AppColors.greyBorder,
|
|
75
|
-
text: AppColors.grey600,
|
|
76
|
-
};
|
|
77
|
-
default:
|
|
78
|
-
return {
|
|
79
|
-
bg: AppColors.purpleBg,
|
|
80
|
-
border: AppColors.purpleBorder,
|
|
81
|
-
text: AppColors.purpleText,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
9
|
// ─── Component ────────────────────────────────────────────────────────────────
|
|
86
10
|
const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPress, isNew = false, searchStr = '', msSincePrev, computedScreenName, }) {
|
|
11
|
+
const { t } = useTranslation();
|
|
87
12
|
const color = getEventColor(event.name);
|
|
88
13
|
const paramCount = event.params ? Object.keys(event.params).length : 0;
|
|
89
14
|
const userPropCount = event.userProperties
|
|
@@ -104,11 +29,19 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
104
29
|
return (<View style={cardStyles.container}>
|
|
105
30
|
{/* ── Gap Indicator ─────────────────────────────────────────────────── */}
|
|
106
31
|
{showGap && (<View style={cardStyles.gapContainer}>
|
|
107
|
-
<Text style={[cardStyles.gapText, { color: AppColors.grayTextWeak }]}>
|
|
32
|
+
<Text style={[cardStyles.gapText, { color: AppColors.grayTextWeak }]}>
|
|
33
|
+
{formatGap(msSincePrev)}
|
|
34
|
+
</Text>
|
|
108
35
|
</View>)}
|
|
109
36
|
|
|
110
37
|
{/* ── Main Card ─────────────────────────────────────────────────────── */}
|
|
111
|
-
<TouchableScale onPress={onPress} style={[
|
|
38
|
+
<TouchableScale onPress={onPress} style={[
|
|
39
|
+
cardStyles.modernCard,
|
|
40
|
+
{
|
|
41
|
+
backgroundColor: AppColors.primaryLight,
|
|
42
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
43
|
+
},
|
|
44
|
+
]}>
|
|
112
45
|
<Animated.View style={[
|
|
113
46
|
StyleSheet.absoluteFill,
|
|
114
47
|
{
|
|
@@ -131,14 +64,21 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
131
64
|
</View>
|
|
132
65
|
|
|
133
66
|
{(() => {
|
|
134
|
-
const
|
|
135
|
-
const tagColors = getCategoryColors(
|
|
67
|
+
const catKey = getEventCategory(event.name);
|
|
68
|
+
const tagColors = getCategoryColors(catKey);
|
|
69
|
+
const categoryLabel = catKey === 'page_view'
|
|
70
|
+
? t('analytics.pageViewCategory')
|
|
71
|
+
: catKey === 'ecommerce'
|
|
72
|
+
? t('analytics.ecommerceCategory')
|
|
73
|
+
: catKey === 'system'
|
|
74
|
+
? t('analytics.systemCategory')
|
|
75
|
+
: t('analytics.customCategory');
|
|
136
76
|
return (<View style={[
|
|
137
77
|
cardStyles.categoryBadge,
|
|
138
78
|
{ backgroundColor: tagColors.bg, borderColor: tagColors.border },
|
|
139
79
|
]}>
|
|
140
80
|
<Text style={[cardStyles.categoryText, { color: tagColors.text }]}>
|
|
141
|
-
{
|
|
81
|
+
{categoryLabel}
|
|
142
82
|
</Text>
|
|
143
83
|
</View>);
|
|
144
84
|
})()}
|
|
@@ -154,7 +94,8 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
154
94
|
cardStyles.duplicateText,
|
|
155
95
|
event.count === 1 && { color: AppColors.grayTextStrong },
|
|
156
96
|
]}>
|
|
157
|
-
{event.count}×
|
|
97
|
+
{event.count}×
|
|
98
|
+
{event.count > 1 ? ` ${t('analytics.duplicate')}` : ''}
|
|
158
99
|
</Text>
|
|
159
100
|
</View>) : null}
|
|
160
101
|
</View>
|
|
@@ -177,7 +118,13 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
177
118
|
const screenNameStr = typeof rawScreenName === 'object'
|
|
178
119
|
? JSON.stringify(rawScreenName)
|
|
179
120
|
: String(rawScreenName);
|
|
180
|
-
return (<View style={[
|
|
121
|
+
return (<View style={[
|
|
122
|
+
cardStyles.chip,
|
|
123
|
+
{
|
|
124
|
+
backgroundColor: AppColors.grayBackground,
|
|
125
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
126
|
+
},
|
|
127
|
+
]}>
|
|
181
128
|
<View style={[cardStyles.screenDot, { backgroundColor: color }]}/>
|
|
182
129
|
<Text style={[cardStyles.chipText, { color: AppColors.grayText }]} numberOfLines={1}>
|
|
183
130
|
{screenNameStr}
|
|
@@ -185,22 +132,51 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
185
132
|
</View>);
|
|
186
133
|
})()}
|
|
187
134
|
|
|
188
|
-
<View style={[
|
|
135
|
+
<View style={[
|
|
136
|
+
cardStyles.chip,
|
|
137
|
+
{
|
|
138
|
+
backgroundColor: AppColors.grayBackground,
|
|
139
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
140
|
+
},
|
|
141
|
+
]}>
|
|
189
142
|
<Text style={[cardStyles.chipText, { color: AppColors.grayText }]}>
|
|
190
|
-
{'{} '} {paramCount} params
|
|
143
|
+
{'{} '} {paramCount} {t('analytics.params')}
|
|
191
144
|
</Text>
|
|
192
145
|
</View>
|
|
193
146
|
|
|
194
|
-
{userPropCount > 0 && (<View style={[
|
|
195
|
-
|
|
147
|
+
{userPropCount > 0 && (<View style={[
|
|
148
|
+
cardStyles.chip,
|
|
149
|
+
{
|
|
150
|
+
backgroundColor: AppColors.grayBackground,
|
|
151
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
152
|
+
},
|
|
153
|
+
]}>
|
|
154
|
+
<Text style={[cardStyles.chipText, { color: AppColors.grayText }]}>
|
|
155
|
+
★ {userPropCount} {t('analytics.props')}
|
|
156
|
+
</Text>
|
|
196
157
|
</View>)}
|
|
197
158
|
|
|
198
159
|
{(() => {
|
|
199
160
|
const items = event.params?.items;
|
|
200
161
|
if (Array.isArray(items) && items.length > 0) {
|
|
201
|
-
return (<View style={[
|
|
202
|
-
|
|
203
|
-
|
|
162
|
+
return (<View style={[
|
|
163
|
+
cardStyles.chip,
|
|
164
|
+
{
|
|
165
|
+
backgroundColor: AppColors.amberBg,
|
|
166
|
+
borderColor: AppColors.amberBorder,
|
|
167
|
+
},
|
|
168
|
+
]}>
|
|
169
|
+
<Text style={[
|
|
170
|
+
cardStyles.chipText,
|
|
171
|
+
{
|
|
172
|
+
color: AppColors.amber700,
|
|
173
|
+
fontFamily: AppFonts.interBold,
|
|
174
|
+
},
|
|
175
|
+
]}>
|
|
176
|
+
🛒 {items.length}{' '}
|
|
177
|
+
{items.length === 1
|
|
178
|
+
? t('analytics.item')
|
|
179
|
+
: t('analytics.items')}
|
|
204
180
|
</Text>
|
|
205
181
|
</View>);
|
|
206
182
|
}
|
|
@@ -212,9 +188,23 @@ const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPre
|
|
|
212
188
|
const currency = event.params?.currency ?? '';
|
|
213
189
|
const isPrimitive = typeof val === 'string' || typeof val === 'number';
|
|
214
190
|
if (isPrimitive) {
|
|
215
|
-
const currencyStr = typeof currency === 'string' || typeof currency === 'number'
|
|
216
|
-
|
|
217
|
-
|
|
191
|
+
const currencyStr = typeof currency === 'string' || typeof currency === 'number'
|
|
192
|
+
? String(currency)
|
|
193
|
+
: '';
|
|
194
|
+
return (<View style={[
|
|
195
|
+
cardStyles.chip,
|
|
196
|
+
{
|
|
197
|
+
backgroundColor: AppColors.emeraldBg,
|
|
198
|
+
borderColor: AppColors.emeraldBorder,
|
|
199
|
+
},
|
|
200
|
+
]}>
|
|
201
|
+
<Text style={[
|
|
202
|
+
cardStyles.chipText,
|
|
203
|
+
{
|
|
204
|
+
color: AppColors.emerald600,
|
|
205
|
+
fontFamily: AppFonts.interBold,
|
|
206
|
+
},
|
|
207
|
+
]}>
|
|
218
208
|
💰 {String(val)} {currencyStr}
|
|
219
209
|
</Text>
|
|
220
210
|
</View>);
|