Typically a web application will have different views and behavior for different users. A basic user might have a different view than a power user or a system administrator. To be able to reproduce a bug that is specific to a certain user type (or user), the session should be replayed in the same context. More specifically this means we need a way to authenticate as different users before replaying a session. When opening a Root Cause session relating to an error on a page within the application, the app will first redirect you to the login page in the Replay Studio:

Since most likely you’re not recording the user’s login details (strongly discouraged), you can’t simply hit replay in the Replay Studio. First you need to put the application in the same mode as the user , i.e. you need to impersonate the user.

Impersonating a user

The easiest way to be able to debug the application error is to build a simple impersonation mechanism. To do this, we can add a simple environment variable for our localhost environment only. In your localhost, add a new variable to your .htaccess file (for Apache servers).

In our localhost server code handling the login, we could then bypass the password check whenever this flag is set. Simple PHP sample below:

For Microsoft ASP.NET applications, please see this support article on impersonation.

The approach above will allow the developer doing the troubleshooting to login as any user in the system. Of course this code should not ever exist in the production version, but only for debugging purposes on a developer machine targeting a testing / non-production database.

Replaying a session on your localhost

To replay an error on a different environment, you should first define your environments in the RootCause dashboard application. Open the settings page for your application and scroll down to the Environments section

After setting up your environments, you can now replay the error on different URLs. Just use the environment picker in the top right toolbar:

We hope you’ll find these tricks useful when debugging your user sessions. Happy impersonating!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">