Repository navigation
Release Notes - v1.9.0
Release Notes - v1.9.0
This release introduces significant improvements to logging, configuration, worker management, and adds new features like campaign cancellation, focusing on robustness, developer experience, and alignment with best practices.
✨ New Features & Major Improvements
- Structured Logging with Pino:
- Replaced the previous simple logger with
pinofor fast, structured (JSON) logging. (#XXX) - Logs now include rich context (component, queue, job ID, campaign ID, etc.).
- Log level is configurable via
loggerFactory.setLevel()or theLOG_LEVELenvironment variable (infodefault). - Added
pino-prettyas an optional dev dependency for improved readability during development.
- Replaced the previous simple logger with
- Refactored Worker Management:
- Removed
startWorker: truefromdispatchNotifications: This breaking change promotes the standard architecture of separating job producers and consumers. Users must now run workers independently usingstartWorkerServer. (#XXX) - Added
WorkerManager.pauseProcessing()andWorkerManager.resumeProcessing()methods to allow operators to gracefully pause/resume job consumption from a queue. (#XXX) - The existing
WorkerManager.close()method provides graceful shutdown.
- Removed
- Campaign Cancellation:
- Added optional
campaignIdtodispatchNotifications. (#XXX) - Workers now check for a Redis key (
worker:cancel:campaign:<campaignId>) before processing jobs with a matchingcampaignId. Setting the key's value to'true'will cause workers to skip processing for that campaign gracefully. - Removed the previous global
SimulationManagerin favor of this more targeted cancellation mechanism.
- Added optional
- Simplified Dispatch Configuration:
- Removed
notifierOptionsandcustomNotifierfromdispatchNotifications. Notifier configuration is now solely handled bystartWorkerServer. (#XXX) - Renamed
notifierTypetochannelNameindispatchNotificationsfor clarity. Kept generic type link formetasafety.
- Removed
- Refactored Notifier Implementation:
- Notifiers (
EmailNotifier,FirebaseNotifier, etc.) now delegate batching/concurrency/rate-limiting to a sharedbatchSenderutility internally. (#XXX) - Notifier
sendmethods now accept aPinoLoggerinstance for contextual logging during message sending.
- Notifiers (
- Improved Redis Instance Handling (
ensureRedisInstance):- The helper now robustly validates provided
ioredisinstances or creates new ones, ensuring required BullMQ options (maxRetriesPerRequest: null) are set correctly. (#XXX) - Provides clearer warnings and errors for misconfigured instances.
- The helper now robustly validates provided
- Firebase Notifier Configuration:
startWorkerServerconfiguration for Firebase (notifiers.firebase) now accepts theServiceAccountobject or a file path string directly, removing the need for the{ serviceAccount: ... }wrapper. (#XXX)
💥 Breaking Changes
startWorker: trueRemoved: ThestartWorkeroption indispatchNotificationshas been removed. Users must run worker processes separately usingstartWorkerServer. Update your deployment strategy accordingly.dispatchNotificationsConfiguration:notifierOptionsparameter removed. Configure notifiers viastartWorkerServer.customNotifierparameter removed. Register custom notifiers manually viaNotifierRegistryin your worker process.notifierTyperenamed tochannelName.
SimulationManagerRemoved: The global simulation mode managed viaSimulationManagerand Redis keyworker:simulation_modehas been removed. Use targeted Campaign Cancellation or environment variables for testing/simulation needs.- Notifier
sendSignature: Thesendmethod on theNotificationChannelinterface (and all implementing classes) now requires aPinoLoggerinstance as the third argument. If you have custom notifiers, update their signatures. - Firebase Config: The structure for configuring Firebase in
startWorkerServerhas changed fromnotifiers: { firebase: { serviceAccount: ... } }tonotifiers: { firebase: serviceAccountOrPathString }.
🔧 Minor Changes & Fixes
- Improved type safety in various interfaces (
NotificationResult, Meta types). - Refined error formatting in notifier results.
- Standardized use of
RateLimiteracross notifiers. - Added comprehensive unit tests for core utilities and notifiers (focusing on functionality). (#XXX)
- Updated README with new architecture, configuration, and examples. (#XXX)
⬆️ Dependency Updates
- Added
pinoas a direct dependency. - Updated BullMQ / ioredis / Notifier SDK types where applicable (List specific versions if changed significantly).
📝 Migration Guide
- Remove
startWorker: true: Delete thestartWorkeroption from alldispatchNotificationscalls. - Create Worker Script: Set up a separate Node.js script using
startWorkerServerto run your worker processes. Configure all necessary notifiers within thenotifiersoption ofstartWorkerServer. Deploy and manage this script using a process manager (PM2, nodemon, Docker, etc.). - Update
dispatchNotificationsCalls:- Rename
notifierTypetochannelName. - Remove
notifierOptions. - Remove
customNotifier. - (Optional) Add
campaignIdif you need cancellation capabilities.
- Rename
- Update
startWorkerServerConfig: If using Firebase, update thenotifiers.firebasevalue to pass the service account object or path directly. - Update Custom Notifiers: If you have custom classes implementing
NotificationChannel, update theirsendmethod to acceptlogger: PinoLoggeras the third argument. - Review Logging: Adapt to the new
pinobased logging output. Configure log levels viaLOG_LEVELenv var orloggerFactory.setLevel(). Consider usingpino-prettyin development. - Update Redis Instance Creation: If providing your own
ioredisinstance, ensure it's created withmaxRetriesPerRequest: null.
How to Use:
See the updated README.md for detailed usage instructions and examples.