You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please link to related issues when possible, and explain WHY you changed things, not WHAT you changed.
Other information:
eg: Did you discuss this change with anybody before working on it (not required, but can be a good idea for bigger changes). Any plans for the future, etc?
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
I checked that there were not similar issues or PRs already open for this.
This PR fixes just ONE issue (do not include multiple issues or types of change in the same PR) For example, don't try and fix a UI issue and include new dependencies in the same PR.
PR Type
Enhancement
Description
Add APM error capturing to login process
Capture provider, redirect, IP, user agent context
Gracefully handle APM failures without affecting flow
Diagram Walkthrough
flowchart LR
A["Login Error Caught"] --> B["Capture Error via APM"]
B --> C["Include Context Data"]
C --> D["Handle APM Failures"]
D --> E["Continue Redirect Flow"]
Loading
File Walkthrough
Relevant files
Enhancement
auth.controller.ts
Add APM error capturing with context metadata
apps/backend/src/api/routes/auth.controller.ts
Wrap error handling in try-catch block to capture errors via APM
Include contextual metadata: provider, redirect URL, IP, user agent, token status
Gracefully handle APM module failures to preserve existing redirect behavior
Use optional chaining to safely call APM captureError method
Below is a summary of compliance checks for this PR:
Security Compliance
⚪
Sensitive data logging
Description: The new APM error reporting sends potentially sensitive user data (e.g., ip, userAgent, redirect, and provider) as custom metadata, which can lead to privacy/PII exposure in third-party observability systems and logs if not explicitly minimized, redacted, or covered by retention/access controls. auth.controller.ts [389-402]
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive information like PII, PHI, or cardholder data.
Status: PII in APM: The new APM error capture attaches ip and userAgent (and potentially redirect) as custom metadata, which can constitute sensitive/PII telemetry and violates secure logging constraints unless explicitly approved/redacted.
Objective: To create a detailed and reliable record of critical system actions for security analysis and compliance.
Status: Missing audit context: The newly added APM capture records an error but does not clearly provide an auditable login-event record with a user identifier and explicit outcome, so it is unclear if login failures are fully traceable per audit requirements.
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful degradation
Status: Swallowed APM errors: The added nested try/catch intentionally ignores APM/reporting failures without any fallback logging, which may reduce diagnosability depending on operational requirements.
Move the dynamic require('../../apm.init') call out of the catch block and preload it at the module scope to prevent repeated, inefficient filesystem lookups on each error.
Why: This is a valid suggestion for performance and code structure. Requiring the module on every error is inefficient, and loading it once at the module or class level is a better practice.
Low
Remove redundant type check
Remove the redundant typeof provider === 'string' check, as provider is already typed as a string, and directly use provider.toUpperCase().
Why: The suggestion correctly identifies a redundant type check for the provider variable, which is already typed as a string. Removing it simplifies the code and improves readability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
What kind of change does this PR introduce?
eg: Bug fix, feature, docs update, ...
Why was this change needed?
Please link to related issues when possible, and explain WHY you changed things, not WHAT you changed.
Other information:
eg: Did you discuss this change with anybody before working on it (not required, but can be a good idea for bigger changes). Any plans for the future, etc?
Checklist:
Put a "X" in the boxes below to indicate you have followed the checklist;
PR Type
Enhancement
Description
Add APM error capturing to login process
Capture provider, redirect, IP, user agent context
Gracefully handle APM failures without affecting flow
Diagram Walkthrough
File Walkthrough
auth.controller.ts
Add APM error capturing with context metadataapps/backend/src/api/routes/auth.controller.ts
token status
behavior