const express = require('express'); const router = express.Router(); const { checkPluginPermission } = require('../../../src/middleware/pluginAuth'); const logger = require('../../../src/utils/logger'); // Get analytics data for the current site router.get('/', checkPluginPermission('view_analytics'), async (req, res) => { try { const { siteId } = req.user; // In a real implementation, you'd query the plugin's database schema const analytics = { total_messages: 150, sent_messages: 145, failed_messages: 5, total_notifications: 75, read_notifications: 60, templates_created: 12, active_templates: 8, monthly_stats: { messages_sent: 45, notifications_sent: 25, new_templates: 2 } }; res.json({ success: true, data: analytics, message: 'Analytics retrieved successfully' }); } catch (error) { logger.error('Failed to get analytics:', error); res.status(500).json({ success: false, error: 'Failed to retrieve analytics', message: error.message }); } }); module.exports = router;