@@ -448,38 +448,36 @@ plugins.setConfigs("crashes", {
448448 }
449449 var hash = common . crypto . createHash ( 'sha1' ) . update ( seed ) . digest ( 'hex' ) ;
450450 var dbAppUser = params . app_user ;
451- if ( dbAppUser ) {
452- report . group = hash ;
453- report . uid = dbAppUser . uid ;
454- report . ts = params . time . timestamp ;
455- let updateUser = { } ;
456- if ( ! report . nonfatal ) {
457- if ( ! dbAppUser . hadFatalCrash ) {
458- updateUser . hadFatalCrash = "true" ;
459- }
460- updateUser . hadAnyFatalCrash = report . ts ;
461- }
462- else if ( report . nonfatal ) {
463- if ( ! dbAppUser . hadNonfatalCrash ) {
464- updateUser . hadNonfatalCrash = "true" ;
465- }
466- updateUser . hadAnyNonfatalCrash = report . ts ;
467- }
468- let updateData = { $inc : { } } ;
469- updateData . $inc [ "data.crashes" ] = 1 ;
470- if ( Object . keys ( updateUser ) . length ) {
471- updateData . $set = updateUser ;
451+ report . group = hash ;
452+ report . uid = dbAppUser . uid ;
453+ report . ts = params . time . timestamp ;
454+ let updateUser = { } ;
455+ if ( ! report . nonfatal ) {
456+ if ( ! dbAppUser . hadFatalCrash ) {
457+ updateUser . hadFatalCrash = "true" ;
472458 }
473- ob . updates . push ( updateData ) ;
474-
475- var set = {
476- group : hash ,
477- uid : report . uid ,
478- last : report . ts ,
479- } ;
480- if ( dbAppUser . sc ) {
481- set . sessions = dbAppUser . sc ;
459+ updateUser . hadAnyFatalCrash = report . ts ;
460+ }
461+ else if ( report . nonfatal ) {
462+ if ( ! dbAppUser . hadNonfatalCrash ) {
463+ updateUser . hadNonfatalCrash = "true" ;
482464 }
465+ updateUser . hadAnyNonfatalCrash = report . ts ;
466+ }
467+ let updateData = { $inc : { } } ;
468+ updateData . $inc [ "data.crashes" ] = 1 ;
469+ if ( Object . keys ( updateUser ) . length ) {
470+ updateData . $set = updateUser ;
471+ }
472+ ob . updates . push ( updateData ) ;
473+
474+ var set = {
475+ group : hash ,
476+ uid : report . uid ,
477+ last : report . ts ,
478+ } ;
479+ if ( dbAppUser . sc ) {
480+ set . sessions = dbAppUser . sc ;
483481 }
484482 common . db . collection ( 'app_crashusers' + params . app_id ) . findAndModify ( { group : hash , 'uid' : report . uid } , { } , { $set : set , $inc : { reports : 1 } } , { upsert : true , new : false } , function ( err , user ) {
485483 user = user && user . ok ? user . value : null ;
0 commit comments