Track backend events (#5405)
Add tracking to backend events, we might disable frontend tracking which doesn't bring much value to improve the product
This commit is contained in:
@ -11,5 +11,6 @@ import { AnalyticsResolver } from './analytics.resolver';
|
||||
baseURL: 'https://t.twenty.com/api/v1/s2s',
|
||||
}),
|
||||
],
|
||||
exports: [AnalyticsService],
|
||||
})
|
||||
export class AnalyticsModule {}
|
||||
|
||||
@ -28,9 +28,11 @@ export class AnalyticsResolver {
|
||||
) {
|
||||
return this.analyticsService.create(
|
||||
createAnalyticsInput,
|
||||
user,
|
||||
workspace,
|
||||
request,
|
||||
user?.id,
|
||||
workspace?.id,
|
||||
workspace?.displayName,
|
||||
workspace?.domainName,
|
||||
request.hostname,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { HttpService } from '@nestjs/axios';
|
||||
|
||||
import { Request } from 'express';
|
||||
|
||||
import { anonymize } from 'src/utils/anonymize';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
import { User } from 'src/engine/core-modules/user/user.entity';
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
|
||||
import { CreateAnalyticsInput } from './dto/create-analytics.input';
|
||||
|
||||
@ -21,9 +17,11 @@ export class AnalyticsService {
|
||||
|
||||
async create(
|
||||
createEventInput: CreateAnalyticsInput,
|
||||
user: User | undefined,
|
||||
workspace: Workspace | undefined,
|
||||
request: Request,
|
||||
userId: string | undefined,
|
||||
workspaceId: string | undefined,
|
||||
workspaceDisplayName: string | undefined,
|
||||
workspaceDomainName: string | undefined,
|
||||
hostName: string | undefined,
|
||||
) {
|
||||
if (!this.environmentService.get('TELEMETRY_ENABLED')) {
|
||||
return { success: true };
|
||||
@ -36,19 +34,14 @@ export class AnalyticsService {
|
||||
const data = {
|
||||
type: createEventInput.type,
|
||||
data: {
|
||||
hostname: request.hostname,
|
||||
userUUID: user
|
||||
? anonymizationEnabled
|
||||
? anonymize(user.id)
|
||||
: user.id
|
||||
: undefined,
|
||||
workspaceUUID: workspace
|
||||
? anonymizationEnabled
|
||||
? anonymize(workspace.id)
|
||||
: workspace.id
|
||||
: undefined,
|
||||
workspaceDisplayName: workspace ? workspace.displayName : undefined,
|
||||
workspaceDomainName: workspace ? workspace.domainName : undefined,
|
||||
hostname: hostName,
|
||||
userUUID: anonymizationEnabled && userId ? anonymize(userId) : userId,
|
||||
workspaceUUID:
|
||||
anonymizationEnabled && workspaceId
|
||||
? anonymize(workspaceId)
|
||||
: workspaceId,
|
||||
workspaceDisplayName: workspaceDisplayName,
|
||||
workspaceDomainName: workspaceDomainName,
|
||||
...createEventInput.data,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user