feat: Track account, invoice and item viewed events

This commit is contained in:
Ahmed Bouhuolia
2024-10-14 12:15:21 +02:00
parent f59b8166b6
commit ea7f987fe3
8 changed files with 90 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import {
SALE_INVOICE_CREATED,
SALE_INVOICE_DELETED,
SALE_INVOICE_EDITED,
SALE_INVOICE_VIEWED,
} from '@/constants/event-tracker';
@Service()
@@ -33,6 +34,10 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
events.saleInvoice.onDeleted,
this.handleTrackDeletedInvoiceEvent
);
bus.subscribe(
events.saleInvoice.onViewed,
this.handleTrackViewedInvoiceEvent
);
}
private handleTrackInvoiceCreatedEvent = ({
@@ -64,4 +69,12 @@ export class SaleInvoiceEventsTracker extends EventSubscriber {
properties: {},
});
};
private handleTrackViewedInvoiceEvent = ({ tenantId }) => {
this.posthog.trackEvent({
distinctId: `tenant-${tenantId}`,
event: SALE_INVOICE_VIEWED,
properties: {},
});
};
}