Skip to content

Commit

Permalink
fix: Track error for edit and check policy (#3422)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunaj5 authored Jan 16, 2025
1 parent b81e042 commit 64e8104
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/app/core/services/tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,14 @@ export class TrackingService {
this.eventTrack('Sync Error', properties);
}

checkPolicyError(properties: { label: Error }): void {
this.eventTrack('Check Policy Error', properties);
}

editExpenseError(properties: { label: Error }): void {
this.eventTrack('Edit Expense Error', properties);
}

// adding expenses in existing report event
addToExistingReport(properties = {}): void {
this.eventTrack('Add Expenses to Report', properties);
Expand Down
14 changes: 11 additions & 3 deletions src/app/fyle/add-edit-expense/add-edit-expense.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3675,9 +3675,13 @@ export class AddEditExpensePage implements OnInit {
}

checkPolicyViolation(etxn: { tx: PublicPolicyExpense; dataUrls: Partial<FileObject>[] }): Observable<ExpensePolicy> {
return this.policyService
.getPlatformPolicyExpense(etxn, this.selectedCCCTransaction)
.pipe(switchMap((platformPolicyExpense) => this.transactionService.checkPolicy(platformPolicyExpense)));
return this.policyService.getPlatformPolicyExpense(etxn, this.selectedCCCTransaction).pipe(
switchMap((platformPolicyExpense) => this.transactionService.checkPolicy(platformPolicyExpense)),
catchError((err: Error) => {
this.trackingService.checkPolicyError({ label: err });
return throwError(() => err);
})
);
}

getProjectDependentFields(): TxnCustomProperties[] {
Expand Down Expand Up @@ -4062,6 +4066,10 @@ export class AddEditExpensePage implements OnInit {
};

return this.transactionService.upsert(etxn.tx as Transaction).pipe(
catchError((err: Error) => {
this.trackingService.editExpenseError({ label: err });
return throwError(() => err);
}),
switchMap((tx) => {
const selectedReportId = reportControl.report?.id;
const criticalPolicyViolated = this.getIsPolicyExpense(etxn as unknown as Expense);
Expand Down

0 comments on commit 64e8104

Please sign in to comment.