CLASS
UserProvider
public class UserProvider: UserProviderProtocol
Provides user information and manages user sessions
Methods
init(storage:userId:sessionParams:)
public init(storage: StorageFacadeProtocol, userId: String, sessionParams: SessionParams)
Initialize user provider - Parameters: - storage: Storage facade for persistence - userId: Unique user identifier - sessionParams: Session parameters for the user
Parameters
| Name | Description |
|---|---|
| storage | Storage facade for persistence |
| userId | Unique user identifier |
| sessionParams | Session parameters for the user |
getUser()
public func getUser() -> User
Get the current user - Returns: The current user object
getUserHash()
public func getUserHash() -> String
Get the user hash for bucketing - Returns: The user hash string
isSessionStarted()
public func isSessionStarted() -> Bool
Check if user session is started and valid - Returns: True if session is active
startSession(_:)
public func startSession(_ timeout: TimeInterval) -> Bool
Start a new user session - Parameter timeout: Session timeout in seconds - Returns: True if session was started successfully
Parameters
| Name | Description |
|---|---|
| timeout | Session timeout in seconds |
updateSessionActivity()
public func updateSessionActivity() -> Bool
Update session activity timestamp - Returns: True if activity was updated successfully
updateSessionParams(_:)
public func updateSessionParams(_ newParams: SessionParams)
Update session parameters - Parameter newParams: New session parameters
Parameters
| Name | Description |
|---|---|
| newParams | New session parameters |
incrementPageviews()
public func incrementPageviews()
Increment pageview count
getSessionTimeout()
public func getSessionTimeout() -> TimeInterval?
Get session timeout for current user - Returns: Session timeout in seconds, or nil if not set