Hey everyone! I'm dealing with some confusing Sentry session replay behavior that's different between environments, plus a setUser() issue affecting both. Would really appreciate any insights!
🔧 Setup:
Self-hosted Sentry server
Session replays configured with anonymous user tracking
Users log in and we call Sentry.setUser() to update the user ID
📊 Current Behavior:
Feature Environment (✅ Working Replays, ❌ setUser Issue):
Replays work perfectly: 5-42 minutes long, full of data
Can see dead clicks, rage clicks, errors, high activity
Everything is being recorded properly, can watch full user sessions
❌ BUT: Sentry.setUser() after login doesn't update the session - all sessions still show the initial anonymous UUID instead of the real user ID
Production Environment (❌ Multiple Issues):
❌ Most replays only last 5-7 seconds, some ~20 seconds
❌ Replays typically end right at/after login screen
❌ Not capturing the actual application usage
❌ In longer replays, can see user dashboard loading but replay ends there
❌ Same setUser() issue - user ID never gets attached to sessions
⚙️ Config:
Only differences between environments are:
Sentry org/project IDs
Self-hosted server URLs
Otherwise nearly identical code
🤔 Questions:
Why would session replays end immediately after login in production but work fine in feature environment?
Why isn't Sentry.setUser() updating the session's user ID in either environment?
Could there be something about the login flow that's terminating replays in production?
Any configuration differences I should check between environments?
Current initialScope:
initialScope: {
user: {
id: uuid() // Anonymous ID until login
}
}
Login flow:
Sentry.setUser({
id: loginResponse.user.id
});
Has anyone seen similar behavior where replays work in one environment but terminate early in another? Or issues with setUser() not updating existing sessions?
Any help would be hugely appreciated! 🙏