Smartlook records user interactions sessions. Every session has a single user and a single user can have multiple sessions. For more information on users, see Life Cycle, Session, User.
User identifier
To specify the user identifier:
Smartlook.instance.user.identifier = "sample-identifier"
Identifier restrictions
- Cannot be null or empty
- Maximum length is 120 characters.
User name and email
The name
and email
properties can be directly set using:
Smartlook.instance.user.name = "John Doe"
Smartlook.instance.user.email = "[email protected]"
Both
user.name
anduser.email
act as an alias. They are added to user properties under thename
and
User properties
User properties can be added using a subscript or method:
Smartlook.instance.user["level"] = "Expert"
Smartlook.instance.user.setProperty("level", to: "Expert")
Opening a new user
The current user can be closed and a new user opened:
Smartlook.instance.user.openNew()
New user session
Opening a new user opens a new session. For more information on user sessions, see Lifecycle, Session, User.
User URL
The URL
of the currently recorded user can be obtained:
let userURL = Smartlook.instance.user.url
Nullability and shareability
The
URL
is only available when the SDK was able to communicate with the Smartlook backend. Otherwise, it isnull
.The
URL
is not publicly sharable. You must log in to the dashboard.
User Notification
A notification can be observed to listen to the user URL changes.
NotificationCenter.default.addObserver(forName: User.urlDidChangeNotification, object: nil, queue: nil) { note in
// Called when session URL changes
}