-
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
fix: Add additional trackers for onboarding #3477
Changes from all commits
b811db2
9994e9c
3ca6f8c
2e0a3f0
585f780
df07ff8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Mind it! Remove unused import, partner! The imported -import { orgSettingsCardsDisabled } from 'src/app/core/test-data/org-settings.service.spec.data'; 📝 Committable suggestion
Suggested change
|
||||||
|
||||||
describe('SpenderOnboardingPage', () => { | ||||||
let component: SpenderOnboardingPage; | ||||||
|
@@ -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])); | ||||||
|
@@ -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(); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ export class SpenderOnboardingPage { | |
this.onboardingComplete = true; | ||
this.startCountdown(); | ||
} else { | ||
this.trackingService.eventTrack('Redirect To Dashboard After Onboarding Skip'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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 |
||
this.router.navigate(['/', 'enterprise', 'my_dashboard']); | ||
} | ||
} | ||
|
@@ -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; | ||
} | ||
} | ||
|
@@ -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)) { | ||
Comment on lines
+120
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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;
|
||
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; | ||
|
@@ -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); | ||
|
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)
Enhance error tracking with structured error details.
Mind it! Let's structure those error details better for tracking.
Apply similar changes to the singular card enrollment error tracking at lines 105-108.
Also applies to: 105-108