feat(analytics): add clickhouse (#11174)

This commit is contained in:
Antoine Moreaux
2025-04-16 18:33:10 +02:00
committed by GitHub
parent b6901a49bf
commit 587281a541
66 changed files with 1858 additions and 244 deletions

View File

@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { AnalyticsService } from 'src/engine/core-modules/analytics/analytics.service';
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
import { AnalyticsService } from 'src/engine/core-modules/analytics/services/analytics.service';
import { MONITORING_EVENT } from 'src/engine/core-modules/analytics/utils/events/track/monitoring/monitoring';
type MessagingTelemetryTrackInput = {
eventName: string;
@ -14,10 +14,7 @@ type MessagingTelemetryTrackInput = {
@Injectable()
export class MessagingTelemetryService {
constructor(
private readonly analyticsService: AnalyticsService,
private readonly twentyConfigService: TwentyConfigService,
) {}
constructor(private readonly analyticsService: AnalyticsService) {}
public async track({
eventName,
@ -27,20 +24,16 @@ export class MessagingTelemetryService {
messageChannelId,
message,
}: MessagingTelemetryTrackInput): Promise<void> {
await this.analyticsService.create(
{
action: 'monitoring',
payload: {
eventName: `messaging.${eventName}`,
workspaceId,
userId,
connectedAccountId,
messageChannelId,
message,
},
},
userId,
workspaceId,
);
await this.analyticsService
.createAnalyticsContext({
userId,
workspaceId,
})
.track(MONITORING_EVENT, {
eventName: `messaging.${eventName}`,
connectedAccountId,
messageChannelId,
message,
});
}
}