mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
refactor(core): Decouple community packages from internal hooks (no-changelog) (#10152)
This commit is contained in:
parent
4547a49db1
commit
467051580b
|
@ -618,72 +618,6 @@ export class InternalHooks {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Community nodes backend telemetry events
|
||||
*/
|
||||
|
||||
async onCommunityPackageInstallFinished(installationData: {
|
||||
user: User;
|
||||
input_string: string;
|
||||
package_name: string;
|
||||
success: boolean;
|
||||
package_version?: string;
|
||||
package_node_names?: string[];
|
||||
package_author?: string;
|
||||
package_author_email?: string;
|
||||
failure_reason?: string;
|
||||
}): Promise<void> {
|
||||
void this.telemetry.track('cnr package install finished', {
|
||||
user_id: installationData.user.id,
|
||||
input_string: installationData.input_string,
|
||||
package_name: installationData.package_name,
|
||||
success: installationData.success,
|
||||
package_version: installationData.package_version,
|
||||
package_node_names: installationData.package_node_names,
|
||||
package_author: installationData.package_author,
|
||||
package_author_email: installationData.package_author_email,
|
||||
failure_reason: installationData.failure_reason,
|
||||
});
|
||||
}
|
||||
|
||||
async onCommunityPackageUpdateFinished(updateData: {
|
||||
user: User;
|
||||
package_name: string;
|
||||
package_version_current: string;
|
||||
package_version_new: string;
|
||||
package_node_names: string[];
|
||||
package_author?: string;
|
||||
package_author_email?: string;
|
||||
}): Promise<void> {
|
||||
void this.telemetry.track('cnr package updated', {
|
||||
user_id: updateData.user.id,
|
||||
package_name: updateData.package_name,
|
||||
package_version_current: updateData.package_version_current,
|
||||
package_version_new: updateData.package_version_new,
|
||||
package_node_names: updateData.package_node_names,
|
||||
package_author: updateData.package_author,
|
||||
package_author_email: updateData.package_author_email,
|
||||
});
|
||||
}
|
||||
|
||||
async onCommunityPackageDeleteFinished(deleteData: {
|
||||
user: User;
|
||||
package_name: string;
|
||||
package_version: string;
|
||||
package_node_names: string[];
|
||||
package_author?: string;
|
||||
package_author_email?: string;
|
||||
}): Promise<void> {
|
||||
void this.telemetry.track('cnr package deleted', {
|
||||
user_id: deleteData.user.id,
|
||||
package_name: deleteData.package_name,
|
||||
package_version: deleteData.package_version,
|
||||
package_node_names: deleteData.package_node_names,
|
||||
package_author: deleteData.package_author,
|
||||
package_author_email: deleteData.package_author_email,
|
||||
});
|
||||
}
|
||||
|
||||
async onLdapSyncFinished(data: {
|
||||
type: string;
|
||||
succeeded: boolean;
|
||||
|
|
|
@ -108,14 +108,6 @@ export class CommunityPackagesController {
|
|||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : UNKNOWN_FAILURE_REASON;
|
||||
|
||||
void this.internalHooks.onCommunityPackageInstallFinished({
|
||||
user: req.user,
|
||||
input_string: name,
|
||||
package_name: parsed.packageName,
|
||||
success: false,
|
||||
package_version: parsed.version,
|
||||
failure_reason: errorMessage,
|
||||
});
|
||||
this.eventService.emit('community-package-installed', {
|
||||
user: req.user,
|
||||
inputString: name,
|
||||
|
@ -144,16 +136,6 @@ export class CommunityPackagesController {
|
|||
});
|
||||
});
|
||||
|
||||
void this.internalHooks.onCommunityPackageInstallFinished({
|
||||
user: req.user,
|
||||
input_string: name,
|
||||
package_name: parsed.packageName,
|
||||
success: true,
|
||||
package_version: parsed.version,
|
||||
package_node_names: installedPackage.installedNodes.map((node) => node.name),
|
||||
package_author: installedPackage.authorName,
|
||||
package_author_email: installedPackage.authorEmail,
|
||||
});
|
||||
this.eventService.emit('community-package-installed', {
|
||||
user: req.user,
|
||||
inputString: name,
|
||||
|
@ -245,14 +227,6 @@ export class CommunityPackagesController {
|
|||
});
|
||||
});
|
||||
|
||||
void this.internalHooks.onCommunityPackageDeleteFinished({
|
||||
user: req.user,
|
||||
package_name: name,
|
||||
package_version: installedPackage.installedVersion,
|
||||
package_node_names: installedPackage.installedNodes.map((node) => node.name),
|
||||
package_author: installedPackage.authorName,
|
||||
package_author_email: installedPackage.authorEmail,
|
||||
});
|
||||
this.eventService.emit('community-package-deleted', {
|
||||
user: req.user,
|
||||
packageName: name,
|
||||
|
@ -300,15 +274,6 @@ export class CommunityPackagesController {
|
|||
});
|
||||
});
|
||||
|
||||
void this.internalHooks.onCommunityPackageUpdateFinished({
|
||||
user: req.user,
|
||||
package_name: name,
|
||||
package_version_current: previouslyInstalledPackage.installedVersion,
|
||||
package_version_new: newInstalledPackage.installedVersion,
|
||||
package_node_names: newInstalledPackage.installedNodes.map((node) => node.name),
|
||||
package_author: newInstalledPackage.authorName,
|
||||
package_author_email: newInstalledPackage.authorEmail,
|
||||
});
|
||||
this.eventService.emit('community-package-updated', {
|
||||
user: req.user,
|
||||
packageName: name,
|
||||
|
|
|
@ -59,6 +59,15 @@ export class TelemetryEventRelay {
|
|||
this.eventService.on('public-api-key-deleted', (event) => {
|
||||
this.publicApiKeyDeleted(event);
|
||||
});
|
||||
this.eventService.on('community-package-installed', (event) => {
|
||||
this.communityPackageInstalled(event);
|
||||
});
|
||||
this.eventService.on('community-package-updated', (event) => {
|
||||
this.communityPackageUpdated(event);
|
||||
});
|
||||
this.eventService.on('community-package-deleted', (event) => {
|
||||
this.communityPackageDeleted(event);
|
||||
});
|
||||
}
|
||||
|
||||
private teamProjectUpdated({ userId, role, members, projectId }: Event['team-project-updated']) {
|
||||
|
@ -230,4 +239,66 @@ export class TelemetryEventRelay {
|
|||
public_api: publicApi,
|
||||
});
|
||||
}
|
||||
|
||||
private communityPackageInstalled({
|
||||
user,
|
||||
inputString,
|
||||
packageName,
|
||||
success,
|
||||
packageVersion,
|
||||
packageNodeNames,
|
||||
packageAuthor,
|
||||
packageAuthorEmail,
|
||||
failureReason,
|
||||
}: Event['community-package-installed']) {
|
||||
void this.telemetry.track('cnr package install finished', {
|
||||
user_id: user.id,
|
||||
input_string: inputString,
|
||||
package_name: packageName,
|
||||
success,
|
||||
package_version: packageVersion,
|
||||
package_node_names: packageNodeNames,
|
||||
package_author: packageAuthor,
|
||||
package_author_email: packageAuthorEmail,
|
||||
failure_reason: failureReason,
|
||||
});
|
||||
}
|
||||
|
||||
private communityPackageUpdated({
|
||||
user,
|
||||
packageName,
|
||||
packageVersionCurrent,
|
||||
packageVersionNew,
|
||||
packageNodeNames,
|
||||
packageAuthor,
|
||||
packageAuthorEmail,
|
||||
}: Event['community-package-updated']) {
|
||||
void this.telemetry.track('cnr package updated', {
|
||||
user_id: user.id,
|
||||
package_name: packageName,
|
||||
package_version_current: packageVersionCurrent,
|
||||
package_version_new: packageVersionNew,
|
||||
package_node_names: packageNodeNames,
|
||||
package_author: packageAuthor,
|
||||
package_author_email: packageAuthorEmail,
|
||||
});
|
||||
}
|
||||
|
||||
private communityPackageDeleted({
|
||||
user,
|
||||
packageName,
|
||||
packageVersion,
|
||||
packageNodeNames,
|
||||
packageAuthor,
|
||||
packageAuthorEmail,
|
||||
}: Event['community-package-deleted']) {
|
||||
void this.telemetry.track('cnr package deleted', {
|
||||
user_id: user.id,
|
||||
package_name: packageName,
|
||||
package_version: packageVersion,
|
||||
package_node_names: packageNodeNames,
|
||||
package_author: packageAuthor,
|
||||
package_author_email: packageAuthorEmail,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue