mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
fix(core): Fix handling of common events for relays (#10135)
This commit is contained in:
parent
f2ad1222b1
commit
d2a3a4a080
|
@ -38,8 +38,8 @@ export class AuditEventRelay {
|
||||||
this.eventService.on('user-password-reset-request-click', (event) =>
|
this.eventService.on('user-password-reset-request-click', (event) =>
|
||||||
this.userPasswordResetRequestClick(event),
|
this.userPasswordResetRequestClick(event),
|
||||||
);
|
);
|
||||||
this.eventService.on('public-api-key-created', (event) => this.apiKeyCreated(event));
|
this.eventService.on('public-api-key-created', (event) => this.publicApiKeyCreated(event));
|
||||||
this.eventService.on('public-api-key-deleted', (event) => this.apiKeyDeleted(event));
|
this.eventService.on('public-api-key-deleted', (event) => this.publicApiKeyDeleted(event));
|
||||||
this.eventService.on('email-failed', (event) => this.emailFailed(event));
|
this.eventService.on('email-failed', (event) => this.emailFailed(event));
|
||||||
this.eventService.on('credentials-created', (event) => this.credentialsCreated(event));
|
this.eventService.on('credentials-created', (event) => this.credentialsCreated(event));
|
||||||
this.eventService.on('credentials-deleted', (event) => this.credentialsDeleted(event));
|
this.eventService.on('credentials-deleted', (event) => this.credentialsDeleted(event));
|
||||||
|
@ -257,22 +257,18 @@ export class AuditEventRelay {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Redactable()
|
@Redactable()
|
||||||
private apiKeyCreated(event: Event['public-api-key-created']) {
|
private publicApiKeyCreated({ user }: Event['public-api-key-created']) {
|
||||||
if ('publicApi' in event) return;
|
|
||||||
|
|
||||||
void this.eventBus.sendAuditEvent({
|
void this.eventBus.sendAuditEvent({
|
||||||
eventName: 'n8n.audit.user.api.created',
|
eventName: 'n8n.audit.user.api.created',
|
||||||
payload: event.user,
|
payload: user,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redactable()
|
@Redactable()
|
||||||
private apiKeyDeleted(event: Event['public-api-key-deleted']) {
|
private publicApiKeyDeleted({ user }: Event['public-api-key-deleted']) {
|
||||||
if ('publicApi' in event) return;
|
|
||||||
|
|
||||||
void this.eventBus.sendAuditEvent({
|
void this.eventBus.sendAuditEvent({
|
||||||
eventName: 'n8n.audit.user.api.deleted',
|
eventName: 'n8n.audit.user.api.deleted',
|
||||||
payload: event.user,
|
payload: user,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,14 +112,6 @@ export type Event = {
|
||||||
apiVersion: string;
|
apiVersion: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
'public-api-key-created':
|
|
||||||
| { user: UserLike } // audit
|
|
||||||
| { user: UserLike; publicApi: boolean }; // telemetry
|
|
||||||
|
|
||||||
'public-api-key-deleted':
|
|
||||||
| { user: UserLike } // audit
|
|
||||||
| { user: UserLike; publicApi: boolean }; // telemetry
|
|
||||||
|
|
||||||
'email-failed': {
|
'email-failed': {
|
||||||
user: UserLike;
|
user: UserLike;
|
||||||
messageType:
|
messageType:
|
||||||
|
@ -275,4 +267,18 @@ export type Event = {
|
||||||
isNew: boolean;
|
isNew: boolean;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Events listened to by more than one relay
|
||||||
|
*/
|
||||||
|
|
||||||
|
'public-api-key-created': {
|
||||||
|
user: UserLike; // audit and telemetry
|
||||||
|
publicApi: boolean; // telemetry only
|
||||||
|
};
|
||||||
|
|
||||||
|
'public-api-key-deleted': {
|
||||||
|
user: UserLike; // audit and telemetry
|
||||||
|
publicApi: boolean; // telemetry only
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -219,8 +219,6 @@ export class TelemetryEventRelay {
|
||||||
}
|
}
|
||||||
|
|
||||||
private publicApiKeyCreated(event: Event['public-api-key-created']) {
|
private publicApiKeyCreated(event: Event['public-api-key-created']) {
|
||||||
if (!('publicApi' in event)) return;
|
|
||||||
|
|
||||||
const { user, publicApi } = event;
|
const { user, publicApi } = event;
|
||||||
|
|
||||||
void this.telemetry.track('API key created', {
|
void this.telemetry.track('API key created', {
|
||||||
|
@ -230,8 +228,6 @@ export class TelemetryEventRelay {
|
||||||
}
|
}
|
||||||
|
|
||||||
private publicApiKeyDeleted(event: Event['public-api-key-deleted']) {
|
private publicApiKeyDeleted(event: Event['public-api-key-deleted']) {
|
||||||
if (!('publicApi' in event)) return;
|
|
||||||
|
|
||||||
const { user, publicApi } = event;
|
const { user, publicApi } = event;
|
||||||
|
|
||||||
void this.telemetry.track('API key deleted', {
|
void this.telemetry.track('API key deleted', {
|
||||||
|
|
Loading…
Reference in a new issue