@withpotter/analytics — module reference
HTTP routes this module mounts, plus its internal use-cases, entities, and repositories. The exhaustive request/response contract is the engine’s OpenAPI document at /docs; the layered structure below follows the package internal architecture.
HTTP routes
Analytics /analytics
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /analytics/booking-stats | Yes | Get booking analytics for bookable businesses |
GET | /analytics/customer-stats | Yes | Get customer statistics |
GET | /analytics/dashboard | Yes | Get complete dashboard statistics |
GET | /analytics/devices | Yes | Get device breakdown |
GET | /analytics/events/:contentId | Yes | Get analytics for a specific event |
GET | /analytics/funnel | Yes | Get conversion funnel statistics |
GET | /analytics/inventory-stats | Yes | Get inventory health statistics |
GET | /analytics/order-stats | Yes | Get order statistics from orders table |
GET | /analytics/overview | Yes | Get overview statistics |
GET | /analytics/page-views | Yes | Get page views time series |
GET | /analytics/recent-events | Yes | Get recent activity events |
GET | /analytics/revenue | Yes | Get revenue time series |
GET | /analytics/sales | Yes | Get sales statistics |
GET | /analytics/sessions | Yes | Get sessions time series |
GET | /analytics/top-content | Yes | Get top performing content |
GET | /analytics/top-pages | Yes | Get top pages by views |
GET | /analytics/traffic-sources | Yes | Get traffic sources breakdown |
GET | /analytics/visitors | Yes | Get visitors time series |
POST | /analytics/track | — | Track an analytics event |
Internals
Use-cases
Application operations. Each is a single-purpose class with one execute() method.
| Use-case | Signature |
|---|---|
GetCrossModuleStatsUseCase | execute(...) |
GetDashboardStatsUseCase | execute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<DashboardStatsDto> |
GetDeviceStatsUseCase | execute(tenantId: string, startDate: Date, endDate: Date): Promise<DeviceStatsDto[]> |
GetEventAnalyticsUseCase | execute(tenantId: string, contentId: string): Promise<EventAnalyticsDto> |
GetFunnelStatsUseCase | execute(tenantId: string, startDate: Date, endDate: Date): Promise<FunnelStatsDto> |
GetOverviewStatsUseCase | execute(tenantId: string, startDate: Date, endDate: Date): Promise<OverviewStatsDto> |
GetPageViewsTimeSeriesUseCase | execute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]> |
GetRecentEventsUseCase | execute(tenantId: string, limit = 20): Promise<RecentEventDto[]> |
GetRevenueTimeSeriesUseCase | execute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]> |
GetSalesStatsUseCase | execute(tenantId: string, startDate: Date, endDate: Date): Promise<SalesStatsDto> |
GetSessionsTimeSeriesUseCase | execute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]> |
GetTopContentUseCase | execute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<TopContentDto[]> |
GetTopPagesUseCase | execute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<TopPageDto[]> |
GetTrafficSourcesUseCase | execute(tenantId: string, startDate: Date, endDate: Date): Promise<TrafficSourceDto[]> |
GetVisitorsTimeSeriesUseCase | execute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]> |
TrackEventUseCase | execute(tenantId: string, dto: TrackEventDto, ipAddress?: string, userAgent?: string): Promise<void> |
Entities
Sequelize models owned by this module.
AnalyticsEvent — table analytics_events
| Field | Type |
|---|---|
id | string |
tenantId | string |
tenant | Tenant |
eventType | EventType |
eventName | string | null |
sessionId | string |
visitorId | string | null |
memberId | string | null |
pageUrl | string | null |
pageTitle | string | null |
contentId | string | null |
referrerUrl | string | null |
utmSource | string | null |
utmMedium | string | null |
utmCampaign | string | null |
deviceType | DeviceType | null |
userAgent | string | null |
ipAddress | string | null |
countryCode | string | null |
city | string | null |
orderId | string | null |
revenue | number | null |
quantity | number | null |
metadata | Record<string, any> |
createdAt | Date |
Repositories
Data-access classes wrapping the entities.
AnalyticsRepository
trackEvent · trackEvents · getOverviewStats · getSalesStats · getTopContent · getTrafficSources · getDeviceStats · getPageViewsTimeSeries · getRevenueTimeSeries · getFunnelStats · getTopPages · getVisitorsTimeSeries · getSessionsTimeSeries · getRecentEvents · deleteOldEvents · getPageDwellTime · getClientErrors · getBounceRateTimeSeries
Generated from the module’s source. Routes are relative to the engine root
(default http://localhost:3001). For full request/response schemas use the live
OpenAPI document.