Metrics & Monitoring Dashboard
Relevant source files
The following files were used as context for generating this wiki page:
The Metrics & Monitoring Dashboard is a centralized system within MarketSage designed to provide real-time observability, security analysis, and performance tracking across marketplace activities. It aggregates data from various specialized services—including security analyzers, price monitors, and social commerce trackers—to provide a comprehensive view of system health and market trends. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:1-10, src/core/analytics/analyticsService.ts:1-10
Architecture and Data Collection
The monitoring architecture relies on a singleton-pattern service that orchestrates data collection from distributed components. The MarketplaceMonitoringDashboard class utilizes RxJS observables to provide real-time streams of metrics, alerts, and system events to the frontend components. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:133-145, src/core/analytics/analyticsService.ts:35-45
Core Components
- Real-time Monitoring Engine: Manages periodic collection of metrics every 30 seconds and checks against predefined thresholds. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:140-155
- Analytics Service: Tracks user behavior, session data, and feature usage (Protect, Insight, Scout). Sources: src/core/analytics/analyticsService.ts:88-105
- Security Analyzer: Provides risk assessment data, seller trust scores, and threat detection. Sources: src/background/services/protect/securityAnalyzer.ts:30-50
- Social Commerce Analytics: Measures community engagement, influence scores, and viral content trends. Sources: src/core/social/SocialCommerceAnalytics.ts:246-265
Monitoring Flow
The following diagram illustrates the flow of data from background services to the monitoring dashboard.
This diagram shows how various specialized analyzers feed data into the central Monitoring Dashboard and Analytics Service, which then stream data to the UI. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:133-160, src/popup/components/protect/EnhancedProtectSection.tsx:75-90
Metrics Categorization
The system tracks five primary categories of metrics to ensure comprehensive coverage of the marketplace environment. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:14-60
| Category | Key Metrics | Data Source |
|---|---|---|
| Overview | Total products, total sellers, active users, system health | Storage Utility |
| Security | Threats detected, risk distribution, security score | SecurityAnalyzer |
| Pricing | Avg price change, volatility, suspicious pricing | PriceAnalytics |
| Performance | Response time, throughput, error rate, uptime | System Internals |
| Trends | Popular categories, search trends, market share | SocialCommerceAnalytics |
Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:193-270, src/core/social/SocialCommerceAnalytics.ts:25-50
Security Monitoring and Alerting
Security monitoring is a critical pillar of the dashboard. It calculates an overall risk score by weighting seller history, price anomalies, and listing quality. Sources: src/background/services/protect/securityAnalyzer.ts:12-25
Risk Calculation Logic
The SecurityAnalyzer uses specific weights to determine the risk score of a listing:
- Seller History: 40%
- Price Anomaly: 30%
- Listing Quality: 30%
- Text Scam Keywords: Weighted within listing quality.
Sources: src/background/services/protect/securityAnalyzer.ts:13-18
Alert Thresholds
The dashboard triggers automated alerts when metrics exceed specific safety boundaries:
| Metric | Threshold | Severity |
|---|---|---|
| Response Time | > 3000ms | Performance Warning |
| Error Rate | > 5% | Performance Warning |
| Security Score | < 70 | Security High |
| Threat Count | > 10 | Security High |
Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:141-146
Alert Generation Sequence
This sequence shows the polling mechanism that triggers alert generation when thresholds are breached. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:153-165, src/core/monitoring/MarketplaceMonitoringDashboard.ts:316-335
Analytics and User Behavior
The AnalyticsService tracks user journeys and engagement to provide business intelligence. It maintains a UserBehavior session object that logs interaction counts and page views. Sources: src/core/analytics/analyticsService.ts:15-30
Key Analytics Functions
trackEvent: Enriches raw events with timestamps and session IDs before queuing them for storage. Sources: src/core/analytics/analyticsService.ts:65-85analyzeRiskPreferences: Evaluates whether a user "proceeds" or "aborts" after receiving security warnings to determine their risk tolerance. Sources: src/core/analytics/analyticsService.ts:192-212calculateEngagementScore: A formulaic approach:(interactionEvents / sessions) * 10, capped at 100. Sources: src/core/analytics/analyticsService.ts:176-190
Technical Implementation Details
Data Structures
DashboardMetrics Interface
export interface DashboardMetrics {
overview: OverviewMetrics;
security: SecurityMetrics;
pricing: PricingMetrics;
performance: PerformanceMetrics;
trends: TrendMetrics;
alerts: AlertMetrics;
}
Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:14-21
Monitoring Event
Events represent discrete system occurrences (e.g., Javascript errors or Extension messages) that are separate from aggregated metrics.
type: stringsource: stringseverity: 'info' | 'warning' | 'error' | 'critical'timestamp: number
Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:118-124
Management Methods
The dashboard provides a CRUD interface for managing custom widgets and alerts.
createWidget(config): Generates a unique ID and persists a new dashboard widget to storage. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:196-208updateAlertStatus(alertId, status): Transitions an alert (e.g., from 'open' to 'resolved') and logs resolution steps. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:241-262
Summary
The Metrics & Monitoring Dashboard serves as the intelligence hub for MarketSage, bridging the gap between low-level data collection and high-level user insights. By combining real-time performance monitoring with AI-driven security analysis and social commerce metrics, it ensures both system stability and user safety. The use of RxJS observables allows the dashboard to remain responsive and provide immediate feedback when market conditions or security risks change. Sources: src/core/monitoring/MarketplaceMonitoringDashboard.ts:1-20, src/core/analytics/analyticsService.ts:1-5