feat: Add global event bus (#4860)

* fix branch

* fix deserialize, add filewriter

* add catchAll eventGroup/Name

* adding simple Redis sender and receiver to eventbus

* remove native node threads

* improve eventbus

* refactor and simplify

* more refactoring and syslog client

* more refactor, improved endpoints and eventbus

* remove local broker and receivers from mvp

* destination de/serialization

* create MessageEventBusDestinationEntity

* db migrations, load destinations at startup

* add delete destination endpoint

* pnpm merge and circular import fix

* delete destination fix

* trigger log file shuffle after size reached

* add environment variables for eventbus

* reworking event messages

* serialize to thread fix

* some refactor and lint fixing

* add emit to eventbus

* cleanup and fix sending unsent

* quicksave frontend trial

* initial EventTree vue component

* basic log streaming settings in vue

* http request code merge

* create destination settings modals

* fix eventmessage options types

* credentials are loaded

* fix and clean up frontend code

* move request code to axios

* update lock file

* merge fix

* fix redis build

* move destination interfaces into workflow pkg

* revive sentry as destination

* migration fixes and frontend cleanup

* N8N-5777 / N8N-5789 N8N-5788

* N8N-5784

* N8N-5782 removed event levels

* N8N-5790 sentry destination cleanup

* N8N-5786 and refactoring

* N8N-5809 and refactor/cleanup

* UI fixes and anonymize renaming

* N8N-5837

* N8N-5834

* fix no-items UI issues

* remove card / settings label in modal

* N8N-5842 fix

* disable webhook auth for now and update ui

* change sidebar to tabs

* remove payload option

* extend audit events with more user data

* N8N-5853 and UI revert to sidebar

* remove redis destination

* N8N-5864 / N8N-5868 / N8N-5867 / N8N-5865

* ui and licensing fixes

* add node events and info bubbles to frontend

* ui wording changes

* frontend tests

* N8N-5896 and ee rename

* improves backend tests

* merge fix

* fix backend test

* make linter happy

* remove unnecessary cfg / limit  actions to owners

* fix multiple sentry DSN and anon bug

* eslint fix

* more tests and fixes

* merge fix

* fix workflow audit events

* remove 'n8n.workflow.execution.error' event

* merge fix

* lint fix

* lint fix

* review fixes

* fix merge

* prettier fixes

* merge

* review changes

* use loggerproxy

* remove catch from internal hook promises

* fix tests

* lint fix

* include review PR changes

* review changes

* delete duplicate lines from a bad merge

* decouple log-streaming UI options from public API

* logstreaming -> log-streaming for consistency

* do not make unnecessary api calls when log streaming is disabled

* prevent sentryClient.close() from being called if init failed

* fix the e2e test for log-streaming

* review changes

* cleanup

* use `private` for one last private property

* do not use node prefix package names.. just yet

* remove unused import

* fix the tests

because there is a folder called `events`, tsc-alias is messing up all imports for native events module.
https://github.com/justkey007/tsc-alias/issues/152

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Auerswald
2023-01-04 09:47:48 +01:00
committed by GitHub
parent 0795cdb74c
commit b67f803cbe
104 changed files with 5867 additions and 219 deletions

View File

@@ -65,7 +65,7 @@ export function meNamespace(this: N8nApp): void {
const updatedkeys = Object.keys(req.body);
void InternalHooksManager.getInstance().onUserUpdate({
user_id: req.user.id,
user,
fields_changed: updatedkeys,
});
await this.externalHooks.run('user.profile.update', [currentEmail, sanitizeUser(user)]);
@@ -106,7 +106,7 @@ export function meNamespace(this: N8nApp): void {
await issueCookie(res, user);
void InternalHooksManager.getInstance().onUserUpdate({
user_id: req.user.id,
user,
fields_changed: ['password'],
});
@@ -162,12 +162,10 @@ export function meNamespace(this: N8nApp): void {
apiKey,
});
const telemetryData = {
user_id: req.user.id,
void InternalHooksManager.getInstance().onApiKeyCreated({
user: req.user,
public_api: false,
};
void InternalHooksManager.getInstance().onApiKeyCreated(telemetryData);
});
return { apiKey };
}),
@@ -183,12 +181,10 @@ export function meNamespace(this: N8nApp): void {
apiKey: null,
});
const telemetryData = {
user_id: req.user.id,
void InternalHooksManager.getInstance().onApiKeyDeleted({
user: req.user,
public_api: false,
};
void InternalHooksManager.getInstance().onApiKeyDeleted(telemetryData);
});
return { success: true };
}),

View File

@@ -86,7 +86,7 @@ export function passwordResetNamespace(this: N8nApp): void {
});
} catch (error) {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: user.id,
user,
message_type: 'Reset password',
public_api: false,
});
@@ -105,7 +105,7 @@ export function passwordResetNamespace(this: N8nApp): void {
});
void InternalHooksManager.getInstance().onUserPasswordResetRequestClick({
user_id: id,
user,
});
}),
);
@@ -152,7 +152,7 @@ export function passwordResetNamespace(this: N8nApp): void {
Logger.info('Reset-password token resolved successfully', { userId: id });
void InternalHooksManager.getInstance().onUserPasswordResetEmailClick({
user_id: id,
user,
});
}),
);
@@ -212,7 +212,7 @@ export function passwordResetNamespace(this: N8nApp): void {
await issueCookie(res, user);
void InternalHooksManager.getInstance().onUserUpdate({
user_id: userId,
user,
fields_changed: ['password'],
});

View File

@@ -145,7 +145,7 @@ export function usersNamespace(this: N8nApp): void {
});
void InternalHooksManager.getInstance().onUserInvite({
user_id: req.user.id,
user: req.user,
target_user_id: Object.values(createUsers) as string[],
public_api: false,
});
@@ -190,7 +190,7 @@ export function usersNamespace(this: N8nApp): void {
});
} else {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: req.user.id,
user: req.user,
message_type: 'New user invite',
public_api: false,
});
@@ -282,7 +282,8 @@ export function usersNamespace(this: N8nApp): void {
}
void InternalHooksManager.getInstance().onUserInviteEmailClick({
user_id: inviteeId,
inviter,
invitee,
});
const { firstName, lastName } = inviter;
@@ -348,7 +349,7 @@ export function usersNamespace(this: N8nApp): void {
await issueCookie(res, updatedUser);
void InternalHooksManager.getInstance().onUserSignup({
user_id: invitee.id,
user: updatedUser,
});
await this.externalHooks.run('user.profile.update', [invitee.email, sanitizeUser(invitee)]);
@@ -479,7 +480,11 @@ export function usersNamespace(this: N8nApp): void {
await transactionManager.delete(User, { id: userToDelete.id });
});
void InternalHooksManager.getInstance().onUserDeletion(req.user.id, telemetryData, false);
void InternalHooksManager.getInstance().onUserDeletion({
user: req.user,
telemetryData,
publicApi: false,
});
await this.externalHooks.run('user.deleted', [sanitizeUser(userToDelete)]);
return { success: true };
}
@@ -512,7 +517,12 @@ export function usersNamespace(this: N8nApp): void {
await transactionManager.delete(User, { id: userToDelete.id });
});
void InternalHooksManager.getInstance().onUserDeletion(req.user.id, telemetryData, false);
void InternalHooksManager.getInstance().onUserDeletion({
user: req.user,
telemetryData,
publicApi: false,
});
await this.externalHooks.run('user.deleted', [sanitizeUser(userToDelete)]);
return { success: true };
}),
@@ -570,7 +580,7 @@ export function usersNamespace(this: N8nApp): void {
if (!result?.success) {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: req.user.id,
user: reinvitee,
message_type: 'Resend invite',
public_api: false,
});
@@ -583,7 +593,7 @@ export function usersNamespace(this: N8nApp): void {
}
void InternalHooksManager.getInstance().onUserReinvite({
user_id: req.user.id,
user: reinvitee,
target_user_id: reinvitee.id,
public_api: false,
});