mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
076e3c02b2
fixes https://github.com/TryGhost/Team/issues/2160 - Adds a `batch_id` to both events that contain the same ID if they were created at the same time. - Removes duplicate signup/conversion events using the batch_id - Requires an update in mongo-knex to work (refs https://ghost.slack.com/archives/C02G9E68C/p1666773313272409?thread_ts=1666767872.375009&cid=C02G9E68C) - Some dependencies needed an update to load the latest mongo-knex - Added tiers to membersUtils, loaded on startup (we can start to use this instead of fetching it every time)
30 lines
783 B
JavaScript
30 lines
783 B
JavaScript
/**
|
|
* @typedef {object} SubscriptionCreatedEventData
|
|
* @prop {string} source
|
|
* @prop {string} memberId
|
|
* @prop {string} batchId
|
|
* @prop {string} tierId
|
|
* @prop {string} subscriptionId
|
|
* @prop {string} offerId
|
|
* @prop {import('@tryghost/member-attribution/lib/attribution').Attribution} [attribution]
|
|
*/
|
|
|
|
module.exports = class SubscriptionCreatedEvent {
|
|
/**
|
|
* @param {SubscriptionCreatedEventData} data
|
|
* @param {Date} timestamp
|
|
*/
|
|
constructor(data, timestamp) {
|
|
this.data = data;
|
|
this.timestamp = timestamp;
|
|
}
|
|
|
|
/**
|
|
* @param {SubscriptionCreatedEventData} data
|
|
* @param {Date} [timestamp]
|
|
*/
|
|
static create(data, timestamp) {
|
|
return new SubscriptionCreatedEvent(data, timestamp ?? new Date);
|
|
}
|
|
};
|