@@ -421,6 +421,9 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
421
421
const user = this . checkUser ( "updateLoggedInUser" ) ;
422
422
await this . guardAccess ( { kind : "user" , subject : user } , "update" ) ;
423
423
424
+ //hang on to user profile before it's overwritten for analytics below
425
+ const oldProfile = { name : user . fullName , ...user . additionalData ?. profile } ;
426
+
424
427
const allowedFields : ( keyof User ) [ ] = [ "avatarUrl" , "fullName" , "additionalData" ] ;
425
428
for ( const p of allowedFields ) {
426
429
if ( p in partialUser ) {
@@ -429,6 +432,28 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
429
432
}
430
433
431
434
await this . userDB . updateUserPartial ( user ) ;
435
+
436
+ //track event and user profile if profile of partialUser changed
437
+ const newProfile = { name : partialUser . fullName , ...partialUser . additionalData ?. profile } ;
438
+ if ( newProfile ) {
439
+ if (
440
+ ! oldProfile ||
441
+ newProfile . emailAddress != oldProfile . emailAddress ||
442
+ newProfile . companyName != oldProfile . companyName ||
443
+ newProfile . name != oldProfile . name
444
+ ) {
445
+ this . analytics . track ( {
446
+ userId : user . id ,
447
+ event : "profile_changed" ,
448
+ properties : { new : newProfile , old : oldProfile } ,
449
+ } ) ;
450
+ this . analytics . identify ( {
451
+ userId : user . id ,
452
+ traits : { email : newProfile . emailAddress , company : newProfile . companyName , name : newProfile . name } ,
453
+ } ) ;
454
+ }
455
+ }
456
+
432
457
return user ;
433
458
}
434
459
0 commit comments