Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing event regarding failed emails #2964

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/cli/src/InternalHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,14 @@ export class InternalHooksClass implements IInternalHooksClass {
async onUserSignup(userSignupData: { user_id: string }): Promise<void> {
return this.telemetry.track('User signed up', userSignupData);
}

async onEmailFailed(failedEmailData: {
user_id: string;
message_type: 'Reset password' | 'New user invite' | 'Resend invite';
}): Promise<void> {
return this.telemetry.track(
'Instance failed to send transactional email to user',
failedEmailData,
);
}
}
4 changes: 4 additions & 0 deletions packages/cli/src/UserManagement/routes/passwordReset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export function passwordResetNamespace(this: N8nApp): void {
domain: baseUrl,
});
} catch (error) {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: user.id,
message_type: 'Reset password',
});
if (error instanceof Error) {
throw new ResponseHelper.ResponseError(
`Please contact your administrator: ${error.message}`,
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/UserManagement/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ export function usersNamespace(this: N8nApp): void {
message_type: 'New user invite',
});
} else {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: req.user.id,
message_type: 'New user invite',
});
Logger.error('Failed to send email', {
userId: req.user.id,
inviteAcceptUrl,
Expand Down Expand Up @@ -530,6 +534,10 @@ export function usersNamespace(this: N8nApp): void {
});

if (!result?.success) {
void InternalHooksManager.getInstance().onEmailFailed({
user_id: req.user.id,
message_type: 'Resend invite',
});
Logger.error('Failed to send email', {
email: reinvitee.email,
inviteAcceptUrl,
Expand Down