@@ -242,24 +242,15 @@ public final class Clix {
242242 }
243243 }
244244
245- /// Removes the user ID (async version - recommended)
246- ///
247- /// This async version ensures the operation completes before returning.
248- /// Use this when you can await the operation in an async context.
249- ///
250- /// - Throws: ClixError if the operation fails
245+ /// Removes the user ID (async version)
246+ @available ( * , deprecated, message: " Use reset() instead " )
251247 public static func removeUserId( ) async throws {
252248 await shared. initCoordinator. waitForInitialization ( )
253249 try await shared. get ( \. deviceService) . removeProjectUserId ( )
254250 }
255251
256252 /// Removes the user ID (synchronous version)
257- ///
258- /// This synchronous version returns immediately while the operation continues in the background.
259- /// Consider using the async version for guaranteed operation completion.
260- ///
261- /// - Note: An async version is available that ensures the operation completes before returning.
262- /// Use `try await Clix.removeUserId()` for better control over operation timing.
253+ @available ( * , deprecated, message: " Use reset() instead " )
263254 public static func removeUserId( ) {
264255 Task . detached ( priority: . userInitiated) {
265256 do {
@@ -270,6 +261,31 @@ public final class Clix {
270261 }
271262 }
272263
264+ /// Resets all local SDK state including device ID.
265+ ///
266+ /// After calling this method, you must call `initialize()` again before using the SDK.
267+ /// Use this when a user logs out and you want to start fresh with a new device identity.
268+ public static func reset( ) async throws {
269+ await shared. initCoordinator. waitForInitialization ( )
270+ let notificationService = try shared. get ( \. notificationService)
271+ let storageService = try shared. get ( \. storageService)
272+ await notificationService. reset ( )
273+ await storageService. remove ( " clix_device_id " )
274+ await storageService. remove ( " clix_session_last_activity " )
275+ await shared. initCoordinator. reset ( )
276+ }
277+
278+ /// Resets all local SDK state including device ID (synchronous version)
279+ public static func reset( ) {
280+ Task . detached ( priority: . userInitiated) {
281+ do {
282+ try await reset ( )
283+ } catch {
284+ ClixLogger . error ( " Failed to reset: \( error) " )
285+ }
286+ }
287+ }
288+
273289 /// Sets a user property (async version - recommended)
274290 ///
275291 /// This async version ensures the operation completes before returning.
@@ -524,6 +540,10 @@ public final class Clix {
524540 }
525541 }
526542
543+ internal func reset( ) {
544+ isInitialized = false
545+ }
546+
527547 nonisolated internal func waitAndGet< T> ( _ getter: @escaping ( ) -> T ? ) -> T ? {
528548 let semaphore = DispatchSemaphore ( value: 0 )
529549 var result : T ?
0 commit comments