Modify log_upcoming_renewal_notification_job to create corresponding EmailEvent records

Problem

Currently, the LogUpcomingRenewalNotificationJob only logs information about upcoming subscription renewal email notifications from Zuora. It doesn't create structured records of these notifications in our system. With our new Notifications::EmailEvent model, we need to enhance this job to create proper EmailEvent records for better tracking and analysis.

Proposal

Modify the LogUpcomingRenewalNotificationJob to create Notifications::EmailEvent records when Zuora sends renewal notification emails. This will involve:

  1. Updating the perform method to create an EmailEvent record after logging the notification
  2. Determining the appropriate source object (likely the Subscription or Order) to associate with the EmailEvent
  3. Extracting the recipient email from the Zuora callback attributes
  4. Adding monitoring to ensure EmailEvent records are being created correctly

The job will continue to log the information as it currently does, but will also create structured records in our EmailEvent table.

Result

  • Comprehensive tracking of all Zuora-sent renewal notifications in the EmailEvent table
  • Improved debugging capabilities for notification issues

How will we measure success?

  • EmailEvent records are created for every Zuora notification received
  • The records contain accurate information about the notification
  • We can query the EmailEvent table to understand notification patterns
Edited by Minahil Nichols