fix(core): Fix user telemetry bugs (#10293)

This commit is contained in:
Iván Ovejero
2024-08-05 13:24:26 +02:00
committed by GitHub
parent 7fb3f62a36
commit 42a0b594d6
4 changed files with 64 additions and 3 deletions

View File

@@ -89,6 +89,7 @@ export class MeController {
await this.externalHooks.run('user.profile.beforeUpdate', [userId, currentEmail, payload]);
const preUpdateUser = await this.userRepository.findOneByOrFail({ id: userId });
await this.userService.update(userId, payload);
const user = await this.userRepository.findOneOrFail({
where: { id: userId },
@@ -98,7 +99,10 @@ export class MeController {
this.authService.issueCookie(res, user, req.browserId);
const fieldsChanged = Object.keys(payload);
const fieldsChanged = (Object.keys(payload) as Array<keyof UserUpdatePayload>).filter(
(key) => payload[key] !== preUpdateUser[key],
);
this.eventService.emit('user-updated', { user, fieldsChanged });
const publicUser = await this.userService.toPublic(user);