@@ -137,6 +137,7 @@ const Flagsmith = class {
137137 } ;
138138 if ( identifier ) {
139139 this . evaluationContext . identity . identifier = identifier ;
140+ this . identity = identifier ;
140141 }
141142 }
142143 this . flags = flags ;
@@ -277,6 +278,7 @@ const Flagsmith = class {
277278 flags :IFlags | null = null
278279 getFlagInterval : NodeJS . Timer | null = null
279280 headers ?: object | null = null
281+ identity :string | null | undefined = null
280282 initialised = false
281283 oldFlags :IFlags | null = null
282284 onChange :IInitConfig [ 'onChange' ] | null = null
@@ -439,7 +441,7 @@ const Flagsmith = class {
439441 const onRetrievedStorage = async ( error : Error | null , res : string | null ) => {
440442 if ( res ) {
441443 let flagsChanged = null
442- let traitsChanged = null
444+ const traitsChanged = null
443445 try {
444446 const json = JSON . parse ( res ) as IState ;
445447 let cachePopulated = false ;
@@ -563,6 +565,7 @@ const Flagsmith = class {
563565 }
564566
565567 identify ( userId ?: string | null , traits ?: ITraits , transient ?: boolean ) {
568+ this . identity = userId
566569 this . evaluationContext . identity = {
567570 identifier : userId ,
568571 transient : transient ,
@@ -591,6 +594,7 @@ const Flagsmith = class {
591594 flags : this . flags ,
592595 ts : this . ts ,
593596 evaluationContext : this . evaluationContext ,
597+ identity : this . identity ,
594598 evaluationEvent : this . evaluationEvent ,
595599 } as IState
596600 }
@@ -602,11 +606,13 @@ const Flagsmith = class {
602606 this . flags = state . flags || this . flags ;
603607 this . evaluationContext = state . evaluationContext || this . evaluationContext ,
604608 this . evaluationEvent = state . evaluationEvent || this . evaluationEvent ;
609+ this . identity = this . getContext ( ) ?. identity ?. identifier
605610 this . log ( "setState called" , this )
606611 }
607612 }
608613
609614 logout ( ) {
615+ this . identity = null
610616 this . evaluationContext . identity = null ;
611617 if ( this . initialised ) {
612618 return this . getFlags ( ) ;
@@ -676,6 +682,7 @@ const Flagsmith = class {
676682 ...evaluationContext ,
677683 environment : evaluationContext . environment || this . evaluationContext . environment ,
678684 } ;
685+ this . identity = this . getContext ( ) ?. identity ?. identifier
679686
680687 if ( this . initialised ) {
681688 return this . getFlags ( ) ;
0 commit comments