Session log — Activity monitoring: on-site dashboard and daily digest
← All session logs
Session log — Activity monitoring: on-site dashboard and daily digest
Summary
Started by checking whether the sign-in and sign-up emails sent by the S2L Magic Login plugin are still being delivered. They are, but Hasmukh was not seeing anything because the existing per-minute "signin-alerts" script still watches the old EP Membership log table and the magic login plugin writes to a different table. Hasmukh then asked for a way to monitor activity on the site, so we built two things: a private on-site activity dashboard and a daily digest email.
Decisions
- Build both: an on-site /activity page (live view, behind sign-in) and a daily digest email at 06:00 SAST.
- Authorise the on-site page by allowlist (hasmukh@gajjar.co.za and hasmukh@mobilearn.africa). A plugin setting takes extra emails for future expansion.
- Send the digest from notifications@vodalibrary.online via SendGrid, matching the pattern of the existing signin-alerts.py script. Recipients: hasmukh@gajjar.co.za and hello@mobilearn.africa.
- Use a 24 hour window for the digest. Quiet days still get an email so silence cannot be mistaken for a broken script.
Changes made
- New plugin S2L_Activity_Monitor at /var/www/s2l/user-content/plugins/s2l-activity-monitor/plugin.php, activated in the pm_options "plugins" list.
- New page added to pm_content: slug "activity", title "Site activity", content "[s2l-activity]", live at https://s2l.online/activity/.
- New script /var/www/s2l/user-content/scripts/daily-activity-digest.py (owned by root, executable).
- New cron entry in root crontab: 0 4 * * * (06:00 SAST) runs the digest, logging to /var/www/s2l/user-content/scripts/.state/digest.log.
- Verified end to end: dry run shows 19 events from the last 24h with proper course and lesson titles. Two live digests sent successfully (SendGrid status 202).
Activity types tracked
Sign-ups, sign-ins (magic), comments, newsletter subscriptions, course purchases, bookings, course enrolments, lesson completions, quiz attempts, contact form submissions.
Follow-ups
- Fix or replace the existing signin-alerts.py so real-time login alerts also work for the new magic login table (currently silent since the switchover). Hasmukh to decide whether he wants instant alerts in addition to the daily digest.
- Optional: patch the magic login plugin so a "signin_email_sent" entry is also logged for brand-new signups (currently only "account_created" is logged, even though the welcome email is sent).
- Possible additions to the digest later: page views (if a tracker is added), failed sign-in attempts, GDPR consent grants, support tickets.
- Add a "Today" view bookmark for Hasmukh: https://s2l.online/activity/?days=1.