Skip to content

Commit e0612cc

Browse files
author
Evan Greer
committed
updates replay to call syncEvents directly
1 parent 0561323 commit e0612cc

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

swift-sdk/Internal/AnonymousUserManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public class AnonymousUserManager: AnonymousUserManagerProtocol {
143143
}
144144

145145
// Syncs locally saved data through track APIs
146-
private func syncEvents() {
146+
public func syncEvents() {
147147
let events = localStorage.anonymousUserEvents
148148
var successfulSyncedData: [Int] = []
149149

swift-sdk/Internal/AnonymousUserManagerProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ import Foundation
1313
func trackAnonUpdateUser(_ dataFields: [AnyHashable: Any])
1414
func updateAnonSession()
1515
func getAnonCriteria()
16-
func syncNonSyncedEvents()
16+
func syncEvents()
1717
}

swift-sdk/Internal/InternalIterableAPI.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
137137
let merge = identityResolution?.mergeOnAnonymousToKnown ?? config.identityResolution.mergeOnAnonymousToKnown
138138
let replay = identityResolution?.replayOnVisitorToKnown ?? config.identityResolution.replayOnVisitorToKnown
139139

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-
147140
if self._email == email && email != nil {
148141
self.checkAndUpdateAuthToken(authToken)
149142
return
@@ -158,6 +151,13 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
158151
self._email = email
159152
self._userId = nil
160153

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+
161161
self._successCallback = successHandler
162162
self._failureCallback = failureHandler
163163
self.storeIdentifierData()
@@ -171,16 +171,6 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
171171
let merge = identityResolution?.mergeOnAnonymousToKnown ?? config.identityResolution.mergeOnAnonymousToKnown
172172
let replay = identityResolution?.replayOnVisitorToKnown ?? config.identityResolution.replayOnVisitorToKnown
173173

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-
184174
if self._userId == userId && userId != nil {
185175
self.checkAndUpdateAuthToken(authToken)
186176
return
@@ -195,6 +185,16 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
195185
self._email = nil
196186
self._userId = userId
197187

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+
198198
self._successCallback = successHandler
199199
self._failureCallback = failureHandler
200200
self.storeIdentifierData()
@@ -210,7 +210,7 @@ final class InternalIterableAPI: NSObject, PushTrackerProtocol, AuthProvider {
210210

211211
if mergeResult == MergeResult.mergenotrequired || mergeResult == MergeResult.mergesuccessful {
212212
if (replay) {
213-
self.anonymousUserManager.syncNonSyncedEvents()
213+
self.anonymousUserManager.syncEvents()
214214
}
215215
} else {
216216
failureHandler?(error, nil)

0 commit comments

Comments
 (0)