This document describes the automated notification system for election date changes that affect POWERBACK users.
When election dates change in a state, the system automatically identifies and notifies users who may be affected by these changes. The notification system serves two types of users:
- Users with Active Celebrations - Users who have made donations to politicians in the affected state
- Users with Residential Address - Users who have provided a validated address in the affected state
Notifications are sent when:
- Election dates are updated in the
electionDates.snapshot.jsonfile - The
electionDatesUpdater.jsjob detects changes in primary or general election dates - Changes are significant enough to potentially affect donation limits or timing
Criteria:
- Have active Celebrations (not resolved, defunct, or paused)
- Celebrations are for politicians in the affected state
- Have a valid email address
Notification Type: ElectionDateChanged
- High priority email (priority: 5)
- Includes detailed impact analysis
- Shows specific changes to donation limits
- Provides actionable next steps
Impact Analysis:
- Calculates how election date changes affect compliant-tier election-cycle donation limits
- Determines if donation limits have increased or decreased
- Identifies any election timeline changes that affect reset timing
Criteria:
- Have a validated
ocd_idin the affected state - Have a valid email address
- Do NOT have active Celebrations in the state (to avoid duplicate notifications)
Notification Type: ElectionDateNotification
- Medium priority email (priority: 3)
- Informational notification about election date changes
- Invites users to visit POWERBACK to learn more
- Focuses on engagement rather than specific impact
Subject: Important: Election Dates Changed in [STATE] - Your Celebrations May Be Affected
Content includes:
- Detailed comparison table of old vs new dates
- Specific impact description for the user
- Changes to donation limits (if applicable)
- Actionable next steps
- Link to Account section
Subject: Election Dates Updated in [STATE] - Stay Informed with POWERBACK
Content includes:
- Updated election schedule table
- Explanation of why election dates matter
- Invitation to visit POWERBACK
- Educational content about political engagement
-
services/electionDateNotificationService.js- Main service for handling notifications
- User discovery and impact calculation
- Email sending coordination
-
controller/comms/emails/alerts/ElectionDateChanged.js- Email templates for both notification types
- HTML formatting and styling
-
jobs/electionDatesUpdater.js- Integration point for triggering notifications
- Detects changes and calls notification service
Main function that orchestrates the notification process:
- Finds users with active Celebrations in the state
- Finds users with ocd_id in the state (excluding those already notified)
- Calculates impact for each user
- Sends appropriate notifications
- Returns summary statistics
Analyzes how election date changes affect a specific user:
- Only applies to compliant-tier users (election cycle limits)
- Calculates old vs new donation limits
- Determines if any election date changes affect reset timing
- Returns impact description and limit changes
Discovers users who have active Celebrations in the affected state:
- Finds all politicians in the state with
has_stakes: true - Finds active Celebrations for those politicians
- Returns unique users with valid email addresses
Discovers users with residential addresses in the affected state:
- Uses regex pattern to match ocd_id for the state
- Filters for users with valid email addresses
- Excludes users already notified via Celebrations
electionDatesUpdater.js
↓ (detects changes)
saveElectionDatesToSnapshot()
↓ (identifies changed states)
handleElectionDateChange()
↓ (for each changed state)
├── findUsersWithActiveCelebrations()
├── findUsersWithOcdIdInState()
├── calculateElectionDateImpact()
└── sendEmail() (via sendEmail service)
The system provides comprehensive logging:
- Change Detection: Logs which states have election date changes
- User Discovery: Logs how many users are found in each category
- Impact Analysis: Logs which users are affected and why
- Email Sending: Logs successful and failed email attempts
- Summary Statistics: Logs total emails sent per state
On the frontend, election-cycle–aware contexts such as ElectionCycleContext and donation-limit views use the shared client logging helper (logError / logWarn from @Utils) to report fallback scenarios (for example, when generic dates are used because a state is missing precise data) and calculation failures. In production these logs are message-only; full error objects and stacks are restricted to development to avoid leaking request/response details to user-visible consoles.
INFO: Election date changes detected (2):
INFO: Updated CA: 2026-03-05/2026-11-05 → 2026-03-08/2026-11-05
INFO: Updated TX: 2026-03-05/2026-11-05 → 2026-03-01/2026-11-05
INFO: Sending notifications for 2 states with changes
INFO: Found 15 users with active Celebrations in CA
INFO: Found 8 users with ocd_id in CA
INFO: Sent election date change notification to user@example.com
INFO: Election date change notifications completed: 23 emails sent across 2 states
The system includes robust error handling:
- Database Errors: Graceful fallback if user queries fail
- Email Failures: Individual email failures don't stop the process
- Impact Calculation Errors: Users without impact analysis still receive basic notifications
- Service Failures: Logs errors but continues processing other states
PROD_URL- Base URL for POWERBACK (server config)PHONE_NUMBER- Support phone number (server config)REACT_APP_EMAIL_SUPPORT_USER- Support email address (shared; see Environment Management)- Email configuration (SMTP settings:
EMAIL_HOST,EMAIL_JONATHAN_USER, etc.)
Usercollection withemail,firstName,compliance,ocd_idfieldsCelebrationcollection withdonatedBy,pol_id,resolved,defunct,pausedfieldsPolcollection withid,roles.state,has_stakesfields
To test the notification system:
- Manual Trigger: Call
electionDateNotificationService.handleElectionDateChange()with test data - Integration Test: Modify election dates in snapshot and run
electionDatesUpdater.js - Email Testing: Use test email addresses to verify template rendering
Potential improvements to consider:
- SMS Notifications: Add SMS alerts for critical changes
- Preference Settings: Allow users to opt out of certain notification types
- Impact Scoring: More sophisticated impact analysis algorithms
- Batch Processing: Process multiple states more efficiently
- Analytics: Track notification effectiveness and user engagement
- Background Jobs - Election dates updater job
- Donation Limits - Election cycle resets for compliant tier
- Email System - Notification emails
- FEC Compliance Guide - Compliance requirements
- Client Utils - Client logging and election-date helpers (e.g.
logError/logWarn,loadBundledElectionDatesfrom@Utils)