Skip to content
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

fix: Add additional trackers for onboarding #3477

Merged
merged 6 commits into from
Feb 4, 2025

Conversation

bistaastha
Copy link
Contributor

@bistaastha bistaastha commented Feb 4, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced error tracking during card enrollment to capture specific failure details.
    • Improved onboarding flow with additional tracking for user actions, such as skipping steps and successful redirection to the dashboard.
    • Introduced a new method for better error management within the onboarding process.

Copy link

coderabbitai bot commented Feb 4, 2025

Walkthrough

The changes enhance error tracking and error handling during the onboarding process. In the card enrollment component, additional tracking events now capture error details and card identification. In the onboarding page, several tracking events log user redirection actions and errors, with modifications added to the control flow. A new private method has been introduced for consistent error management. No exported entities have been altered.

Changes

File(s) Change Summary
src/app/fyle/spender-onboarding/spender-onboarding-connect-card-step/.../spender-onboarding-connect-card-step.component.ts Added tracking events in the catchError blocks for both enrollMultipleCards and enrollSingularCard to log errors with card details.
src/app/fyle/spender-onboarding/spender-onboarding.page.ts Introduced multiple tracking events in methods like setPostOnboardingScreen, setUpRtfSteps, and startCountdown; modified redirection logic and added a new private handleError method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CardEnrollmentComponent as Component
    participant TrackingService as Tracker
    User->>Component: Initiate card enrollment
    Component-->>User: Error occurs during enrollment
    Component->>Tracker: Log tracking event (card error details)
    Tracker-->>Component: Acknowledgement of log
Loading
sequenceDiagram
    participant User
    participant OnboardingPage as Page
    participant TrackingService as Tracker
    User->>Page: Begin onboarding process
    Page->>Page: Evaluate redirection conditions (mobile verified, Amex, RTF cards)
    Page->>Tracker: Log tracking event for redirection or step skipping
    alt Error encountered
        Page->>Page: Invoke private handleError method
        Page->>Tracker: Log error tracking event
    end
    Page-->>User: Redirect or display steps
Loading

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • arjunaj5
  • Chethan-Fyle

Poem

In the land of code, our actions shine bright,
Errors tracked with a punch, like a Rajini fight.
Cards and pages dance in a flawless display,
Onboarding flows smooth—no bug can stand in our way!
CodeRabbit magic, making every line a delight!

🎉✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the size/S Small PR label Feb 4, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔭 Outside diff range comments (1)
src/app/fyle/spender-onboarding/spender-onboarding-connect-card-step/spender-onboarding-connect-card-step.component.ts (1)

270-270: Update TODO comment for Angular version.

Kabali da! This TODO comment about Angular 14 is outdated. Time to update it for the latest Angular version.

-      // TODO (Angular 14 >): Remove the type casting and directly use string type for the form control
+      // TODO (Angular 16+): Remove the type casting and use strongly typed forms
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc9e254 and b811db2.

📒 Files selected for processing (2)
  • src/app/fyle/spender-onboarding/spender-onboarding-connect-card-step/spender-onboarding-connect-card-step.component.ts (2 hunks)
  • src/app/fyle/spender-onboarding/spender-onboarding.page.ts (5 hunks)
🧰 Additional context used
🪛 GitHub Check: Run linters
src/app/fyle/spender-onboarding/spender-onboarding.page.ts

[failure] 2-2:
'catchError' is defined but never used


[failure] 211-211:
Unsafe assignment of an any value


[failure] 212-212:
Unsafe return of an any typed value


[failure] 212-212:
Unsafe call of an any typed value

🪛 ESLint
src/app/fyle/spender-onboarding/spender-onboarding.page.ts

[error] 2-2: 'catchError' is defined but never used.

(@typescript-eslint/no-unused-vars)

🪛 GitHub Actions: Unit Tests
src/app/fyle/spender-onboarding/spender-onboarding.page.ts

[error] 212-212: Cannot find name 'of'.

🪛 GitHub Actions: Lint
src/app/fyle/spender-onboarding/spender-onboarding.page.ts

[error] 2-2: 'catchError' is defined but never used @typescript-eslint/no-unused-vars

@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { finalize, forkJoin, from, map, Observable, switchMap } from 'rxjs';
import { catchError, finalize, forkJoin, from, map, Observable, switchMap } from 'rxjs';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the unused import and missing 'of' operator.

Mind games! You imported 'catchError' but never used it, and 'of' operator is missing from imports.

-import { catchError, finalize, forkJoin, from, map, Observable, switchMap } from 'rxjs';
+import { finalize, forkJoin, from, map, Observable, of, switchMap } from 'rxjs';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { catchError, finalize, forkJoin, from, map, Observable, switchMap } from 'rxjs';
import { finalize, forkJoin, from, map, Observable, of, switchMap } from 'rxjs';
🧰 Tools
🪛 GitHub Check: Run linters

[failure] 2-2:
'catchError' is defined but never used

🪛 ESLint

[error] 2-2: 'catchError' is defined but never used.

(@typescript-eslint/no-unused-vars)

🪛 GitHub Actions: Lint

[error] 2-2: 'catchError' is defined but never used @typescript-eslint/no-unused-vars

Comment on lines 209 to 213
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private handleError(error: any, event: string): Observable<Record<string, never>> {
this.trackingService.eventTrack(event, { error });
return of({});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix type safety issues in handleError method.

Listen up! The handleError method needs proper type safety. Let's fix those TypeScript errors like a boss!

-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  private handleError(error: any, event: string): Observable<Record<string, never>> {
-    this.trackingService.eventTrack(event, { error });
-    return of({});
+  private handleError(error: Error | unknown, event: string): Observable<Record<string, never>> {
+    this.trackingService.eventTrack(event, { error: error instanceof Error ? error.message : String(error) });
+    return of({});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private handleError(error: any, event: string): Observable<Record<string, never>> {
this.trackingService.eventTrack(event, { error });
return of({});
}
private handleError(error: Error | unknown, event: string): Observable<Record<string, never>> {
this.trackingService.eventTrack(event, { error: error instanceof Error ? error.message : String(error) });
return of({});
}
🧰 Tools
🪛 GitHub Check: Run linters

[failure] 211-211:
Unsafe assignment of an any value


[failure] 212-212:
Unsafe return of an any typed value


[failure] 212-212:
Unsafe call of an any typed value

🪛 GitHub Actions: Unit Tests

[error] 212-212: Cannot find name 'of'.

Comment on lines +120 to +122
const onlyAmexEnabled = orgSettings.amex_feed_enrollment_settings.enabled && !isRtfEnabled;
const rtfCards = corporateCards.filter((card) => card.is_visa_enrolled || card.is_mastercard_enrolled);
if (this.isMobileVerified(this.eou) && rtfCards.length > 0) {
if (this.isMobileVerified(this.eou) && (onlyAmexEnabled || rtfCards.length > 0)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Improve variable naming for better clarity.

Style, my friend! Let's make that variable name more descriptive.

-          const onlyAmexEnabled = orgSettings.amex_feed_enrollment_settings.enabled && !isRtfEnabled;
+          const isOnlyAmexEnabled = orgSettings.amex_feed_enrollment_settings.enabled && !isRtfEnabled;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +81 to +84
this.trackingService.eventTrack('Connect Cards Onboarding Step - Failed', {
CardNumber: card.card_number.slice(-4),
error,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enhance error tracking with structured error details.

Mind it! Let's structure those error details better for tracking.

-              this.trackingService.eventTrack('Connect Cards Onboarding Step - Failed', {
-                CardNumber: card.card_number.slice(-4),
-                error,
-              });
+              this.trackingService.eventTrack('Connect Cards Onboarding Step - Failed', {
+                cardNumber: card.card_number.slice(-4),
+                errorCode: error.status,
+                errorMessage: error.message || 'Unknown error',
+              });

Apply similar changes to the singular card enrollment error tracking at lines 105-108.

Also applies to: 105-108

Copy link

@coderabbitai coderabbitai bot left a 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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9994e9c and 585f780.

📒 Files selected for processing (1)
  • src/app/fyle/spender-onboarding/spender-onboarding.page.ts (4 hunks)
🔇 Additional comments (2)
src/app/fyle/spender-onboarding/spender-onboarding.page.ts (2)

2-2: Mind it! Fix those imports, they are like my signature moves - they need to be perfect!

The import statement needs the 'of' operator but doesn't need 'catchError'. Let's style it up!

-import { finalize, forkJoin, from, map, Observable, switchMap } from 'rxjs';
+import { finalize, forkJoin, from, map, Observable, of, switchMap } from 'rxjs';

120-122: Style, my friend! Let's make that variable name more descriptive.

-const onlyAmexEnabled = orgSettings.amex_feed_enrollment_settings.enabled && !isRtfEnabled;
+const isOnlyAmexEnabled = orgSettings.amex_feed_enrollment_settings.enabled && !isRtfEnabled;

@@ -62,6 +62,7 @@ export class SpenderOnboardingPage {
this.onboardingComplete = true;
this.startCountdown();
} else {
this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Listen up! Your tracking events need to follow a style, just like my movies follow a style!

The tracking event names could be more consistent. Some use "Redirect To" while others use different formats. Let's make them all follow the same pattern:

  • "Redirect To Dashboard After Onboarding Skip"
  • "Skip Connect Cards Onboarding Step - Cards Already Enrolled"
  • "Skip Sms Opt In Onboarding Step - Mobile Already Verified"
  • "Redirect To Dashboard From Onboarding As No Steps To Show"
  • "Spender Onboarding"
  • "Redirect To Dashboard After Onboarding Success"

Consider standardizing the event names. For example:

-this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip');
+this.trackingService.eventTrack('Onboarding: Dashboard Redirect - Skip');

-this.trackingService.eventTrack('Skip Connect Cards Onboarding Step - Cards Already Enrolled');
+this.trackingService.eventTrack('Onboarding: Skip Cards Step - Already Enrolled');

Also applies to: 86-88, 96-96, 123-123, 132-132, 203-203


🛠️ Refactor suggestion

When you handle errors like a boss, your code becomes legendary!

The tracking service calls need proper error handling. Let's add a private method to handle tracking errors:

+private handleTrackingError(error: Error | unknown): void {
+  console.error('Tracking failed:', error instanceof Error ? error.message : String(error));
+}

-this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip');
+this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip').subscribe({
+  error: (err) => this.handleTrackingError(err)
+});

Also applies to: 86-88, 96-96, 123-123, 132-132, 203-203

…yle-mobile-app into FYLE-adding-additional-trackers
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/app/fyle/spender-onboarding/spender-onboarding.page.spec.ts (1)

82-174: Hey, test coverage needs more power!

The test suite for ionViewWillEnter should include additional test cases to verify error handling and edge cases during onboarding.

Consider adding test cases for:

  1. Error scenarios during API calls
  2. Edge cases with different org settings combinations
  3. Network failure scenarios
+it('should handle API errors gracefully', (done) => {
+  loaderService.showLoader.and.resolveTo();
+  orgUserService.getCurrent.and.returnValue(throwError(() => new Error('API Error')));
+
+  component.ionViewWillEnter();
+
+  fixture.whenStable().then(() => {
+    fixture.detectChanges();
+    expect(component.isLoading).toBeFalse();
+    expect(loaderService.hideLoader).toHaveBeenCalled();
+    done();
+  });
+});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 585f780 and df07ff8.

📒 Files selected for processing (1)
  • src/app/fyle/spender-onboarding/spender-onboarding.page.spec.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (1)
src/app/fyle/spender-onboarding/spender-onboarding.page.spec.ts (1)

106-106: Magizhchi! Test data update looks good!

The change from extendedOrgUserResponse to apiEouRes and corresponding user name update maintains consistency with the new test data structure.

Also applies to: 117-117

@@ -16,6 +16,7 @@ import { orgSettingsWoTaxAndRtf } from 'src/app/core/mock-data/org-settings.data
import { statementUploadedCard } from 'src/app/core/mock-data/platform-corporate-card.data';
import { TrackingService } from 'src/app/core/services/tracking.service';
import { apiEouRes } from 'src/app/core/mock-data/extended-org-user.data';
import { orgSettingsCardsDisabled } from 'src/app/core/test-data/org-settings.service.spec.data';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Mind it! Remove unused import, partner!

The imported orgSettingsCardsDisabled is not being used in any test case. Let's keep our code clean and remove this unused import.

-import { orgSettingsCardsDisabled } from 'src/app/core/test-data/org-settings.service.spec.data';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { orgSettingsCardsDisabled } from 'src/app/core/test-data/org-settings.service.spec.data';
// (The unused import line has been removed)

Copy link

github-actions bot commented Feb 4, 2025

Unit Test Coverage % values
Statements 96.08% ( 19752 / 20557 )
Branches 91.13% ( 10850 / 11906 )
Functions 94.38% ( 5868 / 6217 )
Lines 96.13% ( 18869 / 19627 )

@bistaastha bistaastha merged commit 517d7b0 into master Feb 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants