-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Added the sentry to trace issues #3368
Conversation
WalkthroughWhistle Listen up, coding universe! 💥 We've just supercharged our error handling like a true superstar! Two components - Changes
Sequence DiagramsequenceDiagram
participant User
participant Component
participant CameraService
participant Sentry
User->>Component: Trigger Action
Component->>CameraService: Start Preview
alt Preview Successful
CameraService-->>Component: Success
else Preview Fails
CameraService-->>Component: Error
Component->>Sentry: Log Detailed Error
Sentry-->>Component: Acknowledgement
end
Poem
Drops mic 🎤 Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts (1)
Line range hint
85-113
: Style-ah style-ah! Let's make this error handling even more powerful!The error tracking is good, but we can make it better by structuring the error context more carefully.
Consider this enhancement:
error: (error) => { Sentry.captureException(error, { extra: { - errorResponse: error, + errorType: error.name, + errorMessage: error.message, currentCameraState, cameraState: this.cameraState, navigationState: window.location.href, options: cameraPreviewOptions, platform: this.devicePlatform, + deviceCapabilities: { + hasCamera: 'mediaDevices' in navigator, + hasFlash: 'ImageCapture' in window + }, timestamp: new Date().toISOString(), }, }); },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/app/fyle/my-view-report/my-view-report.page.ts
(2 hunks)src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts
(3 hunks)
🔇 Additional comments (1)
src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts (1)
8-8
: Mind it! The Sentry import looks perfect!
The import statement is properly placed and follows Angular conventions.
@@ -37,6 +37,7 @@ import { ReportPermissions } from 'src/app/core/models/report-permissions.model' | |||
import { ExtendedComment } from 'src/app/core/models/platform/v1/extended-comment.model'; | |||
import { Comment } from 'src/app/core/models/platform/v1/comment.model'; | |||
import { ExpenseTransactionStatus } from 'src/app/core/enums/platform/v1/expense-transaction-status.enum'; | |||
import * as Sentry from '@sentry/angular'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Kabali style! Let's make error handling consistent across the app!
While the import is correct, I notice we're implementing Sentry tracking in multiple components individually.
Consider creating a centralized error handling service:
// src/app/core/services/error-tracking.service.ts
import * as Sentry from '@sentry/angular';
@Injectable({
providedIn: 'root'
})
export class ErrorTrackingService {
captureError(error: Error, context: Record<string, unknown>) {
Sentry.captureException(error, {
extra: {
errorType: error.name,
errorMessage: error.message,
timestamp: new Date().toISOString(),
...context
}
});
}
}
this.spenderReportsService.submit(this.reportId).subscribe({ | ||
next: () => { | ||
this.router.navigate(['/', 'enterprise', 'my_reports']); | ||
const message = `Report submitted successfully.`; | ||
this.matSnackBar.openFromComponent(ToastMessageComponent, { | ||
...this.snackbarProperties.setSnackbarProperties('success', { message }), | ||
panelClass: ['msb-success-with-camera-icon'], | ||
}); | ||
this.trackingService.showToastMessage({ ToastContent: message }); | ||
}, | ||
error: (error) => { | ||
// Capture error with additional details in Sentry | ||
Sentry.captureException(error, { | ||
extra: { | ||
reportId: this.reportId, | ||
errorResponse: error, | ||
}, | ||
}); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Mind it! The error handling needs more punch!
The Sentry integration is good, but we can make it more robust and user-friendly.
Consider these improvements:
submitReport(): void {
this.spenderReportsService.submit(this.reportId).subscribe({
next: () => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
+ const errorMessage = 'Failed to submit report. Please try again.';
+ this.matSnackBar.openFromComponent(ToastMessageComponent, {
+ ...this.snackbarProperties.setSnackbarProperties('error', { message: errorMessage }),
+ panelClass: ['msb-error'],
+ });
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
- errorResponse: error,
+ errorType: error.name,
+ errorMessage: error.message,
+ userId: this.eou?.us?.id,
+ timestamp: new Date().toISOString()
},
});
+ // Retry submission after a delay if it's a network error
+ if (error.name === 'NetworkError') {
+ setTimeout(() => this.submitReport(), 5000);
+ }
},
});
}
Committable suggestion skipped: line range outside the PR's diff.
|
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
|
Clickup
https://app.clickup.com/
Summary by CodeRabbit