setUser method
Set user context (call after user logs in)
Implementation
void setUser({required String userId, String? userName, String? userEmail}) {
if (!_initialized) {
if (_enableDebugLogs) {
print(
'Telling SDK not initialized. Call Telling.instance.init() first.',
);
}
return;
}
_userId = userId;
_userName = userName;
_userEmail = userEmail;
// Start a new session with the updated user context
_endSession();
_startNewSession();
if (_enableDebugLogs) {
print('Telling: User context updated - $userId');
}
// Log the user identification event
log(
'User identified',
level: LogLevel.info,
type: LogType.analytics,
metadata: {
'userId': userId,
if (userName != null) 'userName': userName,
if (userEmail != null) 'userEmail': userEmail,
},
);
}