feat: Remove PostHog event calls (#6915)

This commit is contained in:
Ricardo Espinoza
2023-08-17 11:39:32 -04:00
committed by GitHub
parent 41c3cc89ca
commit 270946a93b
13 changed files with 86 additions and 53 deletions

View File

@@ -124,7 +124,6 @@ export class InternalHooks implements IInternalHooksClass {
return this.telemetry.track(
'User responded to personalization questions',
personalizationSurveyData,
{ withPostHog: true },
);
}
@@ -190,21 +189,17 @@ export class InternalHooks implements IInternalHooksClass {
workflowName: workflow.name,
},
}),
this.telemetry.track(
'User saved workflow',
{
user_id: user.id,
workflow_id: workflow.id,
node_graph_string: JSON.stringify(nodeGraph),
notes_count_overlapping: overlappingCount,
notes_count_non_overlapping: notesCount - overlappingCount,
version_cli: N8N_VERSION,
num_tags: workflow.tags?.length ?? 0,
public_api: publicApi,
sharing_role: userRole,
},
{ withPostHog: true },
),
this.telemetry.track('User saved workflow', {
user_id: user.id,
workflow_id: workflow.id,
node_graph_string: JSON.stringify(nodeGraph),
notes_count_overlapping: overlappingCount,
notes_count_non_overlapping: notesCount - overlappingCount,
version_cli: N8N_VERSION,
num_tags: workflow.tags?.length ?? 0,
public_api: publicApi,
sharing_role: userRole,
}),
]);
}
@@ -415,11 +410,7 @@ export class InternalHooks implements IInternalHooksClass {
node_id: nodeGraphResult.nameIndices[runData.data.startData?.destinationNode],
};
promises.push(
this.telemetry.track('Manual node exec finished', telemetryPayload, {
withPostHog: true,
}),
);
promises.push(this.telemetry.track('Manual node exec finished', telemetryPayload));
} else {
nodeGraphResult.webhookNodeNames.forEach((name: string) => {
const execJson = runData.data.resultData.runData[name]?.[0]?.data?.main?.[0]?.[0]
@@ -432,9 +423,7 @@ export class InternalHooks implements IInternalHooksClass {
});
promises.push(
this.telemetry.track('Manual workflow exec finished', manualExecEventProperties, {
withPostHog: true,
}),
this.telemetry.track('Manual workflow exec finished', manualExecEventProperties),
);
}
}
@@ -484,7 +473,7 @@ export class InternalHooks implements IInternalHooksClass {
user_id_list: userList,
};
return this.telemetry.track('User updated workflow sharing', properties, { withPostHog: true });
return this.telemetry.track('User updated workflow sharing', properties);
}
async onN8nStop(): Promise<void> {
@@ -1017,7 +1006,7 @@ export class InternalHooks implements IInternalHooksClass {
user_id: string;
workflow_id: string;
}): Promise<void> {
return this.telemetry.track('Workflow first prod success', data, { withPostHog: true });
return this.telemetry.track('Workflow first prod success', data);
}
async onFirstWorkflowDataLoad(data: {
@@ -1028,7 +1017,7 @@ export class InternalHooks implements IInternalHooksClass {
credential_type?: string;
credential_id?: string;
}): Promise<void> {
return this.telemetry.track('Workflow first data fetched', data, { withPostHog: true });
return this.telemetry.track('Workflow first data fetched', data);
}
/**

View File

@@ -490,7 +490,7 @@ export class Server extends AbstractServer {
const controllers: object[] = [
new EventBusController(),
new AuthController({ config, internalHooks, repositories, logger, postHog }),
new OwnerController({ config, internalHooks, repositories, logger }),
new OwnerController({ config, internalHooks, repositories, logger, postHog }),
new MeController({ externalHooks, internalHooks, repositories, logger }),
new NodeTypesController({ config, nodeTypes }),
new PasswordResetController({

View File

@@ -762,7 +762,7 @@ export const schema = {
externalFrontendHooksUrls: {
doc: 'URLs to external frontend hooks files, ; separated',
format: String,
default: 'https://public.n8n.cloud/posthog-hooks.js',
default: '',
env: 'EXTERNAL_FRONTEND_HOOKS_URLS',
},

View File

@@ -6,6 +6,7 @@ import {
hashPassword,
sanitizeUser,
validatePassword,
withFeatureFlags,
} from '@/UserManagement/UserManagementHelper';
import { issueCookie } from '@/auth/jwt';
import { Response } from 'express';
@@ -14,6 +15,7 @@ import type { Config } from '@/config';
import { OwnerRequest } from '@/requests';
import type { IDatabaseCollections, IInternalHooksClass } from '@/Interfaces';
import type { SettingsRepository, UserRepository } from '@db/repositories';
import type { PostHogClient } from '@/posthog';
@Authorized(['global', 'owner'])
@RestController('/owner')
@@ -28,22 +30,27 @@ export class OwnerController {
private readonly settingsRepository: SettingsRepository;
private readonly postHog?: PostHogClient;
constructor({
config,
logger,
internalHooks,
repositories,
postHog,
}: {
config: Config;
logger: ILogger;
internalHooks: IInternalHooksClass;
repositories: Pick<IDatabaseCollections, 'User' | 'Settings'>;
postHog?: PostHogClient;
}) {
this.config = config;
this.logger = logger;
this.internalHooks = internalHooks;
this.userRepository = repositories.User;
this.settingsRepository = repositories.Settings;
this.postHog = postHog;
}
/**
@@ -122,7 +129,7 @@ export class OwnerController {
void this.internalHooks.onInstanceOwnerSetup({ user_id: userId });
return sanitizeUser(owner);
return withFeatureFlags(this.postHog, sanitizeUser(owner));
}
@Post('/dismiss-banner')

View File

@@ -95,15 +95,11 @@ export class Telemetry {
return sum > 0;
})
.map(async (workflowId) => {
const promise = this.track(
'Workflow execution count',
{
event_version: '2',
workflow_id: workflowId,
...this.executionCountsBuffer[workflowId],
},
{ withPostHog: true },
);
const promise = this.track('Workflow execution count', {
event_version: '2',
workflow_id: workflowId,
...this.executionCountsBuffer[workflowId],
});
return promise;
});