react-native-inapp-inspector 1.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.
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/commonjs/components/AnalyticsDetail.d.ts +6 -0
- package/dist/commonjs/components/AnalyticsDetail.js +558 -0
- package/dist/commonjs/components/AnalyticsEventCard.d.ts +18 -0
- package/dist/commonjs/components/AnalyticsEventCard.js +327 -0
- package/dist/commonjs/components/AnalyticsGraph.d.ts +8 -0
- package/dist/commonjs/components/AnalyticsGraph.js +416 -0
- package/dist/commonjs/components/CodeSnippet.d.ts +8 -0
- package/dist/commonjs/components/CodeSnippet.js +427 -0
- package/dist/commonjs/components/ConsoleLogCard.d.ts +10 -0
- package/dist/commonjs/components/ConsoleLogCard.js +401 -0
- package/dist/commonjs/components/CopyButton.d.ts +4 -0
- package/dist/commonjs/components/CopyButton.js +69 -0
- package/dist/commonjs/components/DiffViewer.d.ts +7 -0
- package/dist/commonjs/components/DiffViewer.js +86 -0
- package/dist/commonjs/components/DomainHeader.d.ts +18 -0
- package/dist/commonjs/components/DomainHeader.js +136 -0
- package/dist/commonjs/components/EmptyState.d.ts +5 -0
- package/dist/commonjs/components/EmptyState.js +40 -0
- package/dist/commonjs/components/HeadersSection.d.ts +4 -0
- package/dist/commonjs/components/HeadersSection.js +155 -0
- package/dist/commonjs/components/HighlightText.d.ts +3 -0
- package/dist/commonjs/components/HighlightText.js +57 -0
- package/dist/commonjs/components/JsonViewer.d.ts +7 -0
- package/dist/commonjs/components/JsonViewer.js +19 -0
- package/dist/commonjs/components/LogCard.d.ts +4 -0
- package/dist/commonjs/components/LogCard.js +179 -0
- package/dist/commonjs/components/MetaAccordion.d.ts +4 -0
- package/dist/commonjs/components/MetaAccordion.js +113 -0
- package/dist/commonjs/components/MiniBarChart.d.ts +7 -0
- package/dist/commonjs/components/MiniBarChart.js +56 -0
- package/dist/commonjs/components/MiniLineChart.d.ts +6 -0
- package/dist/commonjs/components/MiniLineChart.js +58 -0
- package/dist/commonjs/components/NetworkIcons.d.ts +31 -0
- package/dist/commonjs/components/NetworkIcons.js +245 -0
- package/dist/commonjs/components/SectionHeader.d.ts +4 -0
- package/dist/commonjs/components/SectionHeader.js +87 -0
- package/dist/commonjs/components/SourcePageCard.d.ts +4 -0
- package/dist/commonjs/components/SourcePageCard.js +132 -0
- package/dist/commonjs/components/TouchableScale.d.ts +9 -0
- package/dist/commonjs/components/TouchableScale.js +44 -0
- package/dist/commonjs/components/TreeNode.d.ts +4 -0
- package/dist/commonjs/components/TreeNode.js +140 -0
- package/dist/commonjs/constants/index.d.ts +7 -0
- package/dist/commonjs/constants/index.js +35 -0
- package/dist/commonjs/customHooks/analyticsLogger.d.ts +21 -0
- package/dist/commonjs/customHooks/analyticsLogger.js +160 -0
- package/dist/commonjs/customHooks/consoleLogger.d.ts +5 -0
- package/dist/commonjs/customHooks/consoleLogger.js +141 -0
- package/dist/commonjs/customHooks/logFilters.d.ts +5 -0
- package/dist/commonjs/customHooks/logFilters.js +34 -0
- package/dist/commonjs/customHooks/networkLogger.d.ts +20 -0
- package/dist/commonjs/customHooks/networkLogger.js +272 -0
- package/dist/commonjs/customHooks/useAccordion.d.ts +17 -0
- package/dist/commonjs/customHooks/useAccordion.js +48 -0
- package/dist/commonjs/customHooks/webViewLogger.d.ts +22 -0
- package/dist/commonjs/customHooks/webViewLogger.js +412 -0
- package/dist/commonjs/helpers/index.d.ts +20 -0
- package/dist/commonjs/helpers/index.js +229 -0
- package/dist/commonjs/index.d.ts +7 -0
- package/dist/commonjs/index.js +2668 -0
- package/dist/commonjs/styles/AppColors.d.ts +27 -0
- package/dist/commonjs/styles/AppColors.js +30 -0
- package/dist/commonjs/styles/AppFonts.d.ts +7 -0
- package/dist/commonjs/styles/AppFonts.js +10 -0
- package/dist/commonjs/styles/index.d.ts +1488 -0
- package/dist/commonjs/styles/index.js +1357 -0
- package/dist/commonjs/types/index.d.ts +127 -0
- package/dist/commonjs/types/index.js +2 -0
- package/dist/esm/components/AnalyticsDetail.d.ts +6 -0
- package/dist/esm/components/AnalyticsDetail.js +520 -0
- package/dist/esm/components/AnalyticsEventCard.d.ts +18 -0
- package/dist/esm/components/AnalyticsEventCard.js +288 -0
- package/dist/esm/components/AnalyticsGraph.d.ts +8 -0
- package/dist/esm/components/AnalyticsGraph.js +378 -0
- package/dist/esm/components/CodeSnippet.d.ts +8 -0
- package/dist/esm/components/CodeSnippet.js +392 -0
- package/dist/esm/components/ConsoleLogCard.d.ts +10 -0
- package/dist/esm/components/ConsoleLogCard.js +362 -0
- package/dist/esm/components/CopyButton.d.ts +4 -0
- package/dist/esm/components/CopyButton.js +31 -0
- package/dist/esm/components/DiffViewer.d.ts +7 -0
- package/dist/esm/components/DiffViewer.js +48 -0
- package/dist/esm/components/DomainHeader.d.ts +18 -0
- package/dist/esm/components/DomainHeader.js +98 -0
- package/dist/esm/components/EmptyState.d.ts +5 -0
- package/dist/esm/components/EmptyState.js +35 -0
- package/dist/esm/components/HeadersSection.d.ts +4 -0
- package/dist/esm/components/HeadersSection.js +117 -0
- package/dist/esm/components/HighlightText.d.ts +3 -0
- package/dist/esm/components/HighlightText.js +52 -0
- package/dist/esm/components/JsonViewer.d.ts +7 -0
- package/dist/esm/components/JsonViewer.js +14 -0
- package/dist/esm/components/LogCard.d.ts +4 -0
- package/dist/esm/components/LogCard.js +141 -0
- package/dist/esm/components/MetaAccordion.d.ts +4 -0
- package/dist/esm/components/MetaAccordion.js +108 -0
- package/dist/esm/components/MiniBarChart.d.ts +7 -0
- package/dist/esm/components/MiniBarChart.js +18 -0
- package/dist/esm/components/MiniLineChart.d.ts +6 -0
- package/dist/esm/components/MiniLineChart.js +20 -0
- package/dist/esm/components/NetworkIcons.d.ts +31 -0
- package/dist/esm/components/NetworkIcons.js +176 -0
- package/dist/esm/components/SectionHeader.d.ts +4 -0
- package/dist/esm/components/SectionHeader.js +49 -0
- package/dist/esm/components/SourcePageCard.d.ts +4 -0
- package/dist/esm/components/SourcePageCard.js +94 -0
- package/dist/esm/components/TouchableScale.d.ts +9 -0
- package/dist/esm/components/TouchableScale.js +9 -0
- package/dist/esm/components/TreeNode.d.ts +4 -0
- package/dist/esm/components/TreeNode.js +102 -0
- package/dist/esm/constants/index.d.ts +7 -0
- package/dist/esm/constants/index.js +32 -0
- package/dist/esm/customHooks/analyticsLogger.d.ts +21 -0
- package/dist/esm/customHooks/analyticsLogger.js +152 -0
- package/dist/esm/customHooks/consoleLogger.d.ts +5 -0
- package/dist/esm/customHooks/consoleLogger.js +134 -0
- package/dist/esm/customHooks/logFilters.d.ts +5 -0
- package/dist/esm/customHooks/logFilters.js +31 -0
- package/dist/esm/customHooks/networkLogger.d.ts +20 -0
- package/dist/esm/customHooks/networkLogger.js +264 -0
- package/dist/esm/customHooks/useAccordion.d.ts +17 -0
- package/dist/esm/customHooks/useAccordion.js +46 -0
- package/dist/esm/customHooks/webViewLogger.d.ts +22 -0
- package/dist/esm/customHooks/webViewLogger.js +365 -0
- package/dist/esm/helpers/index.d.ts +20 -0
- package/dist/esm/helpers/index.js +207 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +2611 -0
- package/dist/esm/styles/AppColors.d.ts +27 -0
- package/dist/esm/styles/AppColors.js +27 -0
- package/dist/esm/styles/AppFonts.d.ts +7 -0
- package/dist/esm/styles/AppFonts.js +7 -0
- package/dist/esm/styles/index.d.ts +1488 -0
- package/dist/esm/styles/index.js +1355 -0
- package/dist/esm/types/index.d.ts +127 -0
- package/dist/esm/types/index.js +1 -0
- package/fonts/Inter/Inter.ttc +0 -0
- package/fonts/Inter/InterVariable-Italic.ttf +0 -0
- package/fonts/Inter/InterVariable.ttf +0 -0
- package/fonts/Inter/LICENSE.txt +92 -0
- package/fonts/Inter/extras/otf/Inter-Black.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-BlackItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Bold.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-BoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-ExtraBold.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-ExtraBoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-ExtraLight.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-ExtraLightItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Italic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Light.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-LightItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Medium.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-MediumItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Regular.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-SemiBold.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-SemiBoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-Thin.otf +0 -0
- package/fonts/Inter/extras/otf/Inter-ThinItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Black.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-BlackItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Bold.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-BoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-ExtraBold.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-ExtraBoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-ExtraLight.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-ExtraLightItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Italic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Light.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-LightItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Medium.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-MediumItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Regular.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-SemiBold.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-SemiBoldItalic.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-Thin.otf +0 -0
- package/fonts/Inter/extras/otf/InterDisplay-ThinItalic.otf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Black.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-BlackItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Bold.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-BoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-ExtraBold.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-ExtraBoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-ExtraLight.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-ExtraLightItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Italic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Light.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-LightItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Medium.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-MediumItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Regular.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-SemiBold.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-SemiBoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-Thin.ttf +0 -0
- package/fonts/Inter/extras/ttf/Inter-ThinItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Black.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-BlackItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Bold.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-BoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-ExtraBold.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-ExtraBoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-ExtraLight.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-ExtraLightItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Italic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Light.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-LightItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Medium.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-MediumItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Regular.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-SemiBold.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-SemiBoldItalic.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-Thin.ttf +0 -0
- package/fonts/Inter/extras/ttf/InterDisplay-ThinItalic.ttf +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Black.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-BlackItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Bold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-ExtraLight.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Italic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Light.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-LightItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Medium.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-MediumItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Regular.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-SemiBold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-Thin.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/Inter-ThinItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Black.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-BlackItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Bold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-BoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-ExtraBold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-ExtraLight.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Italic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Light.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-LightItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Medium.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-MediumItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Regular.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-SemiBold.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-Thin.woff2 +0 -0
- package/fonts/Inter/extras/woff-hinted/InterDisplay-ThinItalic.woff2 +0 -0
- package/fonts/Inter/help.txt +165 -0
- package/fonts/Inter/web/Inter-Black.woff2 +0 -0
- package/fonts/Inter/web/Inter-BlackItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Bold.woff2 +0 -0
- package/fonts/Inter/web/Inter-BoldItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-ExtraBold.woff2 +0 -0
- package/fonts/Inter/web/Inter-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-ExtraLight.woff2 +0 -0
- package/fonts/Inter/web/Inter-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Italic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Light.woff2 +0 -0
- package/fonts/Inter/web/Inter-LightItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Medium.woff2 +0 -0
- package/fonts/Inter/web/Inter-MediumItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Regular.woff2 +0 -0
- package/fonts/Inter/web/Inter-SemiBold.woff2 +0 -0
- package/fonts/Inter/web/Inter-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter/web/Inter-Thin.woff2 +0 -0
- package/fonts/Inter/web/Inter-ThinItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Black.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-BlackItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Bold.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-BoldItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-ExtraBold.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-ExtraBoldItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-ExtraLight.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-ExtraLightItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Italic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Light.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-LightItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Medium.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-MediumItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Regular.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-SemiBold.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-SemiBoldItalic.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-Thin.woff2 +0 -0
- package/fonts/Inter/web/InterDisplay-ThinItalic.woff2 +0 -0
- package/fonts/Inter/web/InterVariable-Italic.woff2 +0 -0
- package/fonts/Inter/web/InterVariable.woff2 +0 -0
- package/fonts/Inter/web/inter.css +148 -0
- package/package.json +52 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import { AppColors } from '../styles/AppColors';
|
|
4
|
+
import { AppFonts } from '../styles/AppFonts';
|
|
5
|
+
import HighlightText from './HighlightText';
|
|
6
|
+
import TouchableScale from './TouchableScale';
|
|
7
|
+
// ─── Palette (Google Analytics colours) ───────────────────────────────────────
|
|
8
|
+
const EVENT_PALETTE = [
|
|
9
|
+
'#4285F4', // blue
|
|
10
|
+
'#34A853', // green
|
|
11
|
+
'#9C27B0', // purple
|
|
12
|
+
'#00897B', // teal
|
|
13
|
+
'#E53935', // red
|
|
14
|
+
'#F57C00', // orange
|
|
15
|
+
'#1565C0', // dark blue
|
|
16
|
+
'#2E7D32', // dark green
|
|
17
|
+
];
|
|
18
|
+
export function getEventColor(name) {
|
|
19
|
+
let hash = 0;
|
|
20
|
+
for (let i = 0; i < name.length; i++) {
|
|
21
|
+
hash = (hash * 31 + name.charCodeAt(i)) | 0;
|
|
22
|
+
}
|
|
23
|
+
return EVENT_PALETTE[Math.abs(hash) % EVENT_PALETTE.length];
|
|
24
|
+
}
|
|
25
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
26
|
+
function formatTime(ts) {
|
|
27
|
+
const d = new Date(ts);
|
|
28
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
29
|
+
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
30
|
+
const ss = String(d.getSeconds()).padStart(2, '0');
|
|
31
|
+
const ms = String(d.getMilliseconds()).padStart(3, '0');
|
|
32
|
+
return `${hh}:${mm}:${ss}.${ms}`;
|
|
33
|
+
}
|
|
34
|
+
function formatGap(ms) {
|
|
35
|
+
if (ms < 1000)
|
|
36
|
+
return `+${ms}ms`;
|
|
37
|
+
const s = Math.round(ms / 1000);
|
|
38
|
+
if (s < 60)
|
|
39
|
+
return `+${s}s`;
|
|
40
|
+
const m = Math.floor(s / 60);
|
|
41
|
+
const rem = s % 60;
|
|
42
|
+
return rem > 0 ? `+${m}m ${rem}s` : `+${m}m`;
|
|
43
|
+
}
|
|
44
|
+
// ─── Component ────────────────────────────────────────────────────────────────
|
|
45
|
+
const AnalyticsEventCard = React.memo(function AnalyticsEventCard({ event, onPress, isNew = false, searchStr = '', msSincePrev, computedScreenName, }) {
|
|
46
|
+
const color = getEventColor(event.name);
|
|
47
|
+
const paramCount = event.params ? Object.keys(event.params).length : 0;
|
|
48
|
+
const userPropCount = event.userProperties
|
|
49
|
+
? Object.keys(event.userProperties).length
|
|
50
|
+
: 0;
|
|
51
|
+
// Flash animation for newly logged events
|
|
52
|
+
const flashOpacity = useRef(new Animated.Value(isNew ? 1 : 0)).current;
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (isNew) {
|
|
55
|
+
Animated.timing(flashOpacity, {
|
|
56
|
+
toValue: 0,
|
|
57
|
+
duration: 1200,
|
|
58
|
+
useNativeDriver: true,
|
|
59
|
+
}).start();
|
|
60
|
+
}
|
|
61
|
+
}, [isNew]);
|
|
62
|
+
const showGap = msSincePrev != null && msSincePrev >= 2000;
|
|
63
|
+
return (<View style={cardStyles.container}>
|
|
64
|
+
{/* ── Gap Indicator ─────────────────────────────────────────────────── */}
|
|
65
|
+
{showGap && (<View style={cardStyles.gapContainer}>
|
|
66
|
+
<Text style={cardStyles.gapText}>{formatGap(msSincePrev)}</Text>
|
|
67
|
+
</View>)}
|
|
68
|
+
|
|
69
|
+
{/* ── Main Card ─────────────────────────────────────────────────────── */}
|
|
70
|
+
<TouchableScale onPress={onPress} style={cardStyles.modernCard}>
|
|
71
|
+
<Animated.View style={[
|
|
72
|
+
StyleSheet.absoluteFill,
|
|
73
|
+
{
|
|
74
|
+
backgroundColor: color,
|
|
75
|
+
opacity: flashOpacity.interpolate({
|
|
76
|
+
inputRange: [0, 1],
|
|
77
|
+
outputRange: [0, 0.08],
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
]}/>
|
|
81
|
+
|
|
82
|
+
{/* Top Row: Event Name & Timestamp */}
|
|
83
|
+
<View style={cardStyles.cardHeader}>
|
|
84
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 8 }}>
|
|
85
|
+
<View style={[
|
|
86
|
+
cardStyles.nameBadge,
|
|
87
|
+
{ backgroundColor: `${color}1A`, borderColor: `${color}30` },
|
|
88
|
+
]}>
|
|
89
|
+
<HighlightText text={event.name} search={searchStr} style={[cardStyles.eventName, { color: color }]} highlightStyle={cardStyles.highlight}/>
|
|
90
|
+
</View>
|
|
91
|
+
|
|
92
|
+
{event.count !== undefined ? (<View style={[
|
|
93
|
+
cardStyles.duplicateBadge,
|
|
94
|
+
event.count === 1 && {
|
|
95
|
+
backgroundColor: AppColors.grayBackground,
|
|
96
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
97
|
+
},
|
|
98
|
+
]}>
|
|
99
|
+
<Text style={[
|
|
100
|
+
cardStyles.duplicateText,
|
|
101
|
+
event.count === 1 && { color: AppColors.grayTextStrong },
|
|
102
|
+
]}>
|
|
103
|
+
{event.count}×{event.count > 1 ? ' Duplicate' : ''}
|
|
104
|
+
</Text>
|
|
105
|
+
</View>) : null}
|
|
106
|
+
</View>
|
|
107
|
+
<Text style={cardStyles.timestamp}>
|
|
108
|
+
{formatTime(event.timestamp)}
|
|
109
|
+
</Text>
|
|
110
|
+
</View>
|
|
111
|
+
|
|
112
|
+
{/* Bottom Row: Metadata Chips & Sparkline */}
|
|
113
|
+
<View style={cardStyles.cardBody}>
|
|
114
|
+
<View style={cardStyles.chipsRow}>
|
|
115
|
+
{computedScreenName ||
|
|
116
|
+
event.screenName ||
|
|
117
|
+
event.params?.firebase_screen ||
|
|
118
|
+
event.params?.screen_name ||
|
|
119
|
+
event.params?.firebase_screen_class ? (<View style={cardStyles.chip}>
|
|
120
|
+
<View style={[cardStyles.screenDot, { backgroundColor: color }]}/>
|
|
121
|
+
<Text style={cardStyles.chipText} numberOfLines={1}>
|
|
122
|
+
{computedScreenName ||
|
|
123
|
+
event.screenName ||
|
|
124
|
+
event.params?.firebase_screen ||
|
|
125
|
+
event.params?.screen_name ||
|
|
126
|
+
event.params?.firebase_screen_class}
|
|
127
|
+
</Text>
|
|
128
|
+
</View>) : null}
|
|
129
|
+
|
|
130
|
+
<View style={cardStyles.chip}>
|
|
131
|
+
<Text style={cardStyles.chipText}>
|
|
132
|
+
{'{} '} {paramCount} params
|
|
133
|
+
</Text>
|
|
134
|
+
</View>
|
|
135
|
+
|
|
136
|
+
{userPropCount > 0 && (<View style={cardStyles.chip}>
|
|
137
|
+
<Text style={cardStyles.chipText}>★ {userPropCount} props</Text>
|
|
138
|
+
</View>)}
|
|
139
|
+
</View>
|
|
140
|
+
|
|
141
|
+
{/* Inline Mini Graph for E-commerce Items */}
|
|
142
|
+
{(() => {
|
|
143
|
+
const items = event.params?.items;
|
|
144
|
+
if (!Array.isArray(items) || items.length === 0)
|
|
145
|
+
return null;
|
|
146
|
+
const prices = items
|
|
147
|
+
.map((item) => parseFloat(item.price || item.value))
|
|
148
|
+
.filter(p => !isNaN(p));
|
|
149
|
+
if (prices.length === 0)
|
|
150
|
+
return null;
|
|
151
|
+
const max = Math.max(...prices);
|
|
152
|
+
if (max === 0)
|
|
153
|
+
return null;
|
|
154
|
+
return (<View style={cardStyles.miniGraphWrapper}>
|
|
155
|
+
{prices.map((val, idx) => {
|
|
156
|
+
const hPct = (val / max) * 100;
|
|
157
|
+
return (<View key={idx} style={[
|
|
158
|
+
cardStyles.miniGraphBar,
|
|
159
|
+
{
|
|
160
|
+
height: `${Math.max(15, hPct)}%`,
|
|
161
|
+
backgroundColor: color,
|
|
162
|
+
},
|
|
163
|
+
]}/>);
|
|
164
|
+
})}
|
|
165
|
+
</View>);
|
|
166
|
+
})()}
|
|
167
|
+
</View>
|
|
168
|
+
</TouchableScale>
|
|
169
|
+
</View>);
|
|
170
|
+
});
|
|
171
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
172
|
+
const cardStyles = StyleSheet.create({
|
|
173
|
+
container: {
|
|
174
|
+
paddingHorizontal: 16,
|
|
175
|
+
paddingVertical: 4,
|
|
176
|
+
},
|
|
177
|
+
gapContainer: {
|
|
178
|
+
alignItems: 'center',
|
|
179
|
+
marginVertical: 4,
|
|
180
|
+
},
|
|
181
|
+
gapText: {
|
|
182
|
+
fontFamily: AppFonts.interMedium,
|
|
183
|
+
fontSize: 10,
|
|
184
|
+
color: AppColors.grayTextWeak,
|
|
185
|
+
letterSpacing: 0.5,
|
|
186
|
+
},
|
|
187
|
+
modernCard: {
|
|
188
|
+
backgroundColor: '#FFFFFF',
|
|
189
|
+
borderRadius: 8,
|
|
190
|
+
borderWidth: 1,
|
|
191
|
+
borderColor: '#EFEFEF',
|
|
192
|
+
padding: 12,
|
|
193
|
+
shadowColor: '#000',
|
|
194
|
+
shadowOpacity: 0.03,
|
|
195
|
+
shadowRadius: 3,
|
|
196
|
+
shadowOffset: { width: 0, height: 1 },
|
|
197
|
+
elevation: 1,
|
|
198
|
+
overflow: 'hidden',
|
|
199
|
+
},
|
|
200
|
+
cardHeader: {
|
|
201
|
+
flexDirection: 'row',
|
|
202
|
+
justifyContent: 'space-between',
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
marginBottom: 8,
|
|
205
|
+
},
|
|
206
|
+
nameBadge: {
|
|
207
|
+
paddingHorizontal: 8,
|
|
208
|
+
paddingVertical: 4,
|
|
209
|
+
borderRadius: 6,
|
|
210
|
+
borderWidth: 1,
|
|
211
|
+
},
|
|
212
|
+
eventName: {
|
|
213
|
+
fontFamily: AppFonts.interBold,
|
|
214
|
+
fontSize: 12,
|
|
215
|
+
letterSpacing: 0.2,
|
|
216
|
+
},
|
|
217
|
+
timestamp: {
|
|
218
|
+
fontFamily: AppFonts.interMedium,
|
|
219
|
+
fontSize: 11,
|
|
220
|
+
color: AppColors.grayTextWeak,
|
|
221
|
+
},
|
|
222
|
+
highlight: {
|
|
223
|
+
backgroundColor: '#FFE44D',
|
|
224
|
+
color: AppColors.primaryBlack,
|
|
225
|
+
borderRadius: 2,
|
|
226
|
+
},
|
|
227
|
+
cardBody: {
|
|
228
|
+
flexDirection: 'row',
|
|
229
|
+
alignItems: 'flex-end',
|
|
230
|
+
justifyContent: 'space-between',
|
|
231
|
+
},
|
|
232
|
+
chipsRow: {
|
|
233
|
+
flexDirection: 'row',
|
|
234
|
+
alignItems: 'center',
|
|
235
|
+
flexWrap: 'wrap',
|
|
236
|
+
gap: 8,
|
|
237
|
+
flex: 1,
|
|
238
|
+
},
|
|
239
|
+
chip: {
|
|
240
|
+
flexDirection: 'row',
|
|
241
|
+
alignItems: 'center',
|
|
242
|
+
backgroundColor: AppColors.grayBackground,
|
|
243
|
+
paddingHorizontal: 6,
|
|
244
|
+
paddingVertical: 3,
|
|
245
|
+
borderRadius: 4,
|
|
246
|
+
borderWidth: 1,
|
|
247
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
248
|
+
},
|
|
249
|
+
chipText: {
|
|
250
|
+
fontFamily: AppFonts.interMedium,
|
|
251
|
+
fontSize: 10,
|
|
252
|
+
color: AppColors.grayText,
|
|
253
|
+
},
|
|
254
|
+
screenDot: {
|
|
255
|
+
width: 6,
|
|
256
|
+
height: 6,
|
|
257
|
+
borderRadius: 3,
|
|
258
|
+
marginRight: 4,
|
|
259
|
+
},
|
|
260
|
+
duplicateBadge: {
|
|
261
|
+
backgroundColor: '#FFE4E6',
|
|
262
|
+
borderColor: '#FCC2D7',
|
|
263
|
+
borderWidth: 1,
|
|
264
|
+
paddingHorizontal: 6,
|
|
265
|
+
paddingVertical: 3,
|
|
266
|
+
borderRadius: 4,
|
|
267
|
+
},
|
|
268
|
+
duplicateText: {
|
|
269
|
+
fontFamily: AppFonts.interBold,
|
|
270
|
+
fontSize: 9,
|
|
271
|
+
color: '#E11D48',
|
|
272
|
+
textTransform: 'uppercase',
|
|
273
|
+
letterSpacing: 0.5,
|
|
274
|
+
},
|
|
275
|
+
miniGraphWrapper: {
|
|
276
|
+
flexDirection: 'row',
|
|
277
|
+
alignItems: 'flex-end',
|
|
278
|
+
height: 18,
|
|
279
|
+
gap: 2,
|
|
280
|
+
marginLeft: 12,
|
|
281
|
+
},
|
|
282
|
+
miniGraphBar: {
|
|
283
|
+
width: 4,
|
|
284
|
+
borderRadius: 2,
|
|
285
|
+
opacity: 0.7,
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
export default AnalyticsEventCard;
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Text, ScrollView, Dimensions, StyleSheet } from 'react-native';
|
|
3
|
+
import Svg, { Rect, Text as SvgText, Line, Circle, Path, Defs, LinearGradient, Stop, } from 'react-native-svg';
|
|
4
|
+
import { AppColors } from '../styles/AppColors';
|
|
5
|
+
import { AppFonts } from '../styles/AppFonts';
|
|
6
|
+
const BAR_HEIGHT = 24;
|
|
7
|
+
const PADDING_Y = 12;
|
|
8
|
+
const AnalyticsGraph = ({ event, accentColor }) => {
|
|
9
|
+
const params = event.params || {};
|
|
10
|
+
// 1. Check for E-commerce items array
|
|
11
|
+
const itemsArray = Array.isArray(params.items) ? params.items : null;
|
|
12
|
+
const filteredItems = itemsArray?.filter((item) => typeof item.price === 'number') || [];
|
|
13
|
+
// 2. Discover root-level numeric fields (exclude ids)
|
|
14
|
+
const rootNumericKeys = [];
|
|
15
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
16
|
+
if (typeof v === 'number' &&
|
|
17
|
+
!k.toLowerCase().includes('id') &&
|
|
18
|
+
!k.toLowerCase().includes('timestamp')) {
|
|
19
|
+
rootNumericKeys.push({ key: k, value: v });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// 3. Discover dates (YYYY-MM-DD format commonly used in booking/flights)
|
|
23
|
+
const dateKeys = [];
|
|
24
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
25
|
+
if (typeof v === 'string' &&
|
|
26
|
+
v.length >= 10 &&
|
|
27
|
+
/^\d{4}-\d{2}-\d{2}/.test(v)) {
|
|
28
|
+
const d = new Date(v);
|
|
29
|
+
if (!isNaN(d.getTime())) {
|
|
30
|
+
dateKeys.push({ key: k, date: d });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
// 4. Calculate parameter types
|
|
35
|
+
const paramTypes = { string: 0, number: 0, boolean: 0, object: 0 };
|
|
36
|
+
const strings = [];
|
|
37
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
38
|
+
const t = typeof v;
|
|
39
|
+
if (t === 'string') {
|
|
40
|
+
paramTypes.string++;
|
|
41
|
+
strings.push({ label: k, value: v.length });
|
|
42
|
+
}
|
|
43
|
+
else if (t === 'number') {
|
|
44
|
+
paramTypes.number++;
|
|
45
|
+
}
|
|
46
|
+
else if (t === 'boolean') {
|
|
47
|
+
paramTypes.boolean++;
|
|
48
|
+
}
|
|
49
|
+
else if (t === 'object' && v !== null) {
|
|
50
|
+
paramTypes.object++;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const typeData = [
|
|
54
|
+
{ label: 'Strings', value: paramTypes.string, color: AppColors.purple },
|
|
55
|
+
{ label: 'Numbers', value: paramTypes.number, color: AppColors.skyBlue },
|
|
56
|
+
{ label: 'Booleans', value: paramTypes.boolean, color: '#F59E0B' }, // Amber
|
|
57
|
+
{ label: 'Objects', value: paramTypes.object, color: AppColors.greenColor },
|
|
58
|
+
].filter(d => d.value > 0);
|
|
59
|
+
strings.sort((a, b) => b.value - a.value);
|
|
60
|
+
const topStrings = strings.slice(0, 5);
|
|
61
|
+
const hasItemsChart = filteredItems.length > 0;
|
|
62
|
+
const hasRootNumericChart = rootNumericKeys.length > 0;
|
|
63
|
+
const hasDatesChart = dateKeys.length > 0;
|
|
64
|
+
const hasStringsChart = topStrings.length > 0;
|
|
65
|
+
const hasTypeData = typeData.length > 0;
|
|
66
|
+
const screenWidth = Dimensions.get('window').width - 60; // Padding adjustments
|
|
67
|
+
const rightMargin = 40; // Space for labels at the end of the bar
|
|
68
|
+
const maxBarWidth = screenWidth - rightMargin;
|
|
69
|
+
return (<View style={graphStyles.container}>
|
|
70
|
+
<Text style={graphStyles.headerTitle}>Data Visualization</Text>
|
|
71
|
+
|
|
72
|
+
{hasTypeData && (<View style={graphStyles.chartBlock}>
|
|
73
|
+
<Text style={graphStyles.chartTitle}>Data Types Breakdown</Text>
|
|
74
|
+
<DonutChart data={typeData}/>
|
|
75
|
+
</View>)}
|
|
76
|
+
|
|
77
|
+
{hasStringsChart && (<View style={graphStyles.chartBlock}>
|
|
78
|
+
<Text style={graphStyles.chartTitle}>Highest Payload Strings</Text>
|
|
79
|
+
<BarChart data={topStrings} accentColor={AppColors.purple} maxBarWidth={maxBarWidth} isGradient/>
|
|
80
|
+
</View>)}
|
|
81
|
+
|
|
82
|
+
{hasRootNumericChart && (<View style={graphStyles.chartBlock}>
|
|
83
|
+
<Text style={graphStyles.chartTitle}>Top-Level Metrics</Text>
|
|
84
|
+
<GaugeChart data={rootNumericKeys.map(d => ({ label: d.key, value: d.value }))} accentColor={accentColor}/>
|
|
85
|
+
</View>)}
|
|
86
|
+
|
|
87
|
+
{hasDatesChart && (<View style={graphStyles.chartBlock}>
|
|
88
|
+
<Text style={graphStyles.chartTitle}>Important Dates</Text>
|
|
89
|
+
<CalendarChart data={dateKeys.map(d => ({ label: d.key, date: d.date }))} accentColor={accentColor}/>
|
|
90
|
+
</View>)}
|
|
91
|
+
|
|
92
|
+
{hasItemsChart && (<View style={graphStyles.chartBlock}>
|
|
93
|
+
<Text style={graphStyles.chartTitle}>Item Prices</Text>
|
|
94
|
+
<BarChart data={filteredItems.map((item, i) => ({
|
|
95
|
+
label: item.item_name || item.item_id || `Item ${i + 1}`,
|
|
96
|
+
value: item.price,
|
|
97
|
+
}))} accentColor={AppColors.successGreen || '#22C55E'} maxBarWidth={maxBarWidth} isGradient={false}/>
|
|
98
|
+
</View>)}
|
|
99
|
+
</View>);
|
|
100
|
+
};
|
|
101
|
+
// --- Donut Chart Helpers ---
|
|
102
|
+
const polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
|
|
103
|
+
const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
|
104
|
+
return {
|
|
105
|
+
x: centerX + radius * Math.cos(angleInRadians),
|
|
106
|
+
y: centerY + radius * Math.sin(angleInRadians),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const getPiePath = (x, y, radius, innerRadius, startAngle, endAngle) => {
|
|
110
|
+
const start = polarToCartesian(x, y, radius, endAngle);
|
|
111
|
+
const end = polarToCartesian(x, y, radius, startAngle);
|
|
112
|
+
const startInner = polarToCartesian(x, y, innerRadius, endAngle);
|
|
113
|
+
const endInner = polarToCartesian(x, y, innerRadius, startAngle);
|
|
114
|
+
const largeArcFlag = endAngle - startAngle <= 180 ? '0' : '1';
|
|
115
|
+
return `
|
|
116
|
+
M ${start.x} ${start.y}
|
|
117
|
+
A ${radius} ${radius} 0 ${largeArcFlag} 0 ${end.x} ${end.y}
|
|
118
|
+
L ${endInner.x} ${endInner.y}
|
|
119
|
+
A ${innerRadius} ${innerRadius} 0 ${largeArcFlag} 1 ${startInner.x} ${startInner.y}
|
|
120
|
+
Z
|
|
121
|
+
`;
|
|
122
|
+
};
|
|
123
|
+
const DonutChart = ({ data, }) => {
|
|
124
|
+
const total = data.reduce((sum, d) => sum + d.value, 0);
|
|
125
|
+
if (total === 0)
|
|
126
|
+
return null;
|
|
127
|
+
let currentAngle = 0;
|
|
128
|
+
const radius = 50;
|
|
129
|
+
const innerRadius = 30;
|
|
130
|
+
const center = 60;
|
|
131
|
+
return (<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
132
|
+
<Svg width="120" height="120" viewBox="0 0 120 120">
|
|
133
|
+
{data.map((d, i) => {
|
|
134
|
+
if (d.value === 0)
|
|
135
|
+
return null;
|
|
136
|
+
const angle = (d.value / total) * 360;
|
|
137
|
+
const startAngle = currentAngle;
|
|
138
|
+
const endAngle = currentAngle + angle;
|
|
139
|
+
currentAngle += angle;
|
|
140
|
+
if (angle === 360) {
|
|
141
|
+
return (<React.Fragment key={i}>
|
|
142
|
+
<Circle cx={center} cy={center} r={radius} fill={d.color}/>
|
|
143
|
+
<Circle cx={center} cy={center} r={innerRadius} fill={AppColors.primaryLight}/>
|
|
144
|
+
</React.Fragment>);
|
|
145
|
+
}
|
|
146
|
+
const path = getPiePath(center, center, radius, innerRadius, startAngle, endAngle);
|
|
147
|
+
return <Path key={i} d={path} fill={d.color}/>;
|
|
148
|
+
})}
|
|
149
|
+
</Svg>
|
|
150
|
+
<View style={{ marginLeft: 16, flex: 1, gap: 6 }}>
|
|
151
|
+
{data.map((d, i) => {
|
|
152
|
+
if (d.value === 0)
|
|
153
|
+
return null;
|
|
154
|
+
return (<View key={i} style={{ flexDirection: 'row', alignItems: 'center', gap: 6 }}>
|
|
155
|
+
<View style={{
|
|
156
|
+
width: 10,
|
|
157
|
+
height: 10,
|
|
158
|
+
borderRadius: 5,
|
|
159
|
+
backgroundColor: d.color,
|
|
160
|
+
}}/>
|
|
161
|
+
<Text style={{
|
|
162
|
+
fontFamily: AppFonts.interMedium,
|
|
163
|
+
fontSize: 11,
|
|
164
|
+
color: AppColors.grayTextStrong,
|
|
165
|
+
}}>
|
|
166
|
+
{d.label} ({d.value})
|
|
167
|
+
</Text>
|
|
168
|
+
</View>);
|
|
169
|
+
})}
|
|
170
|
+
</View>
|
|
171
|
+
</View>);
|
|
172
|
+
};
|
|
173
|
+
const GaugeChart = ({ data, accentColor, }) => {
|
|
174
|
+
const maxVal = Math.max(...data.map(d => Math.abs(d.value)), 1);
|
|
175
|
+
const radius = 26;
|
|
176
|
+
const stroke = 5;
|
|
177
|
+
const circumference = 2 * Math.PI * radius;
|
|
178
|
+
return (<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={{
|
|
179
|
+
gap: 16,
|
|
180
|
+
paddingRight: 16,
|
|
181
|
+
paddingTop: 6,
|
|
182
|
+
paddingBottom: 6,
|
|
183
|
+
}}>
|
|
184
|
+
{data.map((d, i) => {
|
|
185
|
+
const fillPct = Math.min(Math.abs(d.value) / maxVal, 1);
|
|
186
|
+
const strokeDashoffset = Math.max(circumference - fillPct * circumference, 0.001); // avoid exact 0
|
|
187
|
+
return (<View key={d.label} style={{ alignItems: 'center', width: 70 }}>
|
|
188
|
+
<Svg width="60" height="60" viewBox="0 0 60 60">
|
|
189
|
+
<Circle cx="30" cy="30" r={radius} stroke="#F3F4F6" strokeWidth={stroke} fill="none"/>
|
|
190
|
+
<Circle cx="30" cy="30" r={radius} stroke={accentColor} strokeWidth={stroke} fill="none" strokeLinecap="round" strokeDasharray={circumference} strokeDashoffset={strokeDashoffset} rotation="-90" origin="30, 30"/>
|
|
191
|
+
</Svg>
|
|
192
|
+
<View style={{
|
|
193
|
+
position: 'absolute',
|
|
194
|
+
top: 20,
|
|
195
|
+
height: 20,
|
|
196
|
+
width: 60,
|
|
197
|
+
justifyContent: 'center',
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
}}>
|
|
200
|
+
<Text style={{
|
|
201
|
+
fontFamily: AppFonts.interBold,
|
|
202
|
+
fontSize: 13,
|
|
203
|
+
color: AppColors.primaryBlack,
|
|
204
|
+
textAlign: 'center',
|
|
205
|
+
}}>
|
|
206
|
+
{d.value >= 1000 ? (d.value / 1000).toFixed(1) + 'k' : d.value}
|
|
207
|
+
</Text>
|
|
208
|
+
</View>
|
|
209
|
+
<Text style={{
|
|
210
|
+
fontFamily: AppFonts.interMedium,
|
|
211
|
+
fontSize: 10,
|
|
212
|
+
color: AppColors.grayTextWeak,
|
|
213
|
+
marginTop: 6,
|
|
214
|
+
textAlign: 'center',
|
|
215
|
+
}} numberOfLines={1}>
|
|
216
|
+
{d.label}
|
|
217
|
+
</Text>
|
|
218
|
+
</View>);
|
|
219
|
+
})}
|
|
220
|
+
</ScrollView>);
|
|
221
|
+
};
|
|
222
|
+
const CalendarChart = ({ data, accentColor, }) => {
|
|
223
|
+
const months = [
|
|
224
|
+
'Jan',
|
|
225
|
+
'Feb',
|
|
226
|
+
'Mar',
|
|
227
|
+
'Apr',
|
|
228
|
+
'May',
|
|
229
|
+
'Jun',
|
|
230
|
+
'Jul',
|
|
231
|
+
'Aug',
|
|
232
|
+
'Sep',
|
|
233
|
+
'Oct',
|
|
234
|
+
'Nov',
|
|
235
|
+
'Dec',
|
|
236
|
+
];
|
|
237
|
+
return (<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={{
|
|
238
|
+
gap: 16,
|
|
239
|
+
paddingRight: 16,
|
|
240
|
+
paddingTop: 6,
|
|
241
|
+
paddingBottom: 6,
|
|
242
|
+
}}>
|
|
243
|
+
{data.map((d, i) => {
|
|
244
|
+
const monthText = months[d.date.getMonth()];
|
|
245
|
+
const dayText = d.date.getDate();
|
|
246
|
+
const yearText = d.date.getFullYear();
|
|
247
|
+
return (<View key={d.label + i} style={{ width: 70, alignItems: 'center' }}>
|
|
248
|
+
<View style={{
|
|
249
|
+
width: 58,
|
|
250
|
+
height: 62,
|
|
251
|
+
backgroundColor: '#FFFFFF',
|
|
252
|
+
borderRadius: 8,
|
|
253
|
+
borderWidth: 1,
|
|
254
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
255
|
+
overflow: 'hidden',
|
|
256
|
+
shadowColor: '#000',
|
|
257
|
+
shadowOpacity: 0.05,
|
|
258
|
+
shadowRadius: 4,
|
|
259
|
+
shadowOffset: { width: 0, height: 2 },
|
|
260
|
+
elevation: 2,
|
|
261
|
+
}}>
|
|
262
|
+
{/* Calendar Header with Accent Color */}
|
|
263
|
+
<View style={{
|
|
264
|
+
backgroundColor: accentColor,
|
|
265
|
+
height: 18,
|
|
266
|
+
justifyContent: 'center',
|
|
267
|
+
alignItems: 'center',
|
|
268
|
+
}}>
|
|
269
|
+
<Text style={{
|
|
270
|
+
fontFamily: AppFonts.interBold,
|
|
271
|
+
fontSize: 9,
|
|
272
|
+
color: '#FFF',
|
|
273
|
+
textTransform: 'uppercase',
|
|
274
|
+
letterSpacing: 0.5,
|
|
275
|
+
}}>
|
|
276
|
+
{monthText} {yearText}
|
|
277
|
+
</Text>
|
|
278
|
+
</View>
|
|
279
|
+
{/* Calendar Body */}
|
|
280
|
+
<View style={{
|
|
281
|
+
flex: 1,
|
|
282
|
+
justifyContent: 'center',
|
|
283
|
+
alignItems: 'center',
|
|
284
|
+
backgroundColor: '#FAFAFA',
|
|
285
|
+
}}>
|
|
286
|
+
<Text style={{
|
|
287
|
+
fontFamily: AppFonts.interBold,
|
|
288
|
+
fontSize: 24,
|
|
289
|
+
color: AppColors.primaryBlack,
|
|
290
|
+
}}>
|
|
291
|
+
{dayText}
|
|
292
|
+
</Text>
|
|
293
|
+
</View>
|
|
294
|
+
</View>
|
|
295
|
+
|
|
296
|
+
<Text style={{
|
|
297
|
+
fontFamily: AppFonts.interMedium,
|
|
298
|
+
fontSize: 10,
|
|
299
|
+
color: AppColors.grayTextWeak,
|
|
300
|
+
marginTop: 8,
|
|
301
|
+
textAlign: 'center',
|
|
302
|
+
}} numberOfLines={2}>
|
|
303
|
+
{d.label.replace(/_/g, ' ')}
|
|
304
|
+
</Text>
|
|
305
|
+
</View>);
|
|
306
|
+
})}
|
|
307
|
+
</ScrollView>);
|
|
308
|
+
};
|
|
309
|
+
const BarChart = ({ data, accentColor, maxBarWidth, isGradient = false, }) => {
|
|
310
|
+
const maxVal = Math.max(...data.map(d => d.value), 1);
|
|
311
|
+
const chartHeight = data.length * (BAR_HEIGHT + PADDING_Y) + 10;
|
|
312
|
+
return (<View style={graphStyles.svgContainer}>
|
|
313
|
+
<Svg width="100%" height={chartHeight}>
|
|
314
|
+
<Defs>
|
|
315
|
+
<LinearGradient id="barGrad" x1="0" y1="0" x2="1" y2="0">
|
|
316
|
+
<Stop offset="0" stopColor={accentColor} stopOpacity="0.6"/>
|
|
317
|
+
<Stop offset="1" stopColor={accentColor} stopOpacity="1"/>
|
|
318
|
+
</LinearGradient>
|
|
319
|
+
</Defs>
|
|
320
|
+
{data.map((d, i) => {
|
|
321
|
+
const y = i * (BAR_HEIGHT + PADDING_Y);
|
|
322
|
+
const barWidth = Math.max((d.value / maxVal) * maxBarWidth, 2);
|
|
323
|
+
return (<React.Fragment key={d.label}>
|
|
324
|
+
{/* Label above bar */}
|
|
325
|
+
<SvgText x={0} y={y + 12} fill={AppColors.grayTextStrong} fontSize="11" fontFamily={AppFonts.interMedium}>
|
|
326
|
+
{d.label}
|
|
327
|
+
</SvgText>
|
|
328
|
+
|
|
329
|
+
{/* Background trace line */}
|
|
330
|
+
<Line x1={0} y1={y + 24} x2={maxBarWidth} y2={y + 24} stroke={AppColors.grayBorderSecondary} strokeDasharray="4"/>
|
|
331
|
+
|
|
332
|
+
{/* The actual Bar */}
|
|
333
|
+
<Rect x={0} y={y + 16} width={barWidth} height={14} fill={isGradient ? 'url(#barGrad)' : accentColor} rx={4} opacity={0.85}/>
|
|
334
|
+
|
|
335
|
+
{/* Value Text at the end of the bar */}
|
|
336
|
+
<SvgText x={barWidth + 6} y={y + 26} fill={AppColors.primaryBlack} fontSize="11" fontFamily={AppFonts.interBold}>
|
|
337
|
+
{d.value}
|
|
338
|
+
</SvgText>
|
|
339
|
+
</React.Fragment>);
|
|
340
|
+
})}
|
|
341
|
+
</Svg>
|
|
342
|
+
</View>);
|
|
343
|
+
};
|
|
344
|
+
const graphStyles = StyleSheet.create({
|
|
345
|
+
container: {
|
|
346
|
+
backgroundColor: AppColors.primaryLight,
|
|
347
|
+
borderWidth: 1,
|
|
348
|
+
borderColor: AppColors.grayBorderSecondary,
|
|
349
|
+
borderRadius: 12,
|
|
350
|
+
marginBottom: 10,
|
|
351
|
+
padding: 14,
|
|
352
|
+
overflow: 'hidden',
|
|
353
|
+
},
|
|
354
|
+
headerTitle: {
|
|
355
|
+
fontFamily: AppFonts.interBold,
|
|
356
|
+
color: AppColors.primaryBlack,
|
|
357
|
+
fontSize: 14,
|
|
358
|
+
marginBottom: 12,
|
|
359
|
+
borderBottomWidth: 1,
|
|
360
|
+
borderBottomColor: AppColors.dividerColor,
|
|
361
|
+
paddingBottom: 8,
|
|
362
|
+
},
|
|
363
|
+
chartBlock: {
|
|
364
|
+
marginBottom: 16,
|
|
365
|
+
},
|
|
366
|
+
chartTitle: {
|
|
367
|
+
fontFamily: AppFonts.interMedium,
|
|
368
|
+
color: AppColors.grayTextWeak,
|
|
369
|
+
fontSize: 12,
|
|
370
|
+
textTransform: 'uppercase',
|
|
371
|
+
letterSpacing: 0.5,
|
|
372
|
+
marginBottom: 8,
|
|
373
|
+
},
|
|
374
|
+
svgContainer: {
|
|
375
|
+
marginTop: 4,
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
export default AnalyticsGraph;
|