Fix: Campaign Builder inactivity filter uses wrong date field (FA-19)#4
Open
konard wants to merge 3 commits intoalanef:masterfrom
Open
Fix: Campaign Builder inactivity filter uses wrong date field (FA-19)#4konard wants to merge 3 commits intoalanef:masterfrom
konard wants to merge 3 commits intoalanef:masterfrom
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: alanef#2
The Campaign Segment Builder's inactivity filter was incorrectly using subscriber_drips.updated_at which tracks drip stage changes, not actual email sends. Changes: - Add email_sends table to SQLite schema for tracking all email sends - Add recordEmailSend() and related methods to SequenceDatabase - Add /api/webhook/messenger endpoint for Listmonk campaign tracking - Update DripProcessor to log drip sends to email_sends table - Update DunningProcessor to log dunning sends to email_sends table - Update buildQuery() in home.php to use email_sends for inactivity filter The inactivity filter now correctly identifies subscribers who haven't received ANY email (drip, dunning, or campaign) in the specified period. Fixes alanef#2 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit dab9d66.
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Campaign Segment Builder's "No activity in last X days" filter which was incorrectly returning the same subscribers regardless of the number of days specified.
Root cause: The filter was using
subscriber_drips.updated_atwhich tracks when the drip record was last modified (stage changes, etc.), NOT when the subscriber was last emailed.Solution
Track email sends in SQLite to enable accurate inactivity filtering:
1. New
email_sendsTableAdded SQLite table to track all email sends:
subscriber_id- SQLite subscriber IDemail_type- Type: 'drip', 'dunning', or 'campaign'product_id- For drip emailscampaign_id- For campaign emailstemplate_id- Listmonk template IDsent_at- Timestamp of send2. Track Drip/Dunning Sends
Updated
DripProcessorandDunningProcessorto log sends to the new table after each successful email send.3. Track Campaign Sends (via Listmonk Messenger)
Added
/api/webhook/messengerendpoint that receives campaign send notifications from Listmonk's messenger system. This allows tracking of all campaign emails sent via this custom messenger.Setup: Configure a new messenger in Listmonk pointing to
https://your-domain/api/webhook/messenger4. Updated Inactivity Query
Changed the filter in
home.phpto query the newemail_sendstable:NOT EXISTS ( SELECT 1 FROM email_sends e WHERE e.subscriber_id = s.id AND e.sent_at >= datetime('now', '-X days') )Files Changed
shared/src/SequenceDatabase.php- Added email_sends table and methodscampaign-list-builder/public/index.php- Added messenger webhook endpointcampaign-list-builder/templates/home.php- Updated inactivity filter SQLdrip-controller/src/DripProcessor.php- Log drip sendsdrip-controller/src/DunningProcessor.php- Log dunning sendsTest Plan
Note on Migration
For existing subscribers who have received emails before this change, the email_sends table will be empty. The inactivity filter will correctly identify them as inactive (no email send records). You may want to backfill data if historical accuracy is important.
Fixes #2
🤖 Generated with Claude Code