diff --git a/src/app/fyle/my-view-report/my-view-report.page.ts b/src/app/fyle/my-view-report/my-view-report.page.ts index 47b3905dad..c24b63ef39 100644 --- a/src/app/fyle/my-view-report/my-view-report.page.ts +++ b/src/app/fyle/my-view-report/my-view-report.page.ts @@ -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'; @Component({ selector: 'app-my-view-report', @@ -444,14 +445,25 @@ export class MyViewReportPage { } submitReport(): void { - this.spenderReportsService.submit(this.reportId).subscribe(() => { - 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 }); + 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, + }, + }); + }, }); } diff --git a/src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts b/src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts index ec09b0dd1b..42d78731f6 100644 --- a/src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts +++ b/src/app/shared/components/capture-receipt/camera-preview/camera-preview.component.ts @@ -5,6 +5,7 @@ import { DEVICE_PLATFORM } from 'src/app/constants'; import { CameraState } from 'src/app/core/enums/camera-state.enum'; import { CameraPreviewService } from 'src/app/core/services/camera-preview.service'; import { CameraService } from 'src/app/core/services/camera.service'; +import * as Sentry from '@sentry/angular'; @Component({ selector: 'app-camera-preview', @@ -81,6 +82,7 @@ export class CameraPreviewComponent implements OnInit, OnChanges { startCameraPreview(): void { if (![CameraState.STARTING, CameraState.RUNNING].includes(this.cameraState)) { + const currentCameraState = this.cameraState; this.cameraState = CameraState.STARTING; const cameraPreviewOptions: CameraPreviewOptions = { position: 'rear', @@ -91,9 +93,24 @@ export class CameraPreviewComponent implements OnInit, OnChanges { disableAudio: true, }; - from(this.cameraPreviewService.start(cameraPreviewOptions)).subscribe(() => { - this.cameraState = CameraState.RUNNING; - this.getFlashModes(); + from(this.cameraPreviewService.start(cameraPreviewOptions)).subscribe({ + next: () => { + this.cameraState = CameraState.RUNNING; + this.getFlashModes(); + }, + error: (error) => { + Sentry.captureException(error, { + extra: { + errorResponse: error, + currentCameraState, + cameraState: this.cameraState, + navigationState: window.location.href, + options: cameraPreviewOptions, + platform: this.devicePlatform, + timestamp: new Date().toISOString(), + }, + }); + }, }); } }