mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge pull request #653 from bigcapitalhq/tracking-more-events
feat: Tracking more Posthog events
This commit is contained in:
@@ -34,6 +34,26 @@ export const ITEM_EVENT_DELETED = 'Item deleted';
|
|||||||
export const AUTH_SIGNED_UP = 'Auth Signed-up';
|
export const AUTH_SIGNED_UP = 'Auth Signed-up';
|
||||||
export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
export const AUTH_RESET_PASSWORD = 'Auth reset password';
|
||||||
|
|
||||||
|
export const SUBSCRIPTION_CANCELLED = 'Subscription cancelled';
|
||||||
|
export const SUBSCRIPTION_RESUMED = 'Subscription resumed';
|
||||||
|
export const SUBSCRIPTION_PLAN_CHANGED = 'Subscription plan changed';
|
||||||
|
|
||||||
|
export const CUSTOMER_CREATED = 'Customer created';
|
||||||
|
export const CUSTOMER_EDITED = 'Customer edited';
|
||||||
|
export const CUSTOMER_DELETED = 'Customer deleted';
|
||||||
|
|
||||||
|
export const VENDOR_CREATED = 'Vendor created';
|
||||||
|
export const VENDOR_EDITED = 'Vendor edited';
|
||||||
|
export const VENDOR_DELETED = 'Vendor deleted';
|
||||||
|
|
||||||
|
export const TRANSACTIONS_LOCKING_LOCKED = 'Transactions locking locked';
|
||||||
|
export const TRANSACTIONS_LOCKING_LOCKING_CANCELLED =
|
||||||
|
'Transactions locking cancelled';
|
||||||
|
export const TRANSACTIONS_LOCKING_PARTIALLY_UNLOCKED =
|
||||||
|
'Transactions locking partially unlocked';
|
||||||
|
export const TRANSACTIONS_LOCKING_PARTIALLY_UNLOCK_CANCELLED =
|
||||||
|
'Transactions locking partially unlock cancelled';
|
||||||
|
|
||||||
export const BANK_TRANSACTION_MATCHED = 'Bank transaction matching deleted';
|
export const BANK_TRANSACTION_MATCHED = 'Bank transaction matching deleted';
|
||||||
export const BANK_TRANSACTION_EXCLUDED = 'Bank transaction excluded';
|
export const BANK_TRANSACTION_EXCLUDED = 'Bank transaction excluded';
|
||||||
export const BANK_TRANSACTION_CATEGORIZED = 'Bank transaction categorized';
|
export const BANK_TRANSACTION_CATEGORIZED = 'Bank transaction categorized';
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ export class CustomerEventsTracker extends EventSubscriber {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private posthog: PosthogService;
|
private posthog: PosthogService;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor method.
|
|
||||||
*/
|
|
||||||
public attach(bus) {
|
public attach(bus) {
|
||||||
bus.subscribe(
|
bus.subscribe(
|
||||||
events.customers.onCreated,
|
events.customers.onCreated,
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||||
|
import { ITransactionsLockingPartialUnlocked } from '@/interfaces';
|
||||||
|
import { PosthogService } from '../PostHog';
|
||||||
|
import {
|
||||||
|
TRANSACTIONS_LOCKING_LOCKED,
|
||||||
|
TRANSACTIONS_LOCKING_LOCKING_CANCELLED,
|
||||||
|
TRANSACTIONS_LOCKING_PARTIALLY_UNLOCK_CANCELLED,
|
||||||
|
TRANSACTIONS_LOCKING_PARTIALLY_UNLOCKED,
|
||||||
|
} from '@/constants/event-tracker';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class TransactionsLockingEventsTracker extends EventSubscriber {
|
||||||
|
@Inject()
|
||||||
|
private posthog: PosthogService;
|
||||||
|
|
||||||
|
public attach(bus) {
|
||||||
|
bus.subscribe(
|
||||||
|
events.transactionsLocking.locked,
|
||||||
|
this.handleTransactionsLockingLockedEvent
|
||||||
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.transactionsLocking.lockCanceled,
|
||||||
|
this.handleTransactionsLockingCancelledEvent
|
||||||
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.transactionsLocking.partialUnlocked,
|
||||||
|
this.handleTransactionsLockingPartiallyUnlockedEvent
|
||||||
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.transactionsLocking.partialUnlockCanceled,
|
||||||
|
this.handleTransactionsLockingPartiallyUnlockCancelledEvent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleTransactionsLockingLockedEvent = ({
|
||||||
|
tenantId,
|
||||||
|
}: ITransactionsLockingPartialUnlocked) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: TRANSACTIONS_LOCKING_LOCKED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleTransactionsLockingCancelledEvent = ({
|
||||||
|
tenantId,
|
||||||
|
}: ITransactionsLockingPartialUnlocked) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: TRANSACTIONS_LOCKING_LOCKING_CANCELLED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleTransactionsLockingPartiallyUnlockedEvent = ({
|
||||||
|
tenantId,
|
||||||
|
}: ITransactionsLockingPartialUnlocked) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: TRANSACTIONS_LOCKING_PARTIALLY_UNLOCKED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleTransactionsLockingPartiallyUnlockCancelledEvent = ({
|
||||||
|
tenantId,
|
||||||
|
}: ITransactionsLockingPartialUnlocked) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: TRANSACTIONS_LOCKING_PARTIALLY_UNLOCK_CANCELLED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { Inject, Service } from 'typedi';
|
||||||
|
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
|
||||||
|
import { ITransactionsLockingPartialUnlocked } from '@/interfaces';
|
||||||
|
import { PosthogService } from '../PostHog';
|
||||||
|
import {
|
||||||
|
SUBSCRIPTION_CANCELLED,
|
||||||
|
SUBSCRIPTION_PLAN_CHANGED,
|
||||||
|
SUBSCRIPTION_RESUMED,
|
||||||
|
} from '@/constants/event-tracker';
|
||||||
|
import events from '@/subscribers/events';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export class TransactionsLockingEventsTracker extends EventSubscriber {
|
||||||
|
@Inject()
|
||||||
|
private posthog: PosthogService;
|
||||||
|
|
||||||
|
public attach(bus) {
|
||||||
|
bus.subscribe(
|
||||||
|
events.subscription.onSubscriptionResumed,
|
||||||
|
this.handleSubscriptionResumedEvent
|
||||||
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.subscription.onSubscriptionCancelled,
|
||||||
|
this.handleSubscriptionCancelledEvent
|
||||||
|
);
|
||||||
|
bus.subscribe(
|
||||||
|
events.subscription.onSubscriptionPlanChanged,
|
||||||
|
this.handleSubscriptionPlanChangedEvent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleSubscriptionResumedEvent = ({ tenantId }) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: SUBSCRIPTION_RESUMED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleSubscriptionCancelledEvent = ({ tenantId }) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: SUBSCRIPTION_CANCELLED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleSubscriptionPlanChangedEvent = ({ tenantId }) => {
|
||||||
|
this.posthog.trackEvent({
|
||||||
|
distinctId: `tenant-${tenantId}`,
|
||||||
|
event: SUBSCRIPTION_PLAN_CHANGED,
|
||||||
|
properties: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -18,9 +18,6 @@ export class VendorEventsTracker extends EventSubscriber {
|
|||||||
@Inject()
|
@Inject()
|
||||||
private posthog: PosthogService;
|
private posthog: PosthogService;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor method.
|
|
||||||
*/
|
|
||||||
public attach(bus) {
|
public attach(bus) {
|
||||||
bus.subscribe(events.vendors.onCreated, this.handleTrackVendorCreatedEvent);
|
bus.subscribe(events.vendors.onCreated, this.handleTrackVendorCreatedEvent);
|
||||||
bus.subscribe(events.vendors.onEdited, this.handleTrackEditedVendorEvent);
|
bus.subscribe(events.vendors.onEdited, this.handleTrackEditedVendorEvent);
|
||||||
|
|||||||
Reference in New Issue
Block a user