bug: AnalyticsController AJAX endpoints query unpopulated analytics table #246

Open
opened 2026-06-29 14:27:31 +00:00 by jmiller · 1 comment
Owner

Problem

The analytics feature has two separate data sources that are out of sync:

  1. AnalyticsModel (used by the page-rendered Analytics view) queries #__mokosuitecross_posts directly -- this works correctly because posts data always exists.

  2. AnalyticsController AJAX endpoints (heatmap(), besttimes()) use AnalyticsHelper which queries #__mokosuitecross_analytics -- but nothing ever populates this table.

AnalyticsHelper::recordEngagement() exists and is designed to write engagement metrics (impressions, clicks, shares, engagement_rate) to the analytics table, but it is never called anywhere in the codebase.

Impact

  • The AJAX heatmap/besttimes endpoints always return empty data
  • The #__mokosuitecross_analytics table exists with columns for impressions, engagements, clicks, shares, and engagement_rate but is never populated
  • The page-rendered analytics view works correctly (uses AnalyticsModel querying posts table), so the feature appears to work on initial page load but AJAX filtering returns nothing

Files

  • src/Controller/AnalyticsController.php -- AJAX endpoints using AnalyticsHelper
  • src/Helper/AnalyticsHelper.php -- queries analytics table, has unused recordEngagement()
  • src/Model/AnalyticsModel.php -- queries posts table (correct, working)
  • src/View/Analytics/HtmlView.php -- uses AnalyticsModel (correct)
  • sql/install.mysql.sql -- defines #__mokosuitecross_analytics table

Options

  1. Remove the analytics table and rewrite AnalyticsController to use AnalyticsModel (simpler, no engagement metrics)
  2. Wire up recordEngagement() in QueueProcessor after successful posts, and optionally add a scheduled task to pull engagement metrics from platform APIs (more complete but much more work)
  3. Unify on AnalyticsModel for the AJAX endpoints and keep AnalyticsHelper/table for future engagement tracking
## Problem The analytics feature has two separate data sources that are out of sync: 1. **AnalyticsModel** (used by the page-rendered Analytics view) queries `#__mokosuitecross_posts` directly -- this works correctly because posts data always exists. 2. **AnalyticsController** AJAX endpoints (`heatmap()`, `besttimes()`) use `AnalyticsHelper` which queries `#__mokosuitecross_analytics` -- but **nothing ever populates this table**. `AnalyticsHelper::recordEngagement()` exists and is designed to write engagement metrics (impressions, clicks, shares, engagement_rate) to the analytics table, but it is never called anywhere in the codebase. ## Impact - The AJAX heatmap/besttimes endpoints always return empty data - The `#__mokosuitecross_analytics` table exists with columns for impressions, engagements, clicks, shares, and engagement_rate but is never populated - The page-rendered analytics view works correctly (uses AnalyticsModel querying posts table), so the feature appears to work on initial page load but AJAX filtering returns nothing ## Files - `src/Controller/AnalyticsController.php` -- AJAX endpoints using AnalyticsHelper - `src/Helper/AnalyticsHelper.php` -- queries analytics table, has unused `recordEngagement()` - `src/Model/AnalyticsModel.php` -- queries posts table (correct, working) - `src/View/Analytics/HtmlView.php` -- uses AnalyticsModel (correct) - `sql/install.mysql.sql` -- defines `#__mokosuitecross_analytics` table ## Options 1. **Remove the analytics table** and rewrite AnalyticsController to use AnalyticsModel (simpler, no engagement metrics) 2. **Wire up recordEngagement()** in QueueProcessor after successful posts, and optionally add a scheduled task to pull engagement metrics from platform APIs (more complete but much more work) 3. **Unify on AnalyticsModel** for the AJAX endpoints and keep AnalyticsHelper/table for future engagement tracking
Author
Owner

Branch created: feature/246-bug-analyticscontroller-ajax-endpoints-q

git fetch origin
git checkout feature/246-bug-analyticscontroller-ajax-endpoints-q
Branch created: [`feature/246-bug-analyticscontroller-ajax-endpoints-q`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteCross/src/branch/feature/246-bug-analyticscontroller-ajax-endpoints-q) ```bash git fetch origin git checkout feature/246-bug-analyticscontroller-ajax-endpoints-q ```
Sign in to join this conversation.
No labels
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteCross#246