feat: Analytics & Metrics tracking and dashboard (#31) - #32
Merged
Conversation
Implements issue Chulilee#31 — Analytics & Metrics module. New files: - src/types/analytics.ts — AnalyticsEvent, AnalyticsMetrics types - src/services/analyticsService.ts — event buffer, trackEvent, opt-out, aggregation - src/hooks/useAnalytics.ts — React hook (track, optedOut, metrics, refresh) - src/app/api/v1/analytics/events/route.ts — POST collector + GET list endpoint - src/app/analytics/page.tsx — /analytics dashboard route - src/components/MetricCard.tsx — KPI card component - src/components/ActivityChart.tsx — SVG bar chart (no extra deps) - src/components/AnalyticsDashboard.tsx — full dashboard with time-range filter - src/components/AnalyticsOptOut.tsx — privacy toggle (localStorage) - src/components/ListingViewTracker.tsx — silent client tracker for asset pages - src/__tests__/analytics.test.ts — API route tests - src/__tests__/analyticsService.test.ts — client service unit tests Modified: - src/types/index.ts — re-exports analytics types - src/components/Navbar.tsx — adds Analytics nav link - src/components/TradePanel.tsx — instruments trade_complete events - src/app/assets/[id]/page.tsx — instruments listing_view events Acceptance criteria met: - Key events instrumented: listing_view, listing_create, trade_complete, match_propose, wallet_connect, wallet_disconnect, page_view - Dashboard shows metric cards + bar charts with 7/14/30-day time-range filter - Opt-out toggle respects user preference via localStorage; tracked events are silently dropped when opted out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #31 — implements the Analytics & Metrics module.
What's included
New files
src/types/analytics.tsAnalyticsEvent,AnalyticsMetrics,DailyActivityPointtypessrc/services/analyticsService.tstrackEvent(), opt-out helpers, metrics aggregationsrc/hooks/useAnalytics.tstrack,optedOut,metrics,refreshMetricssrc/app/api/v1/analytics/events/route.tssrc/app/analytics/page.tsx/analyticsdashboard pagesrc/components/MetricCard.tsxsrc/components/ActivityChart.tsxsrc/components/AnalyticsDashboard.tsxsrc/components/AnalyticsOptOut.tsxsrc/components/ListingViewTracker.tsxsrc/__tests__/analytics.test.tssrc/__tests__/analyticsService.test.tsModified files
src/types/index.ts— re-exports analytics typessrc/components/Navbar.tsx— adds Analytics linksrc/components/TradePanel.tsx— instrumentstrade_completeeventssrc/app/assets/[id]/page.tsx— instrumentslisting_vieweventsAcceptance criteria
listing_view,listing_create,trade_complete,match_propose,wallet_connect,wallet_disconnect,page_viewTesting