From bdae5c164cc91391fff18218e7f2469171072454 Mon Sep 17 00:00:00 2001 From: William Tso Date: Tue, 1 Apr 2025 23:04:15 +0800 Subject: [PATCH] move events pos --- app/(app)/dashboard/page.tsx | 238 ++++++++++++++++++------------- app/(app)/geo-analytics/page.tsx | 1 + types/react-simple-maps.d.ts | 1 + 3 files changed, 138 insertions(+), 102 deletions(-) create mode 100644 app/(app)/geo-analytics/page.tsx create mode 100644 types/react-simple-maps.d.ts diff --git a/app/(app)/dashboard/page.tsx b/app/(app)/dashboard/page.tsx index c97c2de..e58b2be 100644 --- a/app/(app)/dashboard/page.tsx +++ b/app/(app)/dashboard/page.tsx @@ -35,6 +35,7 @@ interface Event { project_name?: string; link_id?: string; link_slug?: string; + link_tags?: string; } // 格式化日期函数 @@ -77,6 +78,19 @@ const extractEventInfo = (event: Event) => { // 解析用户属性 const userAttrs = parseJsonSafely(event.user_attributes || '{}'); + // 解析标签信息 + let tags: string[] = []; + try { + if (event.link_tags) { + const parsedTags = JSON.parse(event.link_tags); + if (Array.isArray(parsedTags)) { + tags = parsedTags; + } + } + } catch { + // 解析失败则保持空数组 + } + return { eventTime: event.created_at || event.event_time, linkName: event.link_label || linkAttrs?.name || eventAttrs?.link_name || event.link_slug || '-', @@ -90,7 +104,8 @@ const extractEventInfo = (event: Event) => { os: event.os || '-', userInfo: getUserDisplayName(userAttrs), teamName: event.team_name || '-', - projectName: event.project_name || '-' + projectName: event.project_name || '-', + tags: tags }; }; @@ -330,7 +345,126 @@ export default function DashboardPage() { )} - {/* 仪表板内容 */} + {/* 事件列表部分 - 现在放在最上面 */} +
+
+

Recent Events

+
+ +
+ + + + + + + + + + + + + + + {events.map((event, index) => { + const info = extractEventInfo(event); + return ( + + + + + + + + + + + ); + })} + +
+ Time + + Link Name + + Original URL + + Event Type + + Tags + + User + + Team/Project + + Device Info +
+ {formatDate(info.eventTime)} + + {info.linkName} +
+ ID: {event.link_id?.substring(0, 8) || '-'} +
+
+ + {info.originalUrl} + + + + {info.eventType} + + +
+ {info.tags && info.tags.length > 0 ? ( + info.tags.map((tag, idx) => ( + + {tag} + + )) + ) : ( + - + )} +
+
+
{info.userInfo}
+
{info.visitorId}...
+
+
{info.teamName}
+
{info.projectName}
+
+
+ + Device: + {info.device} + + + Browser: + {info.browser} + + + OS: + {info.os} + +
+
+
+ + {/* 表格为空状态 */} + {!loading && events.length === 0 && ( +
+ No events found +
+ )} +
+ + {/* 仪表板内容 - 现在放在事件列表之后 */} <> {summary && (
@@ -377,106 +511,6 @@ export default function DashboardPage() {

Geographic Distribution

- - {/* 事件列表部分 */} -
-
-

Recent Events

-
- -
- - - - - - - - - - - - - - {events.map((event, index) => { - const info = extractEventInfo(event); - return ( - - - - - - - - - - ); - })} - -
- Time - - Link Name - - Original URL - - Event Type - - User - - Team/Project - - Device Info -
- {formatDate(info.eventTime)} - - {info.linkName} -
- ID: {event.link_id?.substring(0, 8) || '-'} -
-
- - {info.originalUrl} - - - - {info.eventType} - - -
{info.userInfo}
-
{info.visitorId}...
-
-
{info.teamName}
-
{info.projectName}
-
-
- - Device: - {info.device} - - - Browser: - {info.browser} - - - OS: - {info.os} - -
-
-
- - {/* 表格为空状态 */} - {!loading && events.length === 0 && ( -
- No events found -
- )} -
); diff --git a/app/(app)/geo-analytics/page.tsx b/app/(app)/geo-analytics/page.tsx new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/app/(app)/geo-analytics/page.tsx @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/types/react-simple-maps.d.ts b/types/react-simple-maps.d.ts new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/types/react-simple-maps.d.ts @@ -0,0 +1 @@ + \ No newline at end of file