Updated subscription created/canceled events data

refs https://github.com/TryGhost/Team/issues/1865

- adds new subscription canceled event
- updates existing subscription created event to include tier id and source data
This commit is contained in:
Rishabh 2022-09-09 19:55:25 +05:30 committed by Rishabh Garg
parent 4187f0da54
commit 8d07d6e93b
3 changed files with 30 additions and 1 deletions

View File

@ -8,5 +8,6 @@ module.exports = {
MemberPaidCancellationEvent: require('./lib/MemberPaidCancellationEvent'),
MemberPageViewEvent: require('./lib/MemberPageViewEvent'),
SubscriptionCreatedEvent: require('./lib/SubscriptionCreatedEvent'),
MemberCommentEvent: require('./lib/MemberCommentEvent')
MemberCommentEvent: require('./lib/MemberCommentEvent'),
SubscriptionCancelledEvent: require('./lib/SubscriptionCancelledEvent')
};

View File

@ -0,0 +1,26 @@
/**
* @typedef {object} SubscriptionCancelledEventData
* @prop {string} source
* @prop {string} memberId
* @prop {string} tierId
* @prop {string} subscriptionId
*/
module.exports = class SubscriptionCancelledEvent {
/**
* @param {SubscriptionCancelledEventData} data
* @param {Date} timestamp
*/
constructor(data, timestamp) {
this.data = data;
this.timestamp = timestamp;
}
/**
* @param {SubscriptionCancelledEventData} data
* @param {Date} [timestamp]
*/
static create(data, timestamp) {
return new SubscriptionCancelledEvent(data, timestamp || new Date);
}
};

View File

@ -1,6 +1,8 @@
/**
* @typedef {object} SubscriptionCreatedEventData
* @prop {string} source
* @prop {string} memberId
* @prop {string} tierId
* @prop {string} subscriptionId
* @prop {string} offerId
* @prop {import('@tryghost/member-attribution/lib/attribution').Attribution} [attribution]