mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
refactor: events tracker to nestjs
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { ITransactionsLockingPartialUnlocked } from '@/interfaces';
|
||||
import {
|
||||
SUBSCRIPTION_CANCELLED,
|
||||
SUBSCRIPTION_PAYMENT_FAILED,
|
||||
SUBSCRIPTION_PAYMENT_SUCCEED,
|
||||
SUBSCRIPTION_PLAN_CHANGED,
|
||||
SUBSCRIPTION_RESUMED,
|
||||
} from '../event-tracker';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { EventTrackerService } from '../EventTracker.service';
|
||||
|
||||
import { events } from '@/common/events/events';
|
||||
@Injectable()
|
||||
export class TransactionsLockingEventsTracker {
|
||||
constructor(public readonly posthog: EventTrackerService) {}
|
||||
|
||||
@OnEvent(events.subscription.onSubscriptionResumed)
|
||||
public handleSubscriptionResumedEvent() {
|
||||
this.posthog.trackEvent({
|
||||
event: SUBSCRIPTION_RESUMED,
|
||||
properties: {},
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(events.subscription.onSubscriptionCancelled)
|
||||
public handleSubscriptionCancelledEvent() {
|
||||
this.posthog.trackEvent({
|
||||
event: SUBSCRIPTION_CANCELLED,
|
||||
properties: {},
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(events.subscription.onSubscriptionPlanChanged)
|
||||
public handleSubscriptionPlanChangedEvent() {
|
||||
this.posthog.trackEvent({
|
||||
event: SUBSCRIPTION_PLAN_CHANGED,
|
||||
properties: {},
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(events.subscription.onSubscriptionPaymentFailed)
|
||||
public handleSubscriptionPaymentFailedEvent() {
|
||||
this.posthog.trackEvent({
|
||||
event: SUBSCRIPTION_PAYMENT_FAILED,
|
||||
properties: {},
|
||||
});
|
||||
}
|
||||
|
||||
@OnEvent(events.subscription.onSubscriptionPaymentSucceed)
|
||||
public handleSubscriptionPaymentSucceed() {
|
||||
this.posthog.trackEvent({
|
||||
event: SUBSCRIPTION_PAYMENT_SUCCEED,
|
||||
properties: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user