From cb27ca5db8470ec061885e614ec99b1b1e6e4c85 Mon Sep 17 00:00:00 2001 From: DhaaraniCIT Date: Mon, 16 Dec 2024 12:51:49 +0530 Subject: [PATCH] QBD direct tracker update --- src/app/core/models/enum/enum.model.ts | 13 ++++++++ src/app/core/models/misc/tracking.model.ts | 8 +++-- .../services/integration/tracking.service.ts | 9 ++++-- ...d-direct-onboarding-connector.component.ts | 24 ++++++++++++-- ...rect-onboarding-pre-requisite.component.ts | 24 ++++++++++++-- .../qbd-direct-advanced-settings.component.ts | 26 ++++++++++++++-- .../qbd-direct-export-settings.component.ts | 23 +++++++++++++- .../qbd-direct-import-settings.component.ts | 31 ++++++++++++++++--- 8 files changed, 141 insertions(+), 17 deletions(-) diff --git a/src/app/core/models/enum/enum.model.ts b/src/app/core/models/enum/enum.model.ts index 5104c7f28..49c07a20b 100644 --- a/src/app/core/models/enum/enum.model.ts +++ b/src/app/core/models/enum/enum.model.ts @@ -82,6 +82,14 @@ export enum TravelperkUpdateEvent { ADVANCED_SETTINGS_TRAVELPERK = 'Advanced Settings TravelPerk', } +export enum QbdDirectUpdateEvent { + CONFIRM_PRE_REQUISITES_QBD_DIRECT = 'Confirm Pre Requisites QuickBooks Desktop Connector', + CONNECT_QBD_DIRECT = 'Connect QuickBooks Desktop Connector', + EXPORT_SETTING_QBD_DIRECT = 'Export Settings QuickBooks Desktop Connector', + IMPORT_SETTINGS_QBD_DIRECT = 'Import Settings QuickBooks Desktop Connector', + ADVANCED_SETTINGS_QBD_DIRECT = 'Advanced Settings QuickBooks Desktop Connector', +} + export enum AppName { BAMBOO_HR = 'BambooHR', QBD = 'QuickBooks Desktop', @@ -126,6 +134,11 @@ export enum Page { ADVANCED_SETTINGS_BUSINESS_CENTRAL = 'Advanced Settings BusinessCentral', PAYMENT_PROFILE_SETTINGS_TRAVELPERK = 'Payment Profile Settings TravelPerk', ADVANCED_SETTINGS_TRAVELPERK = 'Advanced Settings TravelPerk', + EXPORT_SETTING_QBD_DIRECT = 'Export Settings QuickBooks Desktop Connector', + CONNECT_QBD_DIRECT = 'Connect QuickBooks Desktop Connector', + CONFIRM_PRE_REQUISITES_QBD_DIRECT = 'Confirm Pre Requisites QuickBooks Desktop Connector', + IMPORT_SETTINGS_QBD_DIRECT = 'Import Settings QuickBooks Desktop Connector', + ADVANCED_SETTINGS_QBD_DIRECT = 'Advanced Settings QuickBooks Desktop Connector', } export enum ClickEvent { diff --git a/src/app/core/models/misc/tracking.model.ts b/src/app/core/models/misc/tracking.model.ts index b3ebd33d5..f98f2066c 100644 --- a/src/app/core/models/misc/tracking.model.ts +++ b/src/app/core/models/misc/tracking.model.ts @@ -13,11 +13,15 @@ import { TravelperkPaymentProfileSettingResponse } from "../travelperk/travelper import { AdvancedSettingsGet } from "../intacct/intacct-configuration/advanced-settings.model"; import { ExportSettingGet } from "../intacct/intacct-configuration/export-settings.model"; import { ImportSettingGet, ImportSettings } from "../intacct/intacct-configuration/import-settings.model"; +import { QbdDirectAdvancedSettingsPost } from "../qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model"; +import { QbdDirectExportSettingsPost } from "../qbd-direct/qbd-direct-configuration/qbd-direct-export-settings.model"; +import { QbdDirectImportSettingPost } from "../qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.model"; +import { Workspace } from "../db/workspaces.model"; export type UpdateEventAdditionalProperty = { phase: ProgressPhase, - oldState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | null | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost, - newState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost + oldState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | null | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost | QbdDirectExportSettingsPost | QbdDirectImportSettingPost | QbdDirectAdvancedSettingsPost | Workspace, + newState: QBDAdvancedSettingsGet | QBDExportSettingGet | QBDFieldMappingGet | Sage300ExportSettingGet | Sage300ImportSettingGet | Sage300AdvancedSettingGet | BusinessCentralExportSettingGet | BusinessCentralImportSettingsGet | BusinessCentralAdvancedSettingsGet | TravelperkPaymentProfileSettingResponse | TravelperkAdvancedSettingPost | QbdDirectExportSettingsPost | QbdDirectImportSettingPost | QbdDirectAdvancedSettingsPost | Workspace }; export type UpdateIntacctEventAdditionalProperty = { diff --git a/src/app/core/services/integration/tracking.service.ts b/src/app/core/services/integration/tracking.service.ts index 0721d0889..eabed6381 100644 --- a/src/app/core/services/integration/tracking.service.ts +++ b/src/app/core/services/integration/tracking.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { BusinessCentralOnboardingState, NetsuiteOnboardingState, BusinessCentralUpdateEvent, ClickEvent, IntacctOnboardingState, IntacctUpdateEvent, Page, QBDOnboardingState, Sage300OnboardingState, Sage300UpdateEvent, TrackingApp, TravelPerkOnboardingState, TravelperkUpdateEvent, UpdateEvent } from '../../models/enum/enum.model'; +import { BusinessCentralOnboardingState, NetsuiteOnboardingState, BusinessCentralUpdateEvent, ClickEvent, IntacctOnboardingState, IntacctUpdateEvent, Page, QBDOnboardingState, Sage300OnboardingState, Sage300UpdateEvent, TrackingApp, TravelPerkOnboardingState, TravelperkUpdateEvent, UpdateEvent, QbdDirectOnboardingState, QbdDirectUpdateEvent } from '../../models/enum/enum.model'; import { MappingAlphabeticalFilterAdditionalProperty, ResolveMappingErrorProperty, UpdateEventAdditionalProperty, UpdateIntacctEventAdditionalProperty } from '../../models/misc/tracking.model'; import { QBDAdvancedSettingsPost } from '../../models/qbd/qbd-configuration/qbd-advanced-setting.model'; import { QBDExportSettingPost } from '../../models/qbd/qbd-configuration/qbd-export-setting.model'; @@ -17,6 +17,9 @@ import { BusinessCentralAdvancedSettingsPost } from '../../models/business-centr import { NetsuiteSubsidiaryMappingPost } from '../../models/netsuite/netsuite-configuration/netsuite-connector.model'; import { TravelperkPaymentProfileSettingPost } from '../../models/travelperk/travelperk-configuration/travelperk-payment-profile-settings.model'; import { TravelperkAdvancedSettingPost } from '../../models/travelperk/travelperk-configuration/travelperk-advanced-settings.model'; +import { QbdDirectAdvancedSettingsPost } from '../../models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model'; +import { QbdDirectExportSettingsPost } from '../../models/qbd-direct/qbd-direct-configuration/qbd-direct-export-settings.model'; +import { QbdDirectImportSettingPost } from '../../models/qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.model'; @Injectable({ providedIn: 'root' @@ -100,11 +103,11 @@ export class TrackingService { this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, trackingApp, additionalProperties); } - integrationsOnboardingCompletion(trackingApp: TrackingApp, eventName: IntacctOnboardingState | NetsuiteOnboardingState, stepNumber: number, additionalProperties: LocationEntityPost | ExportSettingPost | ImportSettingPost | AdvancedSettingsPost | NetsuiteSubsidiaryMappingPost | void): void { + integrationsOnboardingCompletion(trackingApp: TrackingApp, eventName: IntacctOnboardingState | NetsuiteOnboardingState | QbdDirectOnboardingState, stepNumber: number, additionalProperties: LocationEntityPost | ExportSettingPost | ImportSettingPost | AdvancedSettingsPost | NetsuiteSubsidiaryMappingPost | QbdDirectExportSettingsPost | QbdDirectImportSettingPost | QbdDirectAdvancedSettingsPost | void): void { this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, trackingApp, additionalProperties); } - onUpdateEvent(trackingApp: TrackingApp, eventName: UpdateEvent | Sage300UpdateEvent | BusinessCentralUpdateEvent | TravelperkUpdateEvent, additionalProperties: Partial | void): void { + onUpdateEvent(trackingApp: TrackingApp, eventName: UpdateEvent | Sage300UpdateEvent | BusinessCentralUpdateEvent | TravelperkUpdateEvent | QbdDirectUpdateEvent, additionalProperties: Partial | void): void { this.eventTrack(`Update event: ${eventName}`, trackingApp, additionalProperties); } diff --git a/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts b/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts index a1bb46e03..764d403d8 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-connector/qbd-direct-onboarding-connector.component.ts @@ -3,7 +3,7 @@ import { QbdDirectSharedModule } from '../../qbd-direct-shared/qbd-direct-shared import { SharedModule } from 'src/app/shared/shared.module'; import { brandingConfig, brandingContent, brandingKbArticles } from 'src/app/branding/branding-config'; import { BrandingConfiguration } from 'src/app/core/models/branding/branding-configuration.model'; -import { AppName, ConfigurationCta, QBDConnectionStatus, QbdDirectOnboardingState, QBDOnboardingState, ToastSeverity } from 'src/app/core/models/enum/enum.model'; +import { AppName, ConfigurationCta, Page, ProgressPhase, QBDConnectionStatus, QbdDirectOnboardingState, QbdDirectUpdateEvent, QBDOnboardingState, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model'; import { OnboardingStepper } from 'src/app/core/models/misc/onboarding-stepper.model'; import { QbdDirectOnboardingModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-onboarding.model'; import { Router } from '@angular/router'; @@ -18,6 +18,7 @@ import { interval, switchMap, from, takeWhile } from 'rxjs'; import { QbdDirectTaskResponse } from 'src/app/core/models/qbd-direct/db/qbd-direct-task-log.model'; import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; import { CheckBoxUpdate } from 'src/app/core/models/common/helper.model'; +import { TrackingService } from 'src/app/core/services/integration/tracking.service'; @Component({ selector: 'app-qbd-direct-onboarding-connector', @@ -74,12 +75,15 @@ export class QbdDirectOnboardingConnectorComponent implements OnInit { appName: string = AppName.QBD_DIRECT; + sessionStartTime: Date = new Date(); + constructor( private router: Router, private workspaceService: WorkspaceService, private storageService: StorageService, private qbdDirectConnectorService: QbdDirectConnectorService, - private toastService: IntegrationsToastService + private toastService: IntegrationsToastService, + private trackingService: TrackingService ) { } triggerDownload(filePath: string) { @@ -216,6 +220,22 @@ export class QbdDirectOnboardingConnectorComponent implements OnInit { proceedToExportSetting() { this.isLoading = true; this.workspaceService.updateWorkspaceOnboardingState({onboarding_state: QbdDirectOnboardingState.EXPORT_SETTINGS}).subscribe((workspaceResponse: QbdDirectWorkspace) => { + this.trackingService.trackTimeSpent(TrackingApp.QBD_DIRECT, Page.CONNECT_QBD_DIRECT, this.sessionStartTime); + if (this.workspaceService.getOnboardingState() === QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE) { + this.trackingService.integrationsOnboardingCompletion(TrackingApp.QBD_DIRECT, QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE, 2); + } else { + const oldWorkspaceResponse = workspaceResponse; + oldWorkspaceResponse.onboarding_state = QbdDirectOnboardingState.DESTINATION_SYNC_COMPLETE; + this.trackingService.onUpdateEvent( + TrackingApp.QBD_DIRECT, + QbdDirectUpdateEvent.CONNECT_QBD_DIRECT, + { + phase: ProgressPhase.ONBOARDING, + oldState: oldWorkspaceResponse, + newState: workspaceResponse + } + ); + } this.workspaceService.setOnboardingState(workspaceResponse.onboarding_state); this.router.navigate([`/integrations/qbd_direct/onboarding/export_settings`]); this.isLoading = false; diff --git a/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-pre-requisite/qbd-direct-onboarding-pre-requisite.component.ts b/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-pre-requisite/qbd-direct-onboarding-pre-requisite.component.ts index d852ac490..1385f2263 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-pre-requisite/qbd-direct-onboarding-pre-requisite.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-onboarding/qbd-direct-onboarding-pre-requisite/qbd-direct-onboarding-pre-requisite.component.ts @@ -5,12 +5,13 @@ import { brandingContent, brandingKbArticles } from 'src/app/branding/branding-c import { brandingConfig } from 'src/app/branding/c1-contents-config'; import { BrandingConfiguration } from 'src/app/core/models/branding/branding-configuration.model'; import { CheckBoxUpdate } from 'src/app/core/models/common/helper.model'; -import { AppName, ConfigurationCta, QbdDirectOnboardingState, QBDPreRequisiteState } from 'src/app/core/models/enum/enum.model'; +import { AppName, ConfigurationCta, Page, ProgressPhase, QbdDirectOnboardingState, QbdDirectUpdateEvent, QBDPreRequisiteState, TrackingApp } from 'src/app/core/models/enum/enum.model'; import { OnboardingStepper } from 'src/app/core/models/misc/onboarding-stepper.model'; import { QbdDirectWorkspace } from 'src/app/core/models/qbd-direct/db/qbd-direct-workspaces.model'; import { QBDPrerequisiteObject } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-connector.model'; import { QbdDirectOnboardingModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-onboarding.model'; import { WorkspaceService } from 'src/app/core/services/common/workspace.service'; +import { TrackingService } from 'src/app/core/services/integration/tracking.service'; import { SharedModule } from 'src/app/shared/shared.module'; @Component({ @@ -61,9 +62,12 @@ export class QbdDirectOnboardingPreRequisiteComponent { qbdPreRequisiteState = QBDPreRequisiteState; + sessionStartTime: Date = new Date(); + constructor( private router: Router, - private workspaceService: WorkspaceService + private workspaceService: WorkspaceService, + private trackingService: TrackingService ) { } updateConnectorStatus(status: CheckBoxUpdate): void { @@ -76,6 +80,22 @@ export class QbdDirectOnboardingPreRequisiteComponent { continueToNextStep(): void{ this.saveInProgress = true; this.workspaceService.updateWorkspaceOnboardingState({onboarding_state: QbdDirectOnboardingState.CONNECTION}).subscribe((workspaceResponse: QbdDirectWorkspace) => { + this.trackingService.trackTimeSpent(TrackingApp.QBD_DIRECT, Page.CONFIRM_PRE_REQUISITES_QBD_DIRECT, this.sessionStartTime); + if (this.workspaceService.getOnboardingState() === QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES) { + this.trackingService.integrationsOnboardingCompletion(TrackingApp.QBD_DIRECT, QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES, 1); + } else { + const oldWorkspaceResponse = workspaceResponse; + oldWorkspaceResponse.onboarding_state = QbdDirectOnboardingState.CONFIRM_PRE_REQUISITES; + this.trackingService.onUpdateEvent( + TrackingApp.QBD_DIRECT, + QbdDirectUpdateEvent.CONFIRM_PRE_REQUISITES_QBD_DIRECT, + { + phase: ProgressPhase.ONBOARDING, + oldState: oldWorkspaceResponse, + newState: workspaceResponse + } + ); + } this.workspaceService.setOnboardingState(workspaceResponse.onboarding_state); this.saveInProgress = false; this.router.navigate([`/integrations/qbd_direct/onboarding/connector`]); diff --git a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts index 6d65a224e..b7cc19240 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-advanced-settings/qbd-direct-advanced-settings.component.ts @@ -6,13 +6,14 @@ import { catchError, forkJoin, of } from 'rxjs'; import { brandingConfig, brandingContent, brandingFeatureConfig, brandingKbArticles } from 'src/app/branding/branding-config'; import { ConditionField, ExpenseFilterPayload, ExpenseFilterResponse, SkipExportModel, skipExportValidator, SkipExportValidatorRule } from 'src/app/core/models/common/advanced-settings.model'; import { EmailOption, SelectFormOption } from 'src/app/core/models/common/select-form-option.model'; -import { AppName, AutoMapEmployeeOptions, ConfigurationCta, EmployeeFieldMapping, NameInJournalEntry, QBDCorporateCreditCardExpensesObject, QBDOnboardingState, QBDScheduleFrequency, ToastSeverity } from 'src/app/core/models/enum/enum.model'; +import { AppName, AutoMapEmployeeOptions, ConfigurationCta, EmployeeFieldMapping, IntacctUpdateEvent, NameInJournalEntry, Page, ProgressPhase, QBDCorporateCreditCardExpensesObject, QbdDirectOnboardingState, QbdDirectUpdateEvent, QBDOnboardingState, QBDScheduleFrequency, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model'; import { QbdDirectAdvancedSettingsGet, QbdDirectAdvancedSettingsModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.model'; import { QbdDirectExportSettingGet } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-export-settings.model'; import { HelperService } from 'src/app/core/services/common/helper.service'; import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; import { SkipExportService } from 'src/app/core/services/common/skip-export.service'; import { WorkspaceService } from 'src/app/core/services/common/workspace.service'; +import { TrackingService } from 'src/app/core/services/integration/tracking.service'; import { OrgService } from 'src/app/core/services/org/org.service'; import { QbdDirectAdvancedSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.service'; import { QbdDirectExportSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-export-settings.service'; @@ -104,7 +105,8 @@ export class QbdDirectAdvancedSettingsComponent implements OnInit { private orgService: OrgService, private toastService: IntegrationsToastService, private workspaceService: WorkspaceService, - private qbdDirectHelperService: QbdDirectHelperService + private qbdDirectHelperService: QbdDirectHelperService, + private trackingService: TrackingService ) { } private saveSkipExportFields(): void { @@ -148,11 +150,31 @@ export class QbdDirectAdvancedSettingsComponent implements OnInit { this.qbdDirectHelperService.importAttributes(true); } + private getPhase(): ProgressPhase { + return this.isOnboarding ? ProgressPhase.ONBOARDING : ProgressPhase.POST_ONBOARDING; + } + save() { this.saveInProgress = true; this.saveSkipExport(); const advancedSettingPayload = QbdDirectAdvancedSettingsModel.constructPayload(this.advancedSettingsForm, this.adminEmails); this.advancedSettingsService.postQbdAdvancedSettings(advancedSettingPayload).subscribe((response: QbdDirectAdvancedSettingsGet) => { + + this.trackingService.trackTimeSpent(TrackingApp.QBD_DIRECT, Page.ADVANCED_SETTINGS_QBD_DIRECT, this.sessionStartTime); + if (this.workspaceService.getOnboardingState() === QbdDirectOnboardingState.ADVANCED_SETTINGS) { + this.trackingService.integrationsOnboardingCompletion(TrackingApp.QBD_DIRECT, QbdDirectOnboardingState.ADVANCED_SETTINGS, 5, advancedSettingPayload); + } else { + this.trackingService.onUpdateEvent( + TrackingApp.QBD_DIRECT, + QbdDirectUpdateEvent.ADVANCED_SETTINGS_QBD_DIRECT, + { + phase: this.getPhase(), + oldState: this.advancedSettings, + newState: response + } + ); + } + this.saveInProgress = false; this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Advanced settings saved successfully'); diff --git a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts index c827c3e2f..c42aa35ef 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts @@ -1,7 +1,7 @@ import { Component, Inject, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; -import { AppName, ConfigurationCta, EmployeeFieldMapping, QBDCorporateCreditCardExpensesObject, QbdDirectExpenseGroupBy, QbdDirectExportSettingDestinationOptionKey, QbdDirectOnboardingState, QbdDirectReimbursableExpensesObject, QBDExpenseGroupedBy, ToastSeverity } from 'src/app/core/models/enum/enum.model'; +import { AppName, ConfigurationCta, EmployeeFieldMapping, Page, ProgressPhase, QBDCorporateCreditCardExpensesObject, QbdDirectExpenseGroupBy, QbdDirectExportSettingDestinationOptionKey, QbdDirectOnboardingState, QbdDirectReimbursableExpensesObject, QbdDirectUpdateEvent, QBDExpenseGroupedBy, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model'; import { QbdDirectExportSettingGet, QbdDirectExportSettingModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-export-settings.model'; import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; import { TrackingService } from 'src/app/core/services/integration/tracking.service'; @@ -83,6 +83,8 @@ export class QbdDirectExportSettingsComponent implements OnInit{ private optionSearchUpdate = new Subject(); + sessionStartTime: Date = new Date(); + constructor( private router: Router, private exportSettingService: QbdDirectExportSettingsService, @@ -173,10 +175,29 @@ export class QbdDirectExportSettingsComponent implements OnInit{ } } + private getPhase(): ProgressPhase { + return this.isOnboarding ? ProgressPhase.ONBOARDING : ProgressPhase.POST_ONBOARDING; + } + save() { this.isSaveInProgress = true; const exportSettingPayload = QbdDirectExportSettingModel.constructPayload(this.exportSettingsForm); this.exportSettingService.postQbdExportSettings(exportSettingPayload).subscribe((response: QbdDirectExportSettingGet) => { + this.trackingService.trackTimeSpent(TrackingApp.QBD_DIRECT, Page.EXPORT_SETTING_QBD_DIRECT, this.sessionStartTime); + if (this.workspaceService.getOnboardingState() === QbdDirectOnboardingState.EXPORT_SETTINGS) { + this.trackingService.integrationsOnboardingCompletion(TrackingApp.QBD_DIRECT, QbdDirectOnboardingState.EXPORT_SETTINGS, 3, exportSettingPayload); + } else { + this.trackingService.onUpdateEvent( + TrackingApp.QBD_DIRECT, + QbdDirectUpdateEvent.EXPORT_SETTING_QBD_DIRECT, + { + phase: this.getPhase(), + oldState: this.exportSettings, + newState: response + } + ); + } + this.isSaveInProgress = false; this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Export settings saved successfully'); diff --git a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-import-settings/qbd-direct-import-settings.component.ts b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-import-settings/qbd-direct-import-settings.component.ts index 6e4488d1e..afcc33078 100644 --- a/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-import-settings/qbd-direct-import-settings.component.ts +++ b/src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-import-settings/qbd-direct-import-settings.component.ts @@ -10,12 +10,13 @@ import { ExpenseField, ImportSettingsModel, ImportCodeFieldConfigType } from 'sr import { SelectFormOption } from 'src/app/core/models/common/select-form-option.model'; import { DefaultDestinationAttribute } from 'src/app/core/models/db/destination-attribute.model'; import { FyleField, IntegrationField } from 'src/app/core/models/db/mapping.model'; -import { AppName, ConfigurationCta, QBDReimbursableExpensesObject, QBDCorporateCreditCardExpensesObject, DefaultImportFields, ToastSeverity, QbdDirectOnboardingState } from 'src/app/core/models/enum/enum.model'; -import { QbdDirectImportSettingGet, QbdDirectImportSettingModel } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.model'; +import { AppName, ConfigurationCta, QBDReimbursableExpensesObject, QBDCorporateCreditCardExpensesObject, DefaultImportFields, ToastSeverity, QbdDirectOnboardingState, ProgressPhase, QbdDirectUpdateEvent, TrackingApp, Page } from 'src/app/core/models/enum/enum.model'; +import { QbdDirectImportSettingGet, QbdDirectImportSettingModel, QbdDirectImportSettingPost } from 'src/app/core/models/qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.model'; import { HelperService } from 'src/app/core/services/common/helper.service'; import { IntegrationsToastService } from 'src/app/core/services/common/integrations-toast.service'; import { MappingService } from 'src/app/core/services/common/mapping.service'; import { WorkspaceService } from 'src/app/core/services/common/workspace.service'; +import { TrackingService } from 'src/app/core/services/integration/tracking.service'; import { QbdDirectAdvancedSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-advanced-settings.service'; import { QbdDirectImportSettingsService } from 'src/app/core/services/qbd-direct/qbd-direct-configuration/qbd-direct-import-settings.service'; import { QbdDirectHelperService } from 'src/app/core/services/qbd-direct/qbd-direct-core/qbd-direct-helper.service'; @@ -105,7 +106,7 @@ export class QbdDirectImportSettingsComponent implements OnInit { ] }; - workspaceGeneralSettings: any; + sessionStartTime: Date = new Date(); constructor( private formBuilder: FormBuilder, @@ -116,7 +117,8 @@ export class QbdDirectImportSettingsComponent implements OnInit { private workspaceService: WorkspaceService, private advancedSettingsService: QbdDirectAdvancedSettingsService, private qbdDirectHelperService: QbdDirectHelperService, - public helper: HelperService + public helper: HelperService, + private trackingService: TrackingService ) { } closeModel() { @@ -235,10 +237,29 @@ export class QbdDirectImportSettingsComponent implements OnInit { }); } + private getPhase(): ProgressPhase { + return this.isOnboarding ? ProgressPhase.ONBOARDING : ProgressPhase.POST_ONBOARDING; + } + save(): void { this.isSaveInProgress = true; const importSettingPayload = QbdDirectImportSettingModel.constructPayload(this.importSettingForm); - this.importSettingService.postImportSettings(importSettingPayload).subscribe(() => { + this.importSettingService.postImportSettings(importSettingPayload).subscribe((response: QbdDirectImportSettingPost) => { + this.trackingService.trackTimeSpent(TrackingApp.QBD_DIRECT, Page.IMPORT_SETTINGS_QBD_DIRECT, this.sessionStartTime); + if (this.workspaceService.getOnboardingState() === QbdDirectOnboardingState.IMPORT_SETTINGS) { + this.trackingService.integrationsOnboardingCompletion(TrackingApp.QBD_DIRECT, QbdDirectOnboardingState.IMPORT_SETTINGS, 4, importSettingPayload); + } else { + this.trackingService.onUpdateEvent( + TrackingApp.QBD_DIRECT, + QbdDirectUpdateEvent.IMPORT_SETTINGS_QBD_DIRECT, + { + phase: this.getPhase(), + oldState: this.importSettings, + newState: response + } + ); + } + this.isSaveInProgress = false; this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Import settings saved successfully'); this.updateImportCodeFieldConfig();