diff --git a/packages/cli/src/InternalHooks.ts b/packages/cli/src/InternalHooks.ts index b093b93485215..55a39ed88d08a 100644 --- a/packages/cli/src/InternalHooks.ts +++ b/packages/cli/src/InternalHooks.ts @@ -262,4 +262,14 @@ export class InternalHooksClass implements IInternalHooksClass { async onUserSignup(userSignupData: { user_id: string }): Promise { return this.telemetry.track('User signed up', userSignupData); } + + async onEmailFailed(failedEmailData: { + user_id: string; + message_type: 'Reset password' | 'New user invite' | 'Resend invite'; + }): Promise { + return this.telemetry.track( + 'Instance failed to send transactional email to user', + failedEmailData, + ); + } } diff --git a/packages/cli/src/UserManagement/routes/passwordReset.ts b/packages/cli/src/UserManagement/routes/passwordReset.ts index 7dbb630283d30..4ac00e2cc234e 100644 --- a/packages/cli/src/UserManagement/routes/passwordReset.ts +++ b/packages/cli/src/UserManagement/routes/passwordReset.ts @@ -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}`, diff --git a/packages/cli/src/UserManagement/routes/users.ts b/packages/cli/src/UserManagement/routes/users.ts index 8391c90e1491b..85dad09dccaae 100644 --- a/packages/cli/src/UserManagement/routes/users.ts +++ b/packages/cli/src/UserManagement/routes/users.ts @@ -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, @@ -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,