react-native-debug-toolkit 0.6.4 → 2.0.0

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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -212
  3. package/lib/commonjs/components/ClipboardTab.js +92 -0
  4. package/lib/commonjs/components/ClipboardTab.js.map +1 -0
  5. package/lib/commonjs/components/ConsoleLogTab.js +295 -0
  6. package/lib/commonjs/components/ConsoleLogTab.js.map +1 -0
  7. package/lib/commonjs/components/EnvironmentTab.js +288 -0
  8. package/lib/commonjs/components/EnvironmentTab.js.map +1 -0
  9. package/lib/commonjs/components/FloatPanelView.js +797 -0
  10. package/lib/commonjs/components/FloatPanelView.js.map +1 -0
  11. package/lib/commonjs/components/NavigationLogTab.js +131 -0
  12. package/lib/commonjs/components/NavigationLogTab.js.map +1 -0
  13. package/lib/commonjs/components/NetworkLogTab.js +575 -0
  14. package/lib/commonjs/components/NetworkLogTab.js.map +1 -0
  15. package/lib/commonjs/components/ThirdPartyLibsTab.js +97 -0
  16. package/lib/commonjs/components/ThirdPartyLibsTab.js.map +1 -0
  17. package/lib/commonjs/components/TrackLogTab.js +372 -0
  18. package/lib/commonjs/components/TrackLogTab.js.map +1 -0
  19. package/lib/commonjs/components/ZustandLogTab.js +451 -0
  20. package/lib/commonjs/components/ZustandLogTab.js.map +1 -0
  21. package/lib/commonjs/components/shared/CollapsibleSection.js +84 -0
  22. package/lib/commonjs/components/shared/CollapsibleSection.js.map +1 -0
  23. package/lib/commonjs/components/shared/CopyButton.js +64 -0
  24. package/lib/commonjs/components/shared/CopyButton.js.map +1 -0
  25. package/lib/commonjs/components/shared/JsonView.js +157 -0
  26. package/lib/commonjs/components/shared/JsonView.js.map +1 -0
  27. package/lib/commonjs/core/DebugToolkit.js +142 -0
  28. package/lib/commonjs/core/DebugToolkit.js.map +1 -0
  29. package/lib/commonjs/core/DebugToolkitProvider.js +64 -0
  30. package/lib/commonjs/core/DebugToolkitProvider.js.map +1 -0
  31. package/lib/commonjs/features/ClipboardFeature.js +17 -0
  32. package/lib/commonjs/features/ClipboardFeature.js.map +1 -0
  33. package/lib/commonjs/features/ConsoleLogFeature.js +98 -0
  34. package/lib/commonjs/features/ConsoleLogFeature.js.map +1 -0
  35. package/lib/commonjs/features/EnvironmentFeature.js +168 -0
  36. package/lib/commonjs/features/EnvironmentFeature.js.map +1 -0
  37. package/lib/commonjs/features/NavigationLogFeature.js +60 -0
  38. package/lib/commonjs/features/NavigationLogFeature.js.map +1 -0
  39. package/lib/commonjs/features/NetworkFeature.js +328 -0
  40. package/lib/commonjs/features/NetworkFeature.js.map +1 -0
  41. package/lib/commonjs/features/ThirdPartyLibsFeature.js +51 -0
  42. package/lib/commonjs/features/ThirdPartyLibsFeature.js.map +1 -0
  43. package/lib/commonjs/features/TrackFeature.js +55 -0
  44. package/lib/commonjs/features/TrackFeature.js.map +1 -0
  45. package/lib/commonjs/features/ZustandLogFeature.js +76 -0
  46. package/lib/commonjs/features/ZustandLogFeature.js.map +1 -0
  47. package/lib/commonjs/hooks/useNavigationLogger.js +78 -0
  48. package/lib/commonjs/hooks/useNavigationLogger.js.map +1 -0
  49. package/lib/commonjs/hooks/useSlideDetailAnimation.js +53 -0
  50. package/lib/commonjs/hooks/useSlideDetailAnimation.js.map +1 -0
  51. package/lib/commonjs/index.js +165 -0
  52. package/lib/commonjs/index.js.map +1 -0
  53. package/lib/commonjs/initialize.js +161 -0
  54. package/lib/commonjs/initialize.js.map +1 -0
  55. package/lib/commonjs/native/NativeDebugLibs.js +58 -0
  56. package/lib/commonjs/native/NativeDebugLibs.js.map +1 -0
  57. package/lib/commonjs/package.json +1 -0
  58. package/lib/commonjs/types/index.js +6 -0
  59. package/lib/commonjs/types/index.js.map +1 -0
  60. package/lib/commonjs/utils/constants.js +135 -0
  61. package/lib/commonjs/utils/constants.js.map +1 -0
  62. package/lib/commonjs/utils/copyToComputer.js +97 -0
  63. package/lib/commonjs/utils/copyToComputer.js.map +1 -0
  64. package/lib/commonjs/utils/createEventChannel.js +21 -0
  65. package/lib/commonjs/utils/createEventChannel.js.map +1 -0
  66. package/lib/commonjs/utils/createObservableStore.js +38 -0
  67. package/lib/commonjs/utils/createObservableStore.js.map +1 -0
  68. package/lib/commonjs/utils/safeStringify.js +27 -0
  69. package/lib/commonjs/utils/safeStringify.js.map +1 -0
  70. package/lib/module/components/ClipboardTab.js +86 -0
  71. package/lib/module/components/ClipboardTab.js.map +1 -0
  72. package/lib/module/components/ConsoleLogTab.js +290 -0
  73. package/lib/module/components/ConsoleLogTab.js.map +1 -0
  74. package/lib/module/components/EnvironmentTab.js +282 -0
  75. package/lib/module/components/EnvironmentTab.js.map +1 -0
  76. package/lib/module/components/FloatPanelView.js +791 -0
  77. package/lib/module/components/FloatPanelView.js.map +1 -0
  78. package/lib/module/components/NavigationLogTab.js +126 -0
  79. package/lib/module/components/NavigationLogTab.js.map +1 -0
  80. package/lib/module/components/NetworkLogTab.js +570 -0
  81. package/lib/module/components/NetworkLogTab.js.map +1 -0
  82. package/lib/module/components/ThirdPartyLibsTab.js +91 -0
  83. package/lib/module/components/ThirdPartyLibsTab.js.map +1 -0
  84. package/lib/module/components/TrackLogTab.js +367 -0
  85. package/lib/module/components/TrackLogTab.js.map +1 -0
  86. package/lib/module/components/ZustandLogTab.js +446 -0
  87. package/lib/module/components/ZustandLogTab.js.map +1 -0
  88. package/lib/module/components/shared/CollapsibleSection.js +78 -0
  89. package/lib/module/components/shared/CollapsibleSection.js.map +1 -0
  90. package/lib/module/components/shared/CopyButton.js +58 -0
  91. package/lib/module/components/shared/CopyButton.js.map +1 -0
  92. package/lib/module/components/shared/JsonView.js +152 -0
  93. package/lib/module/components/shared/JsonView.js.map +1 -0
  94. package/lib/module/core/DebugToolkit.js +137 -0
  95. package/lib/module/core/DebugToolkit.js.map +1 -0
  96. package/lib/module/core/DebugToolkitProvider.js +58 -0
  97. package/lib/module/core/DebugToolkitProvider.js.map +1 -0
  98. package/lib/module/features/ClipboardFeature.js +12 -0
  99. package/lib/module/features/ClipboardFeature.js.map +1 -0
  100. package/lib/module/features/ConsoleLogFeature.js +93 -0
  101. package/lib/module/features/ConsoleLogFeature.js.map +1 -0
  102. package/lib/module/features/EnvironmentFeature.js +164 -0
  103. package/lib/module/features/EnvironmentFeature.js.map +1 -0
  104. package/lib/module/features/NavigationLogFeature.js +54 -0
  105. package/lib/module/features/NavigationLogFeature.js.map +1 -0
  106. package/lib/module/features/NetworkFeature.js +322 -0
  107. package/lib/module/features/NetworkFeature.js.map +1 -0
  108. package/lib/module/features/ThirdPartyLibsFeature.js +46 -0
  109. package/lib/module/features/ThirdPartyLibsFeature.js.map +1 -0
  110. package/lib/module/features/TrackFeature.js +49 -0
  111. package/lib/module/features/TrackFeature.js.map +1 -0
  112. package/lib/module/features/ZustandLogFeature.js +69 -0
  113. package/lib/module/features/ZustandLogFeature.js.map +1 -0
  114. package/lib/module/hooks/useNavigationLogger.js +74 -0
  115. package/lib/module/hooks/useNavigationLogger.js.map +1 -0
  116. package/lib/module/hooks/useSlideDetailAnimation.js +50 -0
  117. package/lib/module/hooks/useSlideDetailAnimation.js.map +1 -0
  118. package/lib/module/index.js +29 -0
  119. package/lib/module/index.js.map +1 -0
  120. package/lib/module/initialize.js +156 -0
  121. package/lib/module/initialize.js.map +1 -0
  122. package/lib/module/native/NativeDebugLibs.js +54 -0
  123. package/lib/module/native/NativeDebugLibs.js.map +1 -0
  124. package/lib/module/package.json +1 -0
  125. package/lib/module/types/index.js +4 -0
  126. package/lib/module/types/index.js.map +1 -0
  127. package/lib/module/utils/constants.js +130 -0
  128. package/lib/module/utils/constants.js.map +1 -0
  129. package/lib/module/utils/copyToComputer.js +91 -0
  130. package/lib/module/utils/copyToComputer.js.map +1 -0
  131. package/lib/module/utils/createEventChannel.js +17 -0
  132. package/lib/module/utils/createEventChannel.js.map +1 -0
  133. package/lib/module/utils/createObservableStore.js +34 -0
  134. package/lib/module/utils/createObservableStore.js.map +1 -0
  135. package/lib/module/utils/safeStringify.js +23 -0
  136. package/lib/module/utils/safeStringify.js.map +1 -0
  137. package/lib/typescript/src/components/ClipboardTab.d.ts +4 -0
  138. package/lib/typescript/src/components/ClipboardTab.d.ts.map +1 -0
  139. package/lib/typescript/src/components/ConsoleLogTab.d.ts +4 -0
  140. package/lib/typescript/src/components/ConsoleLogTab.d.ts.map +1 -0
  141. package/lib/typescript/src/components/EnvironmentTab.d.ts +4 -0
  142. package/lib/typescript/src/components/EnvironmentTab.d.ts.map +1 -0
  143. package/lib/typescript/src/components/FloatPanelView.d.ts +64 -0
  144. package/lib/typescript/src/components/FloatPanelView.d.ts.map +1 -0
  145. package/lib/typescript/src/components/NavigationLogTab.d.ts +4 -0
  146. package/lib/typescript/src/components/NavigationLogTab.d.ts.map +1 -0
  147. package/lib/typescript/src/components/NetworkLogTab.d.ts +4 -0
  148. package/lib/typescript/src/components/NetworkLogTab.d.ts.map +1 -0
  149. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts +4 -0
  150. package/lib/typescript/src/components/ThirdPartyLibsTab.d.ts.map +1 -0
  151. package/lib/typescript/src/components/TrackLogTab.d.ts +4 -0
  152. package/lib/typescript/src/components/TrackLogTab.d.ts.map +1 -0
  153. package/lib/typescript/src/components/ZustandLogTab.d.ts +4 -0
  154. package/lib/typescript/src/components/ZustandLogTab.d.ts.map +1 -0
  155. package/lib/typescript/src/components/shared/CollapsibleSection.d.ts +9 -0
  156. package/lib/typescript/src/components/shared/CollapsibleSection.d.ts.map +1 -0
  157. package/lib/typescript/src/components/shared/CopyButton.d.ts +12 -0
  158. package/lib/typescript/src/components/shared/CopyButton.d.ts.map +1 -0
  159. package/lib/typescript/src/components/shared/JsonView.d.ts +6 -0
  160. package/lib/typescript/src/components/shared/JsonView.d.ts.map +1 -0
  161. package/lib/typescript/src/core/DebugToolkit.d.ts +27 -0
  162. package/lib/typescript/src/core/DebugToolkit.d.ts.map +1 -0
  163. package/lib/typescript/src/core/DebugToolkitProvider.d.ts +18 -0
  164. package/lib/typescript/src/core/DebugToolkitProvider.d.ts.map +1 -0
  165. package/lib/typescript/src/features/ClipboardFeature.d.ts +3 -0
  166. package/lib/typescript/src/features/ClipboardFeature.d.ts.map +1 -0
  167. package/lib/typescript/src/features/ConsoleLogFeature.d.ts +7 -0
  168. package/lib/typescript/src/features/ConsoleLogFeature.d.ts.map +1 -0
  169. package/lib/typescript/src/features/EnvironmentFeature.d.ts +8 -0
  170. package/lib/typescript/src/features/EnvironmentFeature.d.ts.map +1 -0
  171. package/lib/typescript/src/features/NavigationLogFeature.d.ts +8 -0
  172. package/lib/typescript/src/features/NavigationLogFeature.d.ts.map +1 -0
  173. package/lib/typescript/src/features/NetworkFeature.d.ts +28 -0
  174. package/lib/typescript/src/features/NetworkFeature.d.ts.map +1 -0
  175. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts +3 -0
  176. package/lib/typescript/src/features/ThirdPartyLibsFeature.d.ts.map +1 -0
  177. package/lib/typescript/src/features/TrackFeature.d.ts +12 -0
  178. package/lib/typescript/src/features/TrackFeature.d.ts.map +1 -0
  179. package/lib/typescript/src/features/ZustandLogFeature.d.ts +29 -0
  180. package/lib/typescript/src/features/ZustandLogFeature.d.ts.map +1 -0
  181. package/lib/typescript/src/hooks/useNavigationLogger.d.ts +20 -0
  182. package/lib/typescript/src/hooks/useNavigationLogger.d.ts.map +1 -0
  183. package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts +11 -0
  184. package/lib/typescript/src/hooks/useSlideDetailAnimation.d.ts.map +1 -0
  185. package/lib/typescript/src/index.d.ts +26 -0
  186. package/lib/typescript/src/index.d.ts.map +1 -0
  187. package/lib/typescript/src/initialize.d.ts +51 -0
  188. package/lib/typescript/src/initialize.d.ts.map +1 -0
  189. package/lib/typescript/src/native/NativeDebugLibs.d.ts +11 -0
  190. package/lib/typescript/src/native/NativeDebugLibs.d.ts.map +1 -0
  191. package/lib/typescript/src/types/index.d.ts +112 -0
  192. package/lib/typescript/src/types/index.d.ts.map +1 -0
  193. package/lib/typescript/src/utils/constants.d.ts +96 -0
  194. package/lib/typescript/src/utils/constants.d.ts.map +1 -0
  195. package/lib/typescript/src/utils/copyToComputer.d.ts +30 -0
  196. package/lib/typescript/src/utils/copyToComputer.d.ts.map +1 -0
  197. package/lib/typescript/src/utils/createEventChannel.d.ts +7 -0
  198. package/lib/typescript/src/utils/createEventChannel.d.ts.map +1 -0
  199. package/lib/typescript/src/utils/createObservableStore.d.ts +9 -0
  200. package/lib/typescript/src/utils/createObservableStore.d.ts.map +1 -0
  201. package/lib/typescript/src/utils/safeStringify.d.ts +6 -0
  202. package/lib/typescript/src/utils/safeStringify.d.ts.map +1 -0
  203. package/package.json +63 -24
  204. package/src/components/ClipboardTab.tsx +81 -0
  205. package/src/components/ConsoleLogTab.tsx +209 -0
  206. package/src/components/EnvironmentTab.tsx +276 -0
  207. package/src/components/FloatPanelView.tsx +714 -0
  208. package/src/components/NavigationLogTab.tsx +66 -0
  209. package/src/components/NetworkLogTab.tsx +411 -0
  210. package/src/components/ThirdPartyLibsTab.tsx +63 -0
  211. package/src/components/TrackLogTab.tsx +245 -0
  212. package/src/components/ZustandLogTab.tsx +305 -0
  213. package/src/components/shared/CollapsibleSection.tsx +78 -0
  214. package/src/components/shared/CopyButton.tsx +68 -0
  215. package/src/components/shared/JsonView.tsx +125 -0
  216. package/src/core/DebugToolkit.tsx +174 -0
  217. package/src/core/DebugToolkitProvider.tsx +89 -0
  218. package/src/features/ClipboardFeature.ts +11 -0
  219. package/src/features/ConsoleLogFeature.ts +118 -0
  220. package/src/features/EnvironmentFeature.ts +194 -0
  221. package/src/features/NavigationLogFeature.ts +74 -0
  222. package/src/features/NetworkFeature.ts +488 -0
  223. package/src/features/ThirdPartyLibsFeature.ts +42 -0
  224. package/src/features/TrackFeature.ts +69 -0
  225. package/src/features/ZustandLogFeature.ts +127 -0
  226. package/src/hooks/useNavigationLogger.ts +107 -0
  227. package/src/hooks/useSlideDetailAnimation.ts +45 -0
  228. package/src/index.ts +52 -0
  229. package/src/initialize.ts +214 -0
  230. package/src/native/NativeDebugLibs.ts +74 -0
  231. package/src/types/index.ts +138 -0
  232. package/src/utils/constants.ts +91 -0
  233. package/src/utils/copyToComputer.ts +104 -0
  234. package/src/utils/createEventChannel.ts +22 -0
  235. package/src/utils/createObservableStore.ts +42 -0
  236. package/src/utils/safeStringify.ts +25 -0
  237. package/.cursor/rules/react-native.mdc +0 -41
  238. package/README.zh-CN.md +0 -230
  239. package/index.js +0 -41
  240. package/ios/BuildTypeModule.h +0 -9
  241. package/ios/BuildTypeModule.m +0 -42
  242. package/ios/RNDebugLibs.h +0 -10
  243. package/ios/RNDebugLibs.m +0 -79
  244. package/lib/DebugToolKit.js +0 -126
  245. package/lib/EnvironmentManager.ts +0 -80
  246. package/lib/NativeDebugLibs.js +0 -67
  247. package/lib/features/ConsoleLogFeature.js +0 -70
  248. package/lib/features/NavigationLogFeature.js +0 -45
  249. package/lib/features/NetworkFeature.js +0 -389
  250. package/lib/features/PerformanceFeature.js +0 -390
  251. package/lib/features/ThirdPartyLibsFeature.js +0 -63
  252. package/lib/features/TrackFeature.js +0 -94
  253. package/lib/features/ZustandLogFeature.js +0 -44
  254. package/lib/hooks/useNavigationLogger.js +0 -92
  255. package/lib/index.js +0 -114
  256. package/lib/navigation/NavigationLogger.js +0 -1
  257. package/lib/types/TrackTypes.ts +0 -92
  258. package/lib/utils/DebugConst.js +0 -67
  259. package/lib/utils/StorageUtils.js +0 -80
  260. package/lib/views/ConsoleLogDetails.js +0 -314
  261. package/lib/views/FloatPanelView.js +0 -697
  262. package/lib/views/HttpLogDetails.js +0 -648
  263. package/lib/views/NavigationLogDetails.js +0 -302
  264. package/lib/views/RestartModal.js +0 -75
  265. package/lib/views/SubViewConsoleLogs.js +0 -209
  266. package/lib/views/SubViewEnvironment.js +0 -73
  267. package/lib/views/SubViewHTTPLogs.js +0 -235
  268. package/lib/views/SubViewNavigationLogs.js +0 -199
  269. package/lib/views/SubViewPerformance.js +0 -515
  270. package/lib/views/SubViewThirdPartyLibs.js +0 -239
  271. package/lib/views/SubViewTrackLogs.js +0 -318
  272. package/lib/views/SubViewZustandLogs.js +0 -279
  273. package/lib/views/TabView.js +0 -66
  274. package/lib/views/TrackLogDetails.js +0 -481
  275. package/lib/views/ZustandLogDetails.js +0 -355
  276. package/react-native-debug-toolkit.podspec +0 -25
  277. package/react-native.config.js +0 -18
@@ -1,481 +0,0 @@
1
- import React, { useState, useCallback } from 'react'
2
- import { View, Text, StyleSheet, Clipboard, Dimensions } from 'react-native'
3
- import { ScrollView, Pressable } from 'react-native'
4
- import JSONTree from 'react-native-json-tree'
5
-
6
- const { width: SCREEN_WIDTH } = Dimensions.get('window')
7
-
8
- const theme = {
9
- scheme: 'monokai',
10
- author: 'wimer hazenberg (http://www.monokai.nl)',
11
- base00: '#272822',
12
- base01: '#383830',
13
- base02: '#49483e',
14
- base03: '#75715e',
15
- base04: '#a59f85',
16
- base05: '#f8f8f2',
17
- base06: '#f5f4f1',
18
- base07: '#f9f8f5',
19
- base08: '#f92672',
20
- base09: '#fd971f',
21
- base0A: '#f4bf75',
22
- base0B: '#a6e22e',
23
- base0C: '#a1efe4',
24
- base0D: '#66d9ef',
25
- base0E: '#ae81ff',
26
- base0F: '#cc6633'
27
- }
28
-
29
- const CopyButton = ({ text, style }) => {
30
- const [copied, setCopied] = useState(false)
31
-
32
- const handleCopy = async () => {
33
- await Clipboard.setString(text)
34
- setCopied(true)
35
- setTimeout(() => setCopied(false), 2000)
36
- }
37
-
38
- return (
39
- <Pressable style={[styles.copyButton, style]} onPress={handleCopy}>
40
- <Text style={styles.copyButtonText}>{copied ? 'Copied!' : 'Copy'}</Text>
41
- </Pressable>
42
- )
43
- }
44
-
45
- const CollapsibleSection = ({ title, children, initiallyExpanded = false }) => {
46
- const [expanded, setExpanded] = useState(initiallyExpanded)
47
-
48
- return (
49
- <View style={styles.collapsibleSection}>
50
- <Pressable
51
- style={styles.sectionHeader}
52
- onPress={() => setExpanded(!expanded)}>
53
- <Text style={styles.sectionTitle}>{title}</Text>
54
- <Text style={styles.expandIcon}>{expanded ? '▼' : '▶'}</Text>
55
- </Pressable>
56
- {expanded && children}
57
- </View>
58
- )
59
- }
60
-
61
- const JSONValue = ({ value, path = '', level = 0, maxExpandLevel = 2 }) => {
62
- if (value === null) {
63
- return <Text style={styles.jsonNull}>null</Text>
64
- }
65
-
66
- if (value === undefined) {
67
- return <Text style={styles.jsonNull}>undefined</Text>
68
- }
69
-
70
- if (typeof value === 'boolean') {
71
- return <Text style={styles.jsonBoolean}>{value.toString()}</Text>
72
- }
73
-
74
- if (typeof value === 'number') {
75
- return <Text style={styles.jsonNumber}>{value}</Text>
76
- }
77
-
78
- if (typeof value === 'string') {
79
- return (
80
- <Text style={styles.jsonString} selectable={true}>
81
- {value}
82
- </Text>
83
- )
84
- }
85
-
86
- // For objects and arrays, use JSONTree for improved large data handling
87
- if (typeof value === 'object') {
88
- return (
89
- <JSONTree
90
- data={value}
91
- theme={theme}
92
- invertTheme={true}
93
- hideRoot={true}
94
- shouldExpandNode={(keyPath, nodeData, currentLevel) => currentLevel < maxExpandLevel}
95
- />
96
- )
97
- }
98
-
99
- return <Text>{String(value)}</Text>
100
- }
101
-
102
- const EventTypeBadge = ({ eventName, entityType }) => {
103
- const getEventColor = () => {
104
- if (eventName?.includes('error')) return '#ff4444'
105
- if (eventName?.includes('click')) return '#4CAF50'
106
- if (eventName?.includes('view')) return '#2196F3'
107
- if (eventName?.includes('search')) return '#FF9800'
108
- return '#9C27B0'
109
- }
110
-
111
- return (
112
- <View style={styles.badgeContainer}>
113
- <Text style={[styles.eventBadge, { backgroundColor: getEventColor() }]}>
114
- {eventName || 'Unknown Event'}
115
- </Text>
116
- {entityType && (
117
- <Text style={[styles.entityBadge]}>
118
- {entityType}
119
- </Text>
120
- )}
121
- </View>
122
- )
123
- }
124
-
125
- const TrackLogDetails = ({ log }) => {
126
- const generateAnalyticsPayload = useCallback(() => {
127
- if (!log) {
128
- return 'No event data available'
129
- }
130
-
131
- const payload = {
132
- eventName: log.eventName,
133
- timestamp: log.timestamp,
134
- ...Object.fromEntries(
135
- Object.entries(log).filter(([key, value]) =>
136
- key !== 'timestamp' && value !== undefined && value !== null
137
- )
138
- )
139
- }
140
-
141
- return JSON.stringify(payload, null, 2)
142
- }, [log])
143
-
144
- if (!log) {
145
- return (
146
- <View style={styles.errorContainer}>
147
- <Text style={styles.errorText}>Event data is missing</Text>
148
- </View>
149
- )
150
- }
151
-
152
- const coreProperties = {
153
- eventName: log.eventName,
154
- entityType: log.entityType,
155
- entityName: log.entityName,
156
- frontOperation: log.frontOperation
157
- }
158
-
159
- const identificationProperties = {
160
- pageId: log.pageId,
161
- objId: log.objId,
162
- entityPath: log.entityPath,
163
- objType: log.objType,
164
- objPt: log.objPt
165
- }
166
-
167
- const locationProperties = {
168
- refPageLocation: log.refPageLocation,
169
- position: log.position,
170
- entityLocation: log.entityLocation
171
- }
172
-
173
- const searchProperties = {
174
- sessionId: log.sessionId,
175
- requestId: log.requestId,
176
- searchKeywored: log.searchKeywored,
177
- enSearchKeywored: log.enSearchKeywored
178
- }
179
-
180
- const filterUndefinedProperties = (obj) => {
181
- return Object.fromEntries(
182
- Object.entries(obj).filter(([key, value]) => value !== undefined && value !== null && value !== '')
183
- )
184
- }
185
-
186
- return (
187
- <ScrollView
188
- style={styles.container}
189
- contentContainerStyle={styles.contentContainer}
190
- showsVerticalScrollIndicator={true}
191
- scrollEventThrottle={16}
192
- keyboardShouldPersistTaps='handled'>
193
-
194
- <View style={styles.header}>
195
- <View style={styles.headerInfo}>
196
- <EventTypeBadge eventName={log.eventName} entityType={log.entityType} />
197
- {log.entityName && (
198
- <Text style={styles.entityName} selectable={true}>
199
- {log.entityName}
200
- </Text>
201
- )}
202
- {log.frontOperation && (
203
- <Text style={styles.operation}>
204
- Operation: {log.frontOperation}
205
- </Text>
206
- )}
207
- </View>
208
- <CopyButton text={generateAnalyticsPayload()} />
209
- </View>
210
-
211
- <CollapsibleSection title='Core Properties' initiallyExpanded={true}>
212
- <View style={styles.content}>
213
- <View style={styles.propertiesGrid}>
214
- {Object.entries(filterUndefinedProperties(coreProperties)).map(([key, value]) => (
215
- <View key={key} style={styles.propertyRow}>
216
- <Text style={styles.propertyKey}>{key}:</Text>
217
- <Text style={styles.propertyValue} selectable={true}>{value}</Text>
218
- </View>
219
- ))}
220
- </View>
221
- </View>
222
- </CollapsibleSection>
223
-
224
- {Object.keys(filterUndefinedProperties(identificationProperties)).length > 0 && (
225
- <CollapsibleSection title='Identification Properties'>
226
- <View style={styles.content}>
227
- <View style={styles.propertiesGrid}>
228
- {Object.entries(filterUndefinedProperties(identificationProperties)).map(([key, value]) => (
229
- <View key={key} style={styles.propertyRow}>
230
- <Text style={styles.propertyKey}>{key}:</Text>
231
- <Text style={styles.propertyValue} selectable={true}>{value}</Text>
232
- </View>
233
- ))}
234
- </View>
235
- </View>
236
- </CollapsibleSection>
237
- )}
238
-
239
- {Object.keys(filterUndefinedProperties(locationProperties)).length > 0 && (
240
- <CollapsibleSection title='Location Properties'>
241
- <View style={styles.content}>
242
- <View style={styles.propertiesGrid}>
243
- {Object.entries(filterUndefinedProperties(locationProperties)).map(([key, value]) => (
244
- <View key={key} style={styles.propertyRow}>
245
- <Text style={styles.propertyKey}>{key}:</Text>
246
- <Text style={styles.propertyValue} selectable={true}>{value}</Text>
247
- </View>
248
- ))}
249
- </View>
250
- </View>
251
- </CollapsibleSection>
252
- )}
253
-
254
- {Object.keys(filterUndefinedProperties(searchProperties)).length > 0 && (
255
- <CollapsibleSection title='Search Properties'>
256
- <View style={styles.content}>
257
- <View style={styles.propertiesGrid}>
258
- {Object.entries(filterUndefinedProperties(searchProperties)).map(([key, value]) => (
259
- <View key={key} style={styles.propertyRow}>
260
- <Text style={styles.propertyKey}>{key}:</Text>
261
- <Text style={styles.propertyValue} selectable={true}>{value}</Text>
262
- </View>
263
- ))}
264
- </View>
265
- </View>
266
- </CollapsibleSection>
267
- )}
268
-
269
- <CollapsibleSection title='Complete Event Data'>
270
- <View style={styles.content}>
271
- <View style={styles.dataSectionHeader}>
272
- <Text style={styles.dataSectionTitle}>Full JSON Payload</Text>
273
- <CopyButton text={generateAnalyticsPayload()} />
274
- </View>
275
- <View style={styles.dataContentWrapper}>
276
- <ScrollView
277
- style={styles.dataContent}
278
- nestedScrollEnabled={true}
279
- bounces={false}
280
- showsVerticalScrollIndicator={true}>
281
- <JSONValue value={log} maxExpandLevel={2} />
282
- </ScrollView>
283
- </View>
284
- </View>
285
- </CollapsibleSection>
286
-
287
- <CollapsibleSection title='Timing Information'>
288
- <View style={styles.content}>
289
- <View style={styles.propertyRow}>
290
- <Text style={styles.propertyKey}>Timestamp:</Text>
291
- <Text style={styles.propertyValue}>
292
- {log.timestamp
293
- ? new Date(log.timestamp).toLocaleString()
294
- : 'Unknown'}
295
- </Text>
296
- </View>
297
- <View style={styles.propertyRow}>
298
- <Text style={styles.propertyKey}>Time ago:</Text>
299
- <Text style={styles.propertyValue}>
300
- {log.timestamp
301
- ? getTimeAgo(log.timestamp)
302
- : 'Unknown'}
303
- </Text>
304
- </View>
305
- </View>
306
- </CollapsibleSection>
307
- </ScrollView>
308
- )
309
- }
310
-
311
- const getTimeAgo = (timestamp) => {
312
- const now = new Date()
313
- const eventTime = new Date(timestamp)
314
- const diffMs = now - eventTime
315
- const diffSeconds = Math.floor(diffMs / 1000)
316
- const diffMinutes = Math.floor(diffSeconds / 60)
317
- const diffHours = Math.floor(diffMinutes / 60)
318
-
319
- if (diffSeconds < 60) {
320
- return `${diffSeconds} seconds ago`
321
- } else if (diffMinutes < 60) {
322
- return `${diffMinutes} minutes ago`
323
- } else if (diffHours < 24) {
324
- return `${diffHours} hours ago`
325
- } else {
326
- const diffDays = Math.floor(diffHours / 24)
327
- return `${diffDays} days ago`
328
- }
329
- }
330
-
331
- const styles = StyleSheet.create({
332
- container: {
333
- flex: 1,
334
- backgroundColor: '#fff',
335
- },
336
- contentContainer: {
337
- paddingBottom: 20,
338
- },
339
- header: {
340
- flexDirection: 'row',
341
- padding: 15,
342
- borderBottomWidth: 1,
343
- borderBottomColor: '#eee',
344
- alignItems: 'flex-start',
345
- },
346
- headerInfo: {
347
- flex: 1,
348
- marginRight: 10,
349
- },
350
- badgeContainer: {
351
- flexDirection: 'row',
352
- alignItems: 'center',
353
- marginBottom: 8,
354
- },
355
- eventBadge: {
356
- paddingHorizontal: 12,
357
- paddingVertical: 4,
358
- borderRadius: 12,
359
- color: 'white',
360
- fontSize: 12,
361
- fontWeight: 'bold',
362
- marginRight: 8,
363
- },
364
- entityBadge: {
365
- paddingHorizontal: 8,
366
- paddingVertical: 2,
367
- borderRadius: 8,
368
- backgroundColor: '#f0f0f0',
369
- color: '#333',
370
- fontSize: 11,
371
- fontWeight: '500',
372
- },
373
- entityName: {
374
- fontSize: 16,
375
- color: '#333',
376
- marginBottom: 4,
377
- fontWeight: '600',
378
- },
379
- operation: {
380
- fontSize: 14,
381
- color: '#666',
382
- fontStyle: 'italic',
383
- },
384
- collapsibleSection: {
385
- marginBottom: 1,
386
- backgroundColor: '#fff',
387
- },
388
- sectionHeader: {
389
- flexDirection: 'row',
390
- justifyContent: 'space-between',
391
- alignItems: 'center',
392
- padding: 15,
393
- backgroundColor: '#f5f5f5',
394
- },
395
- sectionTitle: {
396
- fontSize: 15,
397
- fontWeight: 'bold',
398
- color: '#333',
399
- },
400
- expandIcon: {
401
- fontSize: 14,
402
- color: '#666',
403
- },
404
- content: {
405
- padding: 15,
406
- },
407
- propertiesGrid: {
408
- gap: 8,
409
- },
410
- propertyRow: {
411
- marginBottom: 8,
412
- },
413
- propertyKey: {
414
- fontSize: 14,
415
- fontWeight: 'bold',
416
- color: '#666',
417
- marginBottom: 2,
418
- },
419
- propertyValue: {
420
- fontSize: 14,
421
- color: '#333',
422
- },
423
- errorContainer: {
424
- flex: 1,
425
- justifyContent: 'center',
426
- alignItems: 'center',
427
- padding: 20,
428
- },
429
- errorText: {
430
- color: '#ff4444',
431
- fontSize: 16,
432
- },
433
- dataSectionHeader: {
434
- flexDirection: 'row',
435
- justifyContent: 'space-between',
436
- alignItems: 'center',
437
- marginBottom: 8,
438
- },
439
- dataSectionTitle: {
440
- fontSize: 14,
441
- fontWeight: 'bold',
442
- color: '#666',
443
- },
444
- dataContentWrapper: {
445
- flex: 1,
446
- },
447
- dataContent: {
448
- flex: 1,
449
- backgroundColor: '#f8f9fa',
450
- padding: 10,
451
- borderRadius: 4,
452
- borderWidth: 1,
453
- borderColor: '#e9ecef',
454
- },
455
- copyButton: {
456
- backgroundColor: '#e9ecef',
457
- paddingHorizontal: 10,
458
- paddingVertical: 5,
459
- borderRadius: 4,
460
- },
461
- copyButtonText: {
462
- fontSize: 12,
463
- color: '#666',
464
- },
465
- jsonString: {
466
- color: '#CB772F',
467
- },
468
- jsonNumber: {
469
- color: '#2878D0',
470
- },
471
- jsonBoolean: {
472
- color: '#2878D0',
473
- fontWeight: 'bold',
474
- },
475
- jsonNull: {
476
- color: '#A0A0A0',
477
- fontStyle: 'italic',
478
- },
479
- })
480
-
481
- export default TrackLogDetails