mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
Merge remote-tracking branch 'origin/main' into vaxi/mobile-sdk-sonar-fixes
This commit is contained in:
@@ -17,10 +17,10 @@ struct SetupView: View {
|
||||
let config = FormbricksConfig.Builder(appUrl: "[appUrl]", environmentId: "[environmentId]")
|
||||
.setLogLevel(.debug)
|
||||
.build()
|
||||
|
||||
// Simulate async setup delay
|
||||
DispatchQueue.global().async {
|
||||
Formbricks.setup(with: config)
|
||||
Formbricks.setUserId(UUID().uuidString)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
isSetup = true
|
||||
@@ -31,6 +31,10 @@ struct SetupView: View {
|
||||
.padding()
|
||||
}
|
||||
} else {
|
||||
Button("Call Formbricks.setUserId with a random userId") {
|
||||
Formbricks.setUserId(UUID().uuidString)
|
||||
}.padding()
|
||||
|
||||
Button("Call Formbricks.track") {
|
||||
Formbricks.track("click_demo_button")
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ import Network
|
||||
if let userId = config.userId {
|
||||
userManager?.set(userId: userId)
|
||||
}
|
||||
if let attributes = config.attributes {
|
||||
if let attributes = config.attributes, !attributes.isEmpty {
|
||||
userManager?.set(attributes: attributes)
|
||||
}
|
||||
if let language = config.attributes?["language"] {
|
||||
|
||||
@@ -106,6 +106,14 @@ final class UserManager: UserManagerSyncable {
|
||||
|
||||
/// Logs out the user and clears the user state.
|
||||
func logout() {
|
||||
var isUserIdDefined = false
|
||||
|
||||
if userId != nil {
|
||||
isUserIdDefined = true
|
||||
} else {
|
||||
Formbricks.logger?.error("no userId is set, please set a userId first using the setUserId function")
|
||||
}
|
||||
|
||||
UserDefaults.standard.removeObject(forKey: UserManager.userIdKey)
|
||||
UserDefaults.standard.removeObject(forKey: UserManager.contactIdKey)
|
||||
UserDefaults.standard.removeObject(forKey: UserManager.segmentsKey)
|
||||
@@ -122,7 +130,10 @@ final class UserManager: UserManagerSyncable {
|
||||
backingExpiresAt = nil
|
||||
updateQueue?.reset()
|
||||
|
||||
Formbricks.logger?.debug("Successfully logged out user and reset the user state.")
|
||||
if isUserIdDefined {
|
||||
Formbricks.logger?.debug("Successfully logged out user and reset the user state.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func cleanupUpdateQueue() {
|
||||
|
||||
Reference in New Issue
Block a user