Refactor client config (#529)
* Refactor client config * Fix server tests * Fix lint
This commit is contained in:
@ -3,12 +3,13 @@ import { User, Workspace } from '@prisma/client';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import { CreateAnalyticsInput } from './dto/create-analytics.input';
|
||||
import { anonymize } from 'src/utils/anonymize';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class AnalyticsService {
|
||||
private readonly httpService: AxiosInstance;
|
||||
|
||||
constructor() {
|
||||
constructor(private readonly environmentService: EnvironmentService) {
|
||||
this.httpService = axios.create({
|
||||
baseURL: 'https://t.twenty.com/api/v1/s2s',
|
||||
});
|
||||
@ -19,15 +20,26 @@ export class AnalyticsService {
|
||||
user: User | undefined,
|
||||
workspace: Workspace | undefined,
|
||||
) {
|
||||
if (process.env.IS_TELEMETRY_ENABLED === 'false') {
|
||||
return;
|
||||
if (!this.environmentService.isTelemetryEnabled()) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
const anonymizationEnabled =
|
||||
this.environmentService.isTelemetryAnonymizationEnabled();
|
||||
|
||||
const data = {
|
||||
type: createEventInput.type,
|
||||
data: {
|
||||
userUUID: user ? anonymize(user.id) : undefined,
|
||||
workspaceUUID: workspace ? anonymize(workspace.id) : undefined,
|
||||
userUUID: user
|
||||
? anonymizationEnabled
|
||||
? anonymize(user.id)
|
||||
: user.id
|
||||
: undefined,
|
||||
workspaceUUID: workspace
|
||||
? anonymizationEnabled
|
||||
? anonymize(workspace.id)
|
||||
: workspace.id
|
||||
: undefined,
|
||||
workspaceDomain: workspace ? workspace.domainName : undefined,
|
||||
...createEventInput.data,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user