UserInfo
File: user-info.interface.ts
Introduction
The UserInfo
interface is part of the error-enhanced
library and focuses on capturing user-specific data related to an error event. This can include session IDs, user roles, authentication tokens, and more. Having this level of user-specific detail aids in debugging and helps in resolving user-specific issues more efficiently.
Properties
Property | Type | Description |
---|---|---|
|
| A read-only property indicating the user's session ID. |
|
| A read-only array of roles associated with the user. |
|
| A read-only property for the authentication token. |
|
| A read-only property for the user's IP address. |
|
| A read-only property for the user's agent, usually a browser. |
|
| A read-only array capturing a history of user actions leading up to the error. |
Methods
Method | Return Type | Description |
---|---|---|
|
| Sets the user identifier. Allows for method chaining. |
|
| Sets the session ID. Allows for method chaining. |
|
| Sets the user roles. Allows for method chaining. |
|
| Sets the authentication token. Allows for method chaining. |
|
| Sets the user's IP address. Allows for method chaining. |
|
| Sets the user agent. Allows for method chaining. |
|
| Adds an action to the user's action history. Allows for method chaining. |
Example Usage
Best Practices
Always set user-related properties as soon as the error is captured for more accurate debugging.
Use
addActionToHistory
to maintain a running log of user actions leading up to an error, which can be invaluable for debugging.
Conclusion
The UserInfo
interface provides a structured way to capture user-specific details when an error occurs. This facilitates debugging and issue resolution, making it an indispensable part of your error management strategy.