Skip to content

Issue #89: Backend — AnalyticsEvent Entity #242

@wumibals

Description

@wumibals

Labels: backend database analytics
Area: backend/src/modules/analytics/analytics-event.entity.ts
Difficulty: Intermediate

Description

Every tracked interaction (page view, menu item view, custom event) is persisted as an AnalyticsEvent row. The analytics service queries this table to produce time-series and aggregate data for the admin dashboard.

Acceptance Criteria

  • Create backend/src/modules/analytics/analytics-event.entity.ts
  • Decorate with @Entity("analytics_events")
  • EventType enum exported from same file: PAGE_VIEW = "page_view", MENU_VIEW = "menu_view", CONTACT_SUBMIT = "contact_submit", CART_ADD = "cart_add", ORDER_COMPLETE = "order_complete", QR_SCAN = "qr_scan"
  • Columns: id (UUID, primary, generated), eventType (enum EventType), page (varchar 255, nullable), itemId (UUID, nullable — references menu item), metadata (jsonb, nullable — arbitrary event data), restaurantId (UUID), sessionId (varchar 100, nullable), createdAt (CreateDateColumn)
  • Index on (restaurantId, eventType, createdAt) — the primary query pattern for analytics aggregation
  • Index on (restaurantId, itemId) for per-item analytics

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions