Set or update the current user identifier for Wingify Insights. - Available from SDK version 2.2.0
VWOInsights.setUserId switches identity when the logged-in user changes in the same process. Call it only after VWOInsights.init has completed successfully.
Signature
fun setUserId(userId: String, initCallBack: IVwoInitCallback?): Booleanpublic static boolean setUserId(String userId, IVwoInitCallback initCallBack)Parameters
userId— Non-blank string. Blank values returnfalse.initCallBack— Optional. Invoked when configuration refresh finishes after the switch (vwoInitSuccess/vwoInitFailed), similar to init.
Returns
true— Request accepted locally; refresh started.false— Rejected (blankuserId, or SDK not initialized).
Behavior
- Stops the current recording/session for the previous user.
- Updates client identity and refreshes server configuration for the new
userId. - If recording was active before the switch, it automatically resumes after configuration refresh completes. If recording was stopped, it remains stopped.
import com.vwo.insights.VWOInsights
import com.vwo.insights.exposed.IVwoInitCallback
val accepted = VWOInsights.setUserId("user-123", object : IVwoInitCallback {
override fun vwoInitSuccess(message: String) {
// User switch complete
}
override fun vwoInitFailed(message: String) {
// Handle failure
}
})import com.vwo.insights.VWOInsights;
import com.vwo.insights.exposed.IVwoInitCallback;
boolean accepted = VWOInsights.setUserId("user-123", new IVwoInitCallback() {
@Override
public void vwoInitSuccess(String message) {
// User switch complete
}
@Override
public void vwoInitFailed(String message) {
// Handle failure
}
});