Skip to content

feat: Analytics Phase 5 — Export & Reporting (CSV + JSON) - #30

Open
ChitkulLakshya wants to merge 5 commits into
mainfrom
feature/analytics-phase5
Open

feat: Analytics Phase 5 — Export & Reporting (CSV + JSON)#30
ChitkulLakshya wants to merge 5 commits into
mainfrom
feature/analytics-phase5

Conversation

@ChitkulLakshya

Copy link
Copy Markdown
Collaborator

Analytics Phase 5 — Export & Reporting

Adds CSV and JSON export capabilities to the analytics feature.

Changes

Backend:

  • server/utils/exportUtils.js (new) — 5 export functions + 2 CSV helpers
  • server/index.js — 5 new export API endpoints with Content-Disposition headers

Frontend:

  • src/pages/AnalyticsPage.jsx — CSV/JSON export buttons in header
  • src/pages/TemplateDetailAnalytics.jsx — CSV/JSON export buttons in detail header
  • src/pages/AnalyticsPage.css — Export button styles

Docs:

  • docs/analytics/phase5-export-and-reporting.md — Full documentation

Export Endpoints

Endpoint Format Scope
GET /api/analytics/export/overview.csv CSV All templates overview
GET /api/analytics/export/overview.json JSON All templates overview
GET /api/analytics/templates/:draftId/export.csv CSV Per-template detail
GET /api/analytics/templates/:draftId/export.json JSON Per-template detail
GET /api/analytics/templates/:draftId/submissions/export.csv CSV Submissions only

Build

  • Vite build: PASS (2.14s)
  • No new dependencies
  • All endpoints behind verifyToken, scoped to user

- exportOverviewCSV: multi-section CSV with KPIs, templates, trends, type distribution
- exportOverviewJSON: structured JSON with all overview data
- exportTemplateDetailCSV: per-template CSV with info, field stats, raw submissions
- exportTemplateDetailJSON: structured JSON for template detail
- exportAllSubmissionsCSV: flat CSV of all submissions for a template
- arrayToCSV + escapeCSV: helpers for proper CSV formatting (quotes, commas, newlines)
- All functions scoped by ownerUid for user isolation
- GET /api/analytics/export/overview.csv — full overview as multi-section CSV
- GET /api/analytics/export/overview.json — structured JSON overview
- GET /api/analytics/templates/:draftId/export.csv — template detail with field stats + submissions
- GET /api/analytics/templates/:draftId/export.json — structured JSON template detail
- GET /api/analytics/templates/:draftId/submissions/export.csv — flat submissions CSV
- All endpoints behind verifyToken, scoped to req.user.uid
- Proper Content-Disposition headers for file download
…lateDetailAnalytics

AnalyticsPage.jsx:
- Added Download icon import
- handleExport function: fetches blob, creates download link, triggers file download
- CSV and JSON export buttons in header next to Sync Data button
- Exporting state with spinner during download

TemplateDetailAnalytics.jsx:
- Added Download icon import
- handleExport function: same blob download pattern for per-template export
- CSV and JSON export buttons in detail header
- Exporting state with spinner
- .analytics-export-group: flex container for CSV/JSON buttons
- .analytics-export-btn: outlined button with blue hover state
- .analytics-detail-header: flex space-between for title + export buttons
Copilot AI lite review requested due to automatic review settings August 14, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@netlify

netlify Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy Preview for leddger-ai ready!

Name Link
🔨 Latest commit a0b2914
🔍 Latest deploy log https://app.netlify.com/projects/leddger-ai/deploys/6a7f5aaf79bd2d00080a827e
😎 Deploy Preview https://deploy-preview-30--leddger-ai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants