Fix telemetry (#4303)
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
import { Resolver, Mutation, Args } from '@nestjs/graphql';
|
import { Resolver, Mutation, Args, Context } from '@nestjs/graphql';
|
||||||
import { UseGuards } from '@nestjs/common';
|
import { UseGuards } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
import { OptionalJwtAuthGuard } from 'src/guards/optional-jwt.auth.guard';
|
import { OptionalJwtAuthGuard } from 'src/guards/optional-jwt.auth.guard';
|
||||||
import { AuthWorkspace } from 'src/decorators/auth/auth-workspace.decorator';
|
import { AuthWorkspace } from 'src/decorators/auth/auth-workspace.decorator';
|
||||||
import { AuthUser } from 'src/decorators/auth/auth-user.decorator';
|
import { AuthUser } from 'src/decorators/auth/auth-user.decorator';
|
||||||
@ -22,7 +24,13 @@ export class AnalyticsResolver {
|
|||||||
@Args() createEventInput: CreateAnalyticsInput,
|
@Args() createEventInput: CreateAnalyticsInput,
|
||||||
@AuthWorkspace() workspace: Workspace | undefined,
|
@AuthWorkspace() workspace: Workspace | undefined,
|
||||||
@AuthUser({ allowUndefined: true }) user: User | undefined,
|
@AuthUser({ allowUndefined: true }) user: User | undefined,
|
||||||
|
@Context('req') request: Request,
|
||||||
) {
|
) {
|
||||||
return this.analyticsService.create(createEventInput, user, workspace);
|
return this.analyticsService.create(
|
||||||
|
createEventInput,
|
||||||
|
user,
|
||||||
|
workspace,
|
||||||
|
request,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { HttpService } from '@nestjs/axios';
|
import { HttpService } from '@nestjs/axios';
|
||||||
|
|
||||||
|
import { Request } from 'express';
|
||||||
|
|
||||||
import { anonymize } from 'src/utils/anonymize';
|
import { anonymize } from 'src/utils/anonymize';
|
||||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||||
import { User } from 'src/core/user/user.entity';
|
import { User } from 'src/core/user/user.entity';
|
||||||
@ -19,6 +21,7 @@ export class AnalyticsService {
|
|||||||
createEventInput: CreateAnalyticsInput,
|
createEventInput: CreateAnalyticsInput,
|
||||||
user: User | undefined,
|
user: User | undefined,
|
||||||
workspace: Workspace | undefined,
|
workspace: Workspace | undefined,
|
||||||
|
request: Request,
|
||||||
) {
|
) {
|
||||||
if (!this.environmentService.isTelemetryEnabled()) {
|
if (!this.environmentService.isTelemetryEnabled()) {
|
||||||
return { success: true };
|
return { success: true };
|
||||||
@ -30,6 +33,7 @@ export class AnalyticsService {
|
|||||||
const data = {
|
const data = {
|
||||||
type: createEventInput.type,
|
type: createEventInput.type,
|
||||||
data: {
|
data: {
|
||||||
|
hostname: request.hostname,
|
||||||
userUUID: user
|
userUUID: user
|
||||||
? anonymizationEnabled
|
? anonymizationEnabled
|
||||||
? anonymize(user.id)
|
? anonymize(user.id)
|
||||||
@ -40,13 +44,14 @@ export class AnalyticsService {
|
|||||||
? anonymize(workspace.id)
|
? anonymize(workspace.id)
|
||||||
: workspace.id
|
: workspace.id
|
||||||
: undefined,
|
: undefined,
|
||||||
workspaceDomain: workspace ? workspace.domainName : undefined,
|
workspaceDisplayName: workspace ? workspace.displayName : undefined,
|
||||||
|
workspaceDomainName: workspace ? workspace.domainName : undefined,
|
||||||
...createEventInput.data,
|
...createEventInput.data,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.httpService.post('/event?noToken', data);
|
await this.httpService.axiosRef.post('/v1', data);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
|
|||||||
Reference in New Issue
Block a user