@@ -137,13 +137,6 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
137
137
let merge = identityResolution? . mergeOnAnonymousToKnown ?? config. identityResolution. mergeOnAnonymousToKnown
138
138
let replay = identityResolution? . replayOnVisitorToKnown ?? config. identityResolution. replayOnVisitorToKnown
139
139
140
- if ( config. enableAnonTracking) {
141
- if ( email != nil ) {
142
- attemptAndProcessMerge ( merge: merge ?? true , replay: replay ?? true , destinationUser: email, isEmail: true , failureHandler: failureHandler)
143
- }
144
- self . localStorage. userIdAnnon = nil
145
- }
146
-
147
140
if self . _email == email && email != nil {
148
141
self . checkAndUpdateAuthToken ( authToken)
149
142
return
@@ -158,6 +151,13 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
158
151
self . _email = email
159
152
self . _userId = nil
160
153
154
+ if ( config. enableAnonTracking) {
155
+ if ( email != nil ) {
156
+ attemptAndProcessMerge ( merge: merge ?? true , replay: replay ?? true , destinationUser: email, isEmail: true , failureHandler: failureHandler)
157
+ }
158
+ self . localStorage. userIdAnnon = nil
159
+ }
160
+
161
161
self . _successCallback = successHandler
162
162
self . _failureCallback = failureHandler
163
163
self . storeIdentifierData ( )
@@ -171,16 +171,6 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
171
171
let merge = identityResolution? . mergeOnAnonymousToKnown ?? config. identityResolution. mergeOnAnonymousToKnown
172
172
let replay = identityResolution? . replayOnVisitorToKnown ?? config. identityResolution. replayOnVisitorToKnown
173
173
174
- if ( config. enableAnonTracking) {
175
- if ( userId != nil && userId != localStorage. userIdAnnon) {
176
- attemptAndProcessMerge ( merge: merge ?? true , replay: replay ?? true , destinationUser: userId, isEmail: false , failureHandler: failureHandler)
177
- }
178
-
179
- if ( !isAnon) {
180
- self . localStorage. userIdAnnon = nil
181
- }
182
- }
183
-
184
174
if self . _userId == userId && userId != nil {
185
175
self . checkAndUpdateAuthToken ( authToken)
186
176
return
@@ -195,6 +185,16 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
195
185
self . _email = nil
196
186
self . _userId = userId
197
187
188
+ if ( config. enableAnonTracking) {
189
+ if ( userId != nil && userId != localStorage. userIdAnnon) {
190
+ attemptAndProcessMerge ( merge: merge ?? true , replay: replay ?? true , destinationUser: userId, isEmail: false , failureHandler: failureHandler)
191
+ }
192
+
193
+ if ( !isAnon) {
194
+ self . localStorage. userIdAnnon = nil
195
+ }
196
+ }
197
+
198
198
self . _successCallback = successHandler
199
199
self . _failureCallback = failureHandler
200
200
self . storeIdentifierData ( )
@@ -210,7 +210,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
210
210
211
211
if mergeResult == MergeResult . mergenotrequired || mergeResult == MergeResult . mergesuccessful {
212
212
if ( replay) {
213
- self . anonymousUserManager. syncNonSyncedEvents ( )
213
+ self . anonymousUserManager. syncEvents ( )
214
214
}
215
215
} else {
216
216
failureHandler ? ( error, nil )
0 commit comments