Skip to content

Snippet Analytics Service #104

Description

@SudiptaPaul-31

Description
Build a backend service to track snippet interactions (views, copies, shares) and store analytics data for future dashboard visualizations.

Metrics

  • Views → Count each time a snippet is opened
  • Copies → Count each time snippet content is copied
  • Shares → Count each time snippet is shared via link or export

Requirements

  • Store analytics data in database with fields: id, snippetId, userId, actionType, timestamp
  • Expose API endpoints for analytics retrieval
  • Support aggregation queries for dashboard (e.g., total views, copies, shares per snippet)
  • Ensure efficient querying with indexes on snippetId and actionType
  • Retry logic for failed logging attempts (queue-based or background worker)

Endpoints

  • POST /api/snippets/:id/analytics → Log a snippet action (view, copy, share)
  • GET /api/snippets/:id/analytics → Fetch aggregated analytics for a snippet
  • GET /api/analytics → Fetch global analytics (optional, for admin/dashboard use)

Tasks

  • Define database schema for analytics events
  • Implement logging logic for snippet actions
  • Build API endpoints for logging and fetching analytics
  • Add aggregation queries for dashboard metrics
  • Write unit tests for logging, retrieval, and aggregation logic
  • Document API usage for frontend integration

Acceptance Criteria

  • Snippet actions (view, copy, share) logged reliably in database
  • Aggregated analytics retrievable via API endpoints
  • Efficient queries supported with proper indexing
  • Retry logic ensures no data loss during failed logging attempts
  • Unit tests pass for all endpoints and logic
  • API documented for frontend/dashboard integration

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions