@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

MethodPathAuthDescription
GET/analytics/booking-statsYesGet booking analytics for bookable businesses
GET/analytics/customer-statsYesGet customer statistics
GET/analytics/dashboardYesGet complete dashboard statistics
GET/analytics/devicesYesGet device breakdown
GET/analytics/events/:contentIdYesGet analytics for a specific event
GET/analytics/funnelYesGet conversion funnel statistics
GET/analytics/inventory-statsYesGet inventory health statistics
GET/analytics/order-statsYesGet order statistics from orders table
GET/analytics/overviewYesGet overview statistics
GET/analytics/page-viewsYesGet page views time series
GET/analytics/recent-eventsYesGet recent activity events
GET/analytics/revenueYesGet revenue time series
GET/analytics/salesYesGet sales statistics
GET/analytics/sessionsYesGet sessions time series
GET/analytics/top-contentYesGet top performing content
GET/analytics/top-pagesYesGet top pages by views
GET/analytics/traffic-sourcesYesGet traffic sources breakdown
GET/analytics/visitorsYesGet visitors time series
POST/analytics/trackTrack an analytics event

Internals

Use-cases

Application operations. Each is a single-purpose class with one execute() method.

Use-caseSignature
GetCrossModuleStatsUseCaseexecute(...)
GetDashboardStatsUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<DashboardStatsDto>
GetDeviceStatsUseCaseexecute(tenantId: string, startDate: Date, endDate: Date): Promise<DeviceStatsDto[]>
GetEventAnalyticsUseCaseexecute(tenantId: string, contentId: string): Promise<EventAnalyticsDto>
GetFunnelStatsUseCaseexecute(tenantId: string, startDate: Date, endDate: Date): Promise<FunnelStatsDto>
GetOverviewStatsUseCaseexecute(tenantId: string, startDate: Date, endDate: Date): Promise<OverviewStatsDto>
GetPageViewsTimeSeriesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]>
GetRecentEventsUseCaseexecute(tenantId: string, limit = 20): Promise<RecentEventDto[]>
GetRevenueTimeSeriesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]>
GetSalesStatsUseCaseexecute(tenantId: string, startDate: Date, endDate: Date): Promise<SalesStatsDto>
GetSessionsTimeSeriesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]>
GetTopContentUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<TopContentDto[]>
GetTopPagesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, limit = 10): Promise<TopPageDto[]>
GetTrafficSourcesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date): Promise<TrafficSourceDto[]>
GetVisitorsTimeSeriesUseCaseexecute(tenantId: string, startDate: Date, endDate: Date, granularity: 'day' | 'week' | 'month' = 'day'): Promise<TimeSeriesPointDto[]>
TrackEventUseCaseexecute(tenantId: string, dto: TrackEventDto, ipAddress?: string, userAgent?: string): Promise<void>

Entities

Sequelize models owned by this module.

AnalyticsEvent — table analytics_events

FieldType
idstring
tenantIdstring
tenantTenant
eventTypeEventType
eventNamestring | null
sessionIdstring
visitorIdstring | null
memberIdstring | null
pageUrlstring | null
pageTitlestring | null
contentIdstring | null
referrerUrlstring | null
utmSourcestring | null
utmMediumstring | null
utmCampaignstring | null
deviceTypeDeviceType | null
userAgentstring | null
ipAddressstring | null
countryCodestring | null
citystring | null
orderIdstring | null
revenuenumber | null
quantitynumber | null
metadataRecord<string, any>
createdAtDate

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.