Ghost/ghost/member-events/lib/MemberEmailAnalyticsUpdateEvent.js
Steve Larson 88db66a74c
Added experimental background job queue (#20985)
ref https://linear.app/tryghost/issue/ENG-1556/
- added background job queue behind config flags
- when enabled, is only used for the member email analytics updates in
order to speed up the parent job, and take load off of the main process
that is serving requests

The intent here is to decouple certain code paths from the main process where it is unnecessary, or worse, where it's part of the request. Primary use cases are email analytics (particularly the member stats [open rate]) which are not particularly helpful in the period immediately following an email send, while the click traffic and delivered/opened events are.

Related, the email link clicks themselves send off a cascade of events that are quite a burden on the main process currently and are somewhat tied to the request response when they needn't be. We'll be looking to tackle that after some initial testing with the email analytics job.
2024-11-04 10:13:15 -06:00

23 lines
590 B
JavaScript

/**
* @typedef {object} MemberEmailAnalyticsUpdateEventData
* @prop {string} memberId
*/
module.exports = class MemberEmailAnalyticsUpdateEvent {
/**
* @param {MemberEmailAnalyticsUpdateEventData} data
* @param {Date} timestamp
*/
constructor(data, timestamp) {
this.data = data;
this.timestamp = timestamp;
}
/**
* @param {MemberEmailAnalyticsUpdateEventData} data
* @param {Date} [timestamp]
*/
static create(data, timestamp) {
return new MemberEmailAnalyticsUpdateEvent(data, timestamp ?? new Date);
}
};