Skip to content

Commit

Permalink
Prepend app names to event trackers
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin1111 committed Jan 16, 2024
1 parent a98dad3 commit 28734ca
Show file tree
Hide file tree
Showing 54 changed files with 195 additions and 126 deletions.
13 changes: 13 additions & 0 deletions src/app/core/models/enum/enum.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,3 +610,16 @@ export enum InputType {
TOGGLE = 'TOGGLE',
MULTI_SELECT = 'MULTI_SELECT',
}

export enum TrackingApp {
QBO = 'QBO',
NETSUITE = 'NS',
XERO = 'XERO',
INTACCT = 'SI',
SAGE300 = 'SAGE300',
BUSINESS_CENTRAL = 'BC',
QBD = 'QBD',
BAMBOO_HR = 'BHR',
TRAVELPERK = 'TP',
GUSTO = 'GUSTO'
}
26 changes: 24 additions & 2 deletions src/app/core/models/misc/tracking.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BusinessCentralAdvancedSettingsGet } from "../business-central/business-central-configuration/business-central-advanced-settings.model";
import { BusinessCentralExportSettingGet } from "../business-central/business-central-configuration/business-central-export-setting.model";
import { BusinessCentralImportSettingsGet } from "../business-central/business-central-configuration/business-central-import-settings.model";
import { AccountingErrorType, IntacctErrorType, ProgressPhase } from "../enum/enum.model";
import { AccountingErrorType, AppName, IntacctErrorType, ProgressPhase, TrackingApp } from "../enum/enum.model";
import { QBDAdvancedSettingsGet } from "../qbd/qbd-configuration/advanced-setting.model";
import { QBDExportSettingGet } from "../qbd/qbd-configuration/export-setting.model";
import { QBDFieldMappingGet } from "../qbd/qbd-configuration/field-mapping.model";
Expand Down Expand Up @@ -39,4 +39,26 @@ export type ResolveMappingErrorProperty = {
endTime: Date,
durationInSeconds: number,
errorType: IntacctErrorType | AccountingErrorType
};
};

export type TrackingAppMap = {
[AppName.BUSINESS_CENTRAL]: TrackingApp.BUSINESS_CENTRAL,
[AppName.SAGE300]: TrackingApp.SAGE300,
[AppName.QBD]: TrackingApp.QBD,
[AppName.BAMBOO_HR]: TrackingApp.BAMBOO_HR,
[AppName.INTACCT]: TrackingApp.INTACCT,
[AppName.QBO]: TrackingApp.QBO,
[AppName.TRAVELPERK]: TrackingApp.TRAVELPERK,
[AppName.GUSTO]: TrackingApp.GUSTO,
}

export const trackingAppMap: TrackingAppMap = {
[AppName.BUSINESS_CENTRAL]: TrackingApp.BUSINESS_CENTRAL,
[AppName.SAGE300]: TrackingApp.SAGE300,
[AppName.QBD]: TrackingApp.QBD,
[AppName.BAMBOO_HR]: TrackingApp.BAMBOO_HR,
[AppName.INTACCT]: TrackingApp.INTACCT,
[AppName.QBO]: TrackingApp.QBO,
[AppName.TRAVELPERK]: TrackingApp.TRAVELPERK,
[AppName.GUSTO]: TrackingApp.GUSTO
};
44 changes: 20 additions & 24 deletions src/app/core/services/integration/tracking.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { BusinessCentralOnboardingState, BusinessCentralUpdateEvent, ClickEvent, IntacctOnboardingState, IntacctUpdateEvent, Page, QBDOnboardingState, Sage300OnboardingState, Sage300UpdateEvent, UpdateEvent } from '../../models/enum/enum.model';
import { BusinessCentralOnboardingState, BusinessCentralUpdateEvent, ClickEvent, IntacctOnboardingState, IntacctUpdateEvent, Page, QBDOnboardingState, Sage300OnboardingState, Sage300UpdateEvent, TrackingApp, UpdateEvent } from '../../models/enum/enum.model';
import { MappingAlphabeticalFilterAdditionalProperty, ResolveMappingErrorProperty, UpdateEventAdditionalProperty, UpdateIntacctEventAdditionalProperty } from '../../models/misc/tracking.model';
import { QBDAdvancedSettingsPost } from '../../models/qbd/qbd-configuration/advanced-setting.model';
import { QBDExportSettingPost } from '../../models/qbd/qbd-configuration/export-setting.model';
Expand Down Expand Up @@ -52,14 +52,14 @@ export class TrackingService {
return (window as any).analytics;
}

eventTrack(action: string, properties: any = {}): void {
eventTrack(action: string, trackingApp?: TrackingApp, properties: any = {}): void {
const flattenedObject = this.flattenObject(properties);
properties = {
...flattenedObject,
Asset: 'Integration Settings Web'
};
if (this.tracking) {
this.tracking.track(action, properties);
this.tracking.track(`${trackingApp ? trackingApp : 'Integration Settings Web'}: ${action}`, properties);
}
}

Expand All @@ -75,44 +75,40 @@ export class TrackingService {
this.eventTrack('Opened Landing Page');
}

onClickEvent(eventName: ClickEvent): void {
this.eventTrack(`Click event: ${eventName}`);
onClickEvent(trackingApp: TrackingApp, eventName: ClickEvent): void {
this.eventTrack(`Click event: ${eventName}`, trackingApp, {});
}

onErrorPage(): void {
this.eventTrack('Error Page shown');
}

trackTimeSpent(page: Page, sessionStartTime: Date): void {
trackTimeSpent(trackingApp: TrackingApp, page: Page, sessionStartTime: Date): void {
const differenceInMs = new Date().getTime() - sessionStartTime.getTime();
this.eventTrack(`Time Spent on ${page} page`, {durationInSeconds: differenceInMs / 1000});
this.eventTrack(`Time Spent on ${page} page`, trackingApp, {durationInSeconds: differenceInMs / 1000});
}

onOnboardingStepCompletion(eventName: QBDOnboardingState | Sage300OnboardingState | BusinessCentralOnboardingState, stepNumber: number, additionalProperties: QBDExportSettingPost | QBDFieldMappingPost | QBDAdvancedSettingsPost | void | Sage300ExportSettingPost | Sage300ImportSettingPost | Sage300AdvancedSettingPost | BusinessCentralExportSettingPost | BusinessCentralImportSettingsPost |BusinessCentralAdvancedSettingsPost ): void {
this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, additionalProperties);
onOnboardingStepCompletion(trackingApp: TrackingApp, eventName: QBDOnboardingState | Sage300OnboardingState | BusinessCentralOnboardingState, stepNumber: number, additionalProperties: QBDExportSettingPost | QBDFieldMappingPost | QBDAdvancedSettingsPost | void | Sage300ExportSettingPost | Sage300ImportSettingPost | Sage300AdvancedSettingPost | BusinessCentralExportSettingPost | BusinessCentralImportSettingsPost |BusinessCentralAdvancedSettingsPost ): void {
this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, trackingApp, additionalProperties);
}

integrationsOnboardingCompletion(eventName: IntacctOnboardingState, stepNumber: number, additionalProperties: LocationEntityPost | ExportSettingPost | ImportSettingPost | AdvancedSettingsPost | void): void {
this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, additionalProperties);
integrationsOnboardingCompletion(trackingApp: TrackingApp, eventName: IntacctOnboardingState, stepNumber: number, additionalProperties: LocationEntityPost | ExportSettingPost | ImportSettingPost | AdvancedSettingsPost | void): void {
this.eventTrack(`Step ${stepNumber} completed: ${eventName}`, trackingApp, additionalProperties);
}

onUpdateEvent(eventName: UpdateEvent | Sage300UpdateEvent | BusinessCentralUpdateEvent, additionalProperties: Partial<UpdateEventAdditionalProperty> | void): void {
this.eventTrack(`Update event: ${eventName}`, additionalProperties);
onUpdateEvent(trackingApp: TrackingApp, eventName: UpdateEvent | Sage300UpdateEvent | BusinessCentralUpdateEvent, additionalProperties: Partial<UpdateEventAdditionalProperty> | void): void {
this.eventTrack(`Update event: ${eventName}`, trackingApp, additionalProperties);
}

intacctUpdateEvent (eventName: IntacctUpdateEvent, additionalProperties: Partial<UpdateIntacctEventAdditionalProperty> | void): void {
this.eventTrack(`Update event: ${eventName}`, additionalProperties);
this.eventTrack(`Update event: ${eventName}`, TrackingApp.INTACCT, additionalProperties);
}

onDateFilter(properties: {filterType: 'existing' | 'custom', startDate: Date, endDate: Date}): void {
this.eventTrack('Date filter', properties);
onDateFilter(trackingApp: TrackingApp, properties: {filterType: 'existing' | 'custom', startDate: Date, endDate: Date}): void {
this.eventTrack('Date filter', trackingApp, properties);
}

onMappingsAlphabeticalFilter(properties: MappingAlphabeticalFilterAdditionalProperty): void {
this.eventTrack('Mappings Alphabetical Filter', properties);
onMappingsAlphabeticalFilter(trackingApp: TrackingApp, properties: MappingAlphabeticalFilterAdditionalProperty): void {
this.eventTrack('Mappings Alphabetical Filter', trackingApp, properties);
}

onErrorResolve(properties: ResolveMappingErrorProperty): void {
this.eventTrack('Resolve Mapping Error', properties);
onErrorResolve(trackingApp: TrackingApp, properties: ResolveMappingErrorProperty): void {
this.eventTrack('Resolve Mapping Error', trackingApp, properties);
}
}
14 changes: 7 additions & 7 deletions src/app/integrations/bamboo-hr/bamboo-hr.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MessageService } from 'primeng/api';
import { catchError, concat, merge, of, toArray } from 'rxjs';
import { brandingConfig, brandingKbArticles } from 'src/app/branding/branding-config';
import { BambooHr, BambooHRConfiguration, BambooHRConfigurationPost, BambooHrModel, EmailOption } from 'src/app/core/models/bamboo-hr/bamboo-hr.model';
import { ClickEvent, Page, ToastSeverity } from 'src/app/core/models/enum/enum.model';
import { ClickEvent, Page, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { Org } from 'src/app/core/models/org/org.model';
import { BambooHrService } from 'src/app/core/services/bamboo-hr/bamboo-hr.service';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
Expand Down Expand Up @@ -61,7 +61,7 @@ export class BambooHrComponent implements OnInit {
) { }

openDialog(): void {
this.trackingService.onClickEvent(ClickEvent.CONNECT_BAMBOO_HR);
this.trackingService.onClickEvent(TrackingApp.BAMBOO_HR, ClickEvent.CONNECT_BAMBOO_HR);
this.showDialog = true;
}

Expand All @@ -81,7 +81,7 @@ export class BambooHrComponent implements OnInit {
this.isBambooConnectionInProgress = false;
this.showDialog = false;
this.displayToastMessage(ToastSeverity.SUCCESS, 'Connected Bamboo HR Successfully');
this.trackingService.trackTimeSpent(Page.BAMBOO_HR_LANDING, this.sessionStartTime);
this.trackingService.trackTimeSpent(TrackingApp.BAMBOO_HR, Page.BAMBOO_HR_LANDING, this.sessionStartTime);
this.sessionStartTime = new Date();
}, () => {
this.displayToastMessage(ToastSeverity.ERROR, 'Connecting Bamboo HR Failed', 5000);
Expand All @@ -94,19 +94,19 @@ export class BambooHrComponent implements OnInit {
}

configurationUpdatesHandler(payload: BambooHRConfigurationPost): void {
this.trackingService.onClickEvent(ClickEvent.CONFIGURE_BAMBOO_HR);
this.trackingService.onClickEvent(TrackingApp.BAMBOO_HR, ClickEvent.CONFIGURE_BAMBOO_HR);
this.isConfigurationSaveInProgress = true;
this.bambooHrService.postConfigurations(payload).subscribe((updatedConfiguration: BambooHRConfiguration) => {
this.bambooHrConfiguration = updatedConfiguration;
this.hideRefreshIcon = false;
this.isConfigurationSaveInProgress = false;
this.displayToastMessage(ToastSeverity.SUCCESS, 'Configuration saved successfully');
this.trackingService.trackTimeSpent(Page.CONFIGURE_BAMBOO_HR, this.sessionStartTime);
this.trackingService.trackTimeSpent(TrackingApp.BAMBOO_HR, Page.CONFIGURE_BAMBOO_HR, this.sessionStartTime);
});
}

syncEmployees(): void {
this.trackingService.onClickEvent(ClickEvent.SYNC_BAMBOO_HR_EMPLOYEES);
this.trackingService.onClickEvent(TrackingApp.BAMBOO_HR, ClickEvent.SYNC_BAMBOO_HR_EMPLOYEES);
this.hideRefreshIcon = true;
this.displayToastMessage(ToastSeverity.SUCCESS, 'Syncing Employees Started');
this.bambooHrService.syncEmployees().subscribe(() => {
Expand All @@ -115,7 +115,7 @@ export class BambooHrComponent implements OnInit {
}

disconnectBambooHr(): void {
this.trackingService.onClickEvent(ClickEvent.DISCONNECT_BAMBOO_HR);
this.trackingService.onClickEvent(TrackingApp.BAMBOO_HR, ClickEvent.DISCONNECT_BAMBOO_HR);
this.isLoading = true;
this.bambooHrService.disconnectBambooHr().subscribe(() => {
this.displayToastMessage(ToastSeverity.SUCCESS, 'Disconnected Bamboo HR Successfully');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DropdownFilterOptions } from 'primeng/dropdown';
import { brandingConfig } from 'src/app/branding/branding-config';
import { BambooHRConfiguration, BambooHRConfigurationPost, BambooHrModel, EmailOption } from 'src/app/core/models/bamboo-hr/bamboo-hr.model';
import { ClickEvent } from 'src/app/core/models/enum/enum.model';
import { ClickEvent, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { Org } from 'src/app/core/models/org/org.model';
import { TrackingService } from 'src/app/core/services/integration/tracking.service';
import { OrgService } from 'src/app/core/services/org/org.service';
Expand Down Expand Up @@ -62,7 +62,7 @@ export class ConfigurationComponent implements OnInit {
}

addEmail(): void {
this.trackingService.onClickEvent(ClickEvent.ADD_BAMBOO_HR_EMAIL_MANUALLY);
this.trackingService.onClickEvent(TrackingApp.BAMBOO_HR, ClickEvent.ADD_BAMBOO_HR_EMAIL_MANUALLY);
const selectedEmails = this.cofigurationForm.value.emails || [];
selectedEmails.push(this.addEmailForm.value);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { AccountingExport, AccountingExportList, AccountingExportModel } from 'src/app/core/models/db/accounting-export.model';
import { AccountingExportStatus, AccountingExportType, AppName, BusinessCentralExportType, PaginatorPage } from 'src/app/core/models/enum/enum.model';
import { AccountingExportStatus, AccountingExportType, AppName, BusinessCentralExportType, PaginatorPage, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { Paginator } from 'src/app/core/models/misc/paginator.model';
import { DateFilter, SelectedDateFilter } from 'src/app/core/models/qbd/misc/date-filter.model';
import { Expense } from 'src/app/core/models/si/db/expense.model';
Expand Down Expand Up @@ -109,7 +109,7 @@ export class BusinessCentralCompleteExportLogComponent implements OnInit {
filterType,
...selectedDateFilter
};
this.trackingService.onDateFilter(trackingProperty);
this.trackingService.onDateFilter(TrackingApp.BUSINESS_CENTRAL, trackingProperty);
}

private setupForm(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { AccountingExportModel, SkippedAccountingExportModel } from 'src/app/core/models/db/accounting-export.model';
import { PaginatorPage } from 'src/app/core/models/enum/enum.model';
import { PaginatorPage, TrackingApp } from 'src/app/core/models/enum/enum.model';
import { Paginator } from 'src/app/core/models/misc/paginator.model';
import { DateFilter, SelectedDateFilter } from 'src/app/core/models/qbd/misc/date-filter.model';
import { SkipExportList, SkipExportLog, SkipExportLogResponse } from 'src/app/core/models/si/db/expense-group.model';
Expand Down Expand Up @@ -130,7 +130,7 @@ export class BusinessCentralSkippedExportLogComponent implements OnInit {
filterType,
...selectedDateFilter
};
this.trackingService.onDateFilter(trackingProperty);
this.trackingService.onDateFilter(TrackingApp.BUSINESS_CENTRAL, trackingProperty);
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div *ngIf="advancedSettingForm.value.scheduleEnabled">
<app-configuration-schedule-export
[form]="advancedSettingForm"
[appName]="appName"
[isFieldMandatory]="false"
[mandatoryErrorListName]="'automatic export method'"
[label]="'Set up export frequency'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { TrackingService } from 'src/app/core/services/integration/tracking.serv
import { BusinessCentralAdvancedSettingsGet, BusinessCentralAdvancedSettingsModel } from 'src/app/core/models/business-central/business-central-configuration/business-central-advanced-settings.model';
import { FormGroup } from '@angular/forms';
import { brandingConfig, brandingKbArticles } from 'src/app/branding/branding-config';
import { AppName, BusinessCentralOnboardingState, BusinessCentralUpdateEvent, ConfigurationCta, Page, ToastSeverity } from 'src/app/core/models/enum/enum.model';
import { AppName, BusinessCentralOnboardingState, BusinessCentralUpdateEvent, ConfigurationCta, Page, ToastSeverity, TrackingApp } from 'src/app/core/models/enum/enum.model';

@Component({
selector: 'app-business-central-advanced-settings',
Expand All @@ -39,7 +39,7 @@ export class BusinessCentralAdvancedSettingsComponent implements OnInit {

isOnboarding: boolean;

appName: string = AppName.BUSINESS_CENTRAL;
appName: AppName = AppName.BUSINESS_CENTRAL;

hours: HourOption[] = [];

Expand Down Expand Up @@ -143,11 +143,12 @@ export class BusinessCentralAdvancedSettingsComponent implements OnInit {
this.advancedSettingsService.postAdvancedSettings(advancedSettingPayload).subscribe((advancedSettingsResponse: BusinessCentralAdvancedSettingsGet) => {
this.isSaveInProgress = false;
this.toastService.displayToastMessage(ToastSeverity.SUCCESS, 'Advanced settings saved successfully');
this.trackingService.trackTimeSpent(Page.ADVANCED_SETTINGS_BUSINESS_CENTRAL, this.sessionStartTime);
this.trackingService.trackTimeSpent(TrackingApp.BUSINESS_CENTRAL, Page.ADVANCED_SETTINGS_BUSINESS_CENTRAL, this.sessionStartTime);
if (this.workspaceService.getOnboardingState() === BusinessCentralOnboardingState.ADVANCED_SETTINGS) {
this.trackingService.onOnboardingStepCompletion(BusinessCentralOnboardingState.ADVANCED_SETTINGS, 3, advancedSettingPayload);
this.trackingService.onOnboardingStepCompletion(TrackingApp.BUSINESS_CENTRAL, BusinessCentralOnboardingState.ADVANCED_SETTINGS, 3, advancedSettingPayload);
} else {
this.trackingService.onUpdateEvent(
TrackingApp.BUSINESS_CENTRAL,
BusinessCentralUpdateEvent.ADVANCED_SETTINGS_BUSINESS_CENTRAL,
{
phase: this.helper.getPhase(this.isOnboarding),
Expand Down
Loading

0 comments on commit 28734ca

Please sign in to comment.