File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
packages/core/src/storage Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -61,11 +61,31 @@ export class SovranStorage implements Storage {
61
61
this . userInfoStore = createStore (
62
62
{ userInfo : INITIAL_VALUES . userInfo } ,
63
63
{
64
- persist : { storeId : `${ this . storeId } -userInfo` } ,
64
+ persist : {
65
+ storeId : `${ this . storeId } -userInfo` ,
66
+ } ,
65
67
}
66
68
) ;
69
+
70
+ this . fixAnonymousId ( ) ;
67
71
}
68
72
73
+ /**
74
+ * This is a fix for users that have started the app with the anonymousId set to 'anonymousId' bug
75
+ */
76
+ private fixAnonymousId = ( ) => {
77
+ const fixUnsubscribe = this . userInfoStore . subscribe ( ( store ) => {
78
+ if ( store . userInfo . anonymousId === 'anonymousId' ) {
79
+ this . userInfoStore . dispatch ( ( state ) => {
80
+ return {
81
+ userInfo : { ...state . userInfo , anonymousId : getUUID ( ) } ,
82
+ } ;
83
+ } ) ;
84
+ }
85
+ fixUnsubscribe ( ) ;
86
+ } ) ;
87
+ } ;
88
+
69
89
readonly isReady = {
70
90
get : ( ) => true ,
71
91
onChange : ( _callback : ( value : boolean ) => void ) => {
@@ -119,6 +139,7 @@ export class SovranStorage implements Storage {
119
139
} ) ;
120
140
} ,
121
141
} ;
142
+
122
143
readonly userInfo = {
123
144
get : ( ) => this . userInfoStore . getState ( ) . userInfo ,
124
145
onChange : ( callback : ( value : UserInfoState ) => void ) =>
You can’t perform that action at this time.
0 commit comments