Skip to content

Commit

Permalink
fix: Add additional trackers for onboarding (#3477)
Browse files Browse the repository at this point in the history
  • Loading branch information
bistaastha authored Feb 4, 2025
1 parent def2def commit 517d7b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class SpenderOnboardingConnectCardStepComponent implements OnInit, OnChan
this.cardValuesMap[card.id].enrollment_success = true;
}),
catchError((error: HttpErrorResponse) => {
this.trackingService.eventTrack('Connect Cards Onboarding Step - Failed', {
CardNumber: card.card_number.slice(-4),
error,
});
this.setupErrorMessages(error, `${card.card_number.slice(-4)}`, card.id);
return of(error);
})
Expand All @@ -98,6 +102,10 @@ export class SpenderOnboardingConnectCardStepComponent implements OnInit, OnChan
this.cardsList.successfulCards.push(`**** ${(this.fg.controls.card_number.value as string).slice(-4)}`);
}),
catchError((error: HttpErrorResponse) => {
this.trackingService.eventTrack('Connect Cards Onboarding Step - Failed', {
CardNumber: (this.fg.controls.card_number.value as string).slice(-4),
error,
});
this.setupErrorMessages(error, (this.fg.controls.card_number.value as string).slice(-4));
return of(error);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

describe('SpenderOnboardingPage', () => {
let component: SpenderOnboardingPage;
Expand Down Expand Up @@ -102,7 +103,7 @@ describe('SpenderOnboardingPage', () => {

it('should go to Opt in step when RTF is disabled', (done) => {
loaderService.showLoader.and.resolveTo();
orgUserService.getCurrent.and.returnValue(of(extendedOrgUserResponse));
orgUserService.getCurrent.and.returnValue(of(apiEouRes));
orgSettingsService.get.and.returnValue(of(orgSettingsWoTaxAndRtf));
spenderOnboardingService.getOnboardingStatus.and.returnValue(of(onboardingStatusData));
corporateCreditCardExpenseService.getCorporateCards.and.returnValue(of([statementUploadedCard]));
Expand All @@ -113,7 +114,7 @@ describe('SpenderOnboardingPage', () => {
fixture.detectChanges();

expect(loaderService.showLoader).toHaveBeenCalledTimes(1);
expect(component.userFullName).toBe('Aiyush');
expect(component.userFullName).toBe('Abhishek Jain');
expect(component.currentStep).toBe(OnboardingStep.OPT_IN);
expect(component.isLoading).toBeFalse();
done();
Expand Down
14 changes: 11 additions & 3 deletions src/app/fyle/spender-onboarding/spender-onboarding.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class SpenderOnboardingPage {
this.onboardingComplete = true;
this.startCountdown();
} else {
this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip');
this.router.navigate(['/', 'enterprise', 'my_dashboard']);
}
}
Expand All @@ -82,13 +83,17 @@ export class SpenderOnboardingPage {
this.showOneStep = true;
}
} else if (rtfCards.length > 0) {
this.trackingService.eventTrack('Skip Connect Cards Onboarding Step - Cards Already Enrolled', {
numberOfEnrolledCards: rtfCards.length,
});
this.areCardsEnrolled = true;
this.currentStep = OnboardingStep.OPT_IN;
this.showOneStep = true;
this.spenderOnboardingService.skipConnectCardsStep().subscribe();
} else {
this.currentStep = OnboardingStep.CONNECT_CARD;
if (this.isMobileVerified(this.eou)) {
this.trackingService.eventTrack('Skip Sms Opt In Onboarding Step - Mobile Already Verified');
this.showOneStep = true;
}
}
Expand All @@ -112,17 +117,19 @@ export class SpenderOnboardingPage {
this.orgSettings = orgSettings;
const isRtfEnabled =
orgSettings.visa_enrollment_settings.enabled || orgSettings.mastercard_enrollment_settings.enabled;
const isAmexFeedEnabled = orgSettings.amex_feed_enrollment_settings.enabled;
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)) {
this.trackingService.eventTrack('Redirect To Dashboard From Onboarding As No Steps To Show');
this.completeOnboarding().subscribe();
} else if (isAmexFeedEnabled && !isRtfEnabled) {
} else if (onlyAmexEnabled) {
this.currentStep = OnboardingStep.OPT_IN;
this.showOneStep = true;
} else if (isRtfEnabled) {
// If Connect Card was skipped earlier or Cards are already enrolled, then go to OPT_IN step
this.setUpRtfSteps(onboardingStatus, rtfCards);
}
this.trackingService.eventTrack('Spender Onboarding', { numberOfEnrollableCards: rtfCards.length });
}),
finalize(() => {
this.isLoading = false;
Expand Down Expand Up @@ -193,6 +200,7 @@ export class SpenderOnboardingPage {
this.redirectionCount--;
if (this.redirectionCount === 0) {
clearInterval(interval);
this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Success');
this.router.navigate(['/', 'enterprise', 'my_dashboard']);
}
}, 1000);
Expand Down

0 comments on commit 517d7b0

Please sign in to comment.