Getting user context for error handling

How can I get info about where the user is (what page, what action, what method, etc for the purpose of error logging?
At a minimum, user info, page they’re on, error details and what method (if user written) is what I’m looking for here…

The page is pretty straightforward. You can just access window.location.href and that should give you the full path that the user is on. This will include path parameters like id and query parameters as well. These are more specific than just knowing the page.

For which method they are in, you could use debug.namespace. That variable contains :. You would have to pass that in to whatever API you are using to log the error.

Thanks.
Can you remind me how to access the current username?
And if there’s an error happening (say where in a try catch), how do I get the stack trace and any other specific things of interest?

To access the current user, add the AuthService to your user interface as a dependency and then you can get the user like this:

const currentUser = await this.authService.currentAppUser();

Sorry - I forgot to answer your question about stack trace. I am doing some research on using a global error handler in Angular and will get back to you on this.