feat: Track reports view events

This commit is contained in:
Ahmed Bouhuolia
2024-10-26 12:39:48 +02:00
parent 32ba6f9a6c
commit cadf6b81a0
18 changed files with 459 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ import { Tenant } from '@/system/models';
import { mergeQueryWithDefaults } from './utils';
import { ProfitLossSheetRepository } from './ProfitLossSheetRepository';
import { ProfitLossSheetMeta } from './ProfitLossSheetMeta';
import { EventPublisher } from '@/lib/EventPublisher/EventPublisher';
import events from '@/subscribers/events';
// Profit/Loss sheet service.
@Service()
@@ -20,6 +22,9 @@ export default class ProfitLossSheetService {
@Inject()
private profitLossSheetMeta: ProfitLossSheetMeta;
@Inject()
private eventPublisher: EventPublisher;
/**
* Retrieve profit/loss sheet statement.
* @param {number} tenantId
@@ -62,6 +67,15 @@ export default class ProfitLossSheetService {
// Retrieve the profit/loss sheet meta.
const meta = await this.profitLossSheetMeta.meta(tenantId, filter);
// Triggers `onProfitLossSheetViewed` event.
await this.eventPublisher.emitAsync(
events.reports.onProfitLossSheetViewed,
{
tenantId,
query,
}
);
return {
query: filter,
data,