#Session Replay Issues: Working in Feature Environment but Failing in Production + setUser() Not Work

2 messages · Page 1 of 1 (latest)

humble granite
#

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! 🙏

tawny oak
#

i do not recall similar behaviour in the past.
i tried to reproduce the issue of the user not updating with the following steps:

  1. load the page
  2. cause an error to send the replay to sentry (using only onErrorSamplinRate)
  3. click a "login" button to add the user to SDK
  4. close the browser.
    in this scenario, the user was correctly set to my "login" user. When i do not add the user, i see the uuid from the initial scope.