From 45799ee2c6bce882b2775fcd86ac154a67f63f9f Mon Sep 17 00:00:00 2001 From: Lars Saalbach Date: Wed, 18 Dec 2024 20:28:53 +0100 Subject: [PATCH] Adding some more analytics --- ...internal-share-code-generator.component.ts | 15 +++++-- src/app/beans/beans.page.ts | 4 ++ src/app/brew/brew-add/brew-add.component.ts | 39 ++++++++++++------- src/app/brew/brew-edit/brew-edit.component.ts | 26 +++++++++---- .../preparation-add-type.component.ts | 19 +++++++-- src/data/tracking/beanTracking.ts | 2 + src/data/tracking/bluetoothTracking.ts | 14 +++++++ src/data/tracking/brewTracking.ts | 4 ++ src/data/tracking/intentHandlerTracking.ts | 9 +++++ src/data/tracking/preparationTracking.ts | 2 + ...etooth-device-chooser-popover.component.ts | 25 ++++++++++-- .../coffee-bluetooth-devices.service.ts | 24 +++++++++++- .../intentHandler/intent-handler.service.ts | 22 ++++++++++- src/services/uiAnalytics.ts | 23 +++++------ 14 files changed, 180 insertions(+), 48 deletions(-) create mode 100644 src/data/tracking/bluetoothTracking.ts create mode 100644 src/data/tracking/intentHandlerTracking.ts diff --git a/src/app/beans/bean-internal-share-code-generator/bean-internal-share-code-generator.component.ts b/src/app/beans/bean-internal-share-code-generator/bean-internal-share-code-generator.component.ts index bfe812a1b..9e3ad2f93 100644 --- a/src/app/beans/bean-internal-share-code-generator/bean-internal-share-code-generator.component.ts +++ b/src/app/beans/bean-internal-share-code-generator/bean-internal-share-code-generator.component.ts @@ -12,6 +12,8 @@ import { UIBeanStorage } from '../../../services/uiBeanStorage'; import { UILog } from '../../../services/uiLog'; import { BEAN_CODE_ACTION } from '../../../enums/beans/beanCodeAction'; import { NfcService } from '../../../services/nfcService/nfc-service.service'; +import BEAN_TRACKING from '../../../data/tracking/beanTracking'; +import { UIAnalytics } from '../../../services/uiAnalytics'; @Component({ selector: 'app-bean-internal-share-code-generator.', @@ -35,7 +37,8 @@ export class BeanInternalShareCodeGeneratorComponent implements OnInit { private readonly uiAlert: UIAlert, private readonly uiBeanStorage: UIBeanStorage, private readonly uiLog: UILog, - private readonly nfcService: NfcService + private readonly nfcService: NfcService, + private readonly uiAnalytics: UIAnalytics, ) {} ngOnInit() {} @@ -54,11 +57,11 @@ export class BeanInternalShareCodeGeneratorComponent implements OnInit { while (true) { newShareCode = this.uiHelper.generateShortUUID().toUpperCase(); const indexFound = allBeanEntries.findIndex( - (b) => b.internal_share_code === newShareCode + (b) => b.internal_share_code === newShareCode, ); if (indexFound === -1) { this.uiLog.log( - 'Generate QR Code - ' + newShareCode + ' - code not used yet.' + 'Generate QR Code - ' + newShareCode + ' - code not used yet.', ); /** This id isn't used yet**/ break; @@ -92,6 +95,10 @@ export class BeanInternalShareCodeGeneratorComponent implements OnInit { this.shareService.shareImage(this.imageSrc); } public writeNFC() { + this.uiAnalytics.trackEvent( + BEAN_TRACKING.TITLE, + BEAN_TRACKING.ACTIONS.NFC_WRITE, + ); this.nfcService.writeNFCData(this.qrData); } @@ -103,7 +110,7 @@ export class BeanInternalShareCodeGeneratorComponent implements OnInit { this.modalController.dismiss( undefined, undefined, - BeanInternalShareCodeGeneratorComponent.COMPONENT_ID + BeanInternalShareCodeGeneratorComponent.COMPONENT_ID, ); } diff --git a/src/app/beans/beans.page.ts b/src/app/beans/beans.page.ts index a01b8e95b..6f71f4fc4 100644 --- a/src/app/beans/beans.page.ts +++ b/src/app/beans/beans.page.ts @@ -332,6 +332,10 @@ export class BeansPage implements OnDestroy { public async scanNFC() { if (this.platform.is('capacitor')) { try { + this.uiAnalytics.trackEvent( + BEAN_TRACKING.TITLE, + BEAN_TRACKING.ACTIONS.NFC_SCAN, + ); await this.nfcService.readNFCTag(); } catch (error) { // Just log and do nothing else, it's likely the user just cancelled diff --git a/src/app/brew/brew-add/brew-add.component.ts b/src/app/brew/brew-add/brew-add.component.ts index 4f73ee30b..166f2896b 100644 --- a/src/app/brew/brew-add/brew-add.component.ts +++ b/src/app/brew/brew-add/brew-add.component.ts @@ -99,7 +99,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { private readonly visualizerService: VisualizerService, private readonly changeDetectorRef: ChangeDetectorRef, private readonly hapticService: HapticService, - private readonly uiHelper: UIHelper + private readonly uiHelper: UIHelper, ) { // Initialize to standard in drop down this.settings = this.uiSettingsStorage.getSettings(); @@ -178,7 +178,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { }, () => { // No - } + }, ); } else { this.dismiss(); @@ -238,7 +238,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { this.data.coordinates.speed = resp.coords.speed; this.data.coordinates.longitude = resp.coords.longitude; this.uiLog.info( - 'BREW - Coordinates found - ' + JSON.stringify(this.data.coordinates) + 'BREW - Coordinates found - ' + JSON.stringify(this.data.coordinates), ); } catch (error) { this.uiLog.error('BREW - No Coordinates found: ', error); @@ -272,7 +272,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { try { if (this.brewBrewing.brewBrewingGraphEl) { Plotly.purge( - this.brewBrewing.brewBrewingGraphEl.profileDiv.nativeElement + this.brewBrewing.brewBrewingGraphEl.profileDiv.nativeElement, ); } } catch (ex) {} @@ -281,7 +281,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { dismissed: true, }, undefined, - BrewAddComponent.COMPONENT_ID + BrewAddComponent.COMPONENT_ID, ); } @@ -327,14 +327,25 @@ export class BrewAddComponent implements OnInit, OnDestroy { if (this.uiBrewHelper.checkIfBeanPackageIsConsumed(this.data.getBean())) { await this.uiBrewHelper.checkIfBeanPackageIsConsumedTriggerMessageAndArchive( - this.data.getBean() + this.data.getBean(), ); } this.uiAnalytics.trackEvent( BREW_TRACKING.TITLE, - BREW_TRACKING.ACTIONS.ADD_FINISH + BREW_TRACKING.ACTIONS.ADD_FINISH, + ); + this.uiAnalytics.trackEvent( + BREW_TRACKING.TITLE, + BREW_TRACKING.ACTIONS.ADD_FINISH_PREPARATION_TYPE, + addedBrewObj.getPreparation().type, ); + this.uiAnalytics.trackEvent( + BREW_TRACKING.TITLE, + BREW_TRACKING.ACTIONS.ADD_FINISH_PREPARATION_STYLE, + addedBrewObj.getPreparation().style_type, + ); + if ( this.brewBrewing?.brewBrewingPreparationDeviceEl?.getDataPreparationDeviceType() === PreparationDeviceType.XENIA @@ -349,11 +360,11 @@ export class BrewAddComponent implements OnInit, OnDestroy { await this.uiBrewStorage.update(addedBrewObj); } catch (ex) { this.uiLog.log( - 'We could not get the logs from xenia: ' + JSON.stringify(ex) + 'We could not get the logs from xenia: ' + JSON.stringify(ex), ); this.uiToast.showInfoToast( 'We could not get the logs from xenia: ' + JSON.stringify(ex), - false + false, ); } } @@ -375,7 +386,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { ) { this.uiHealthKit.trackCaffeineConsumption( this.data.getCaffeineAmount(), - moment(this.brewBrewing.customCreationDate).toDate() + moment(this.brewBrewing.customCreationDate).toDate(), ); } } @@ -420,7 +431,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { if (checkData.manage_parameters.set_custom_brew_time) { this.uiLog.log('Brew add - Step 6'); addedBrewObj.config.unix_timestamp = moment( - this.brewBrewing.customCreationDate + this.brewBrewing.customCreationDate, ).unix(); await this.uiBrewStorage.update(addedBrewObj); } @@ -438,7 +449,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { if (this.hasAnyFlowProfileRequisites()) { this.uiLog.log('Brew add - Step 5'); const savedPath: string = await this.brewBrewing.saveFlowProfile( - addedBrewObj.config.uuid + addedBrewObj.config.uuid, ); if (savedPath !== '') { addedBrewObj.flow_profile = savedPath; @@ -458,7 +469,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { addedBrewObj.reference_flow_profile.type === REFERENCE_GRAPH_TYPE.NONE ) { const path = await this.brewBrewing.saveReferenceFlowProfile( - addedBrewObj.config.uuid + addedBrewObj.config.uuid, ); addedBrewObj.reference_flow_profile = new ReferenceGraph(); @@ -503,7 +514,7 @@ export class BrewAddComponent implements OnInit, OnDestroy { (_processNextHandler) => { // Don't do anything. this.confirmDismiss(); - } + }, ); } } diff --git a/src/app/brew/brew-edit/brew-edit.component.ts b/src/app/brew/brew-edit/brew-edit.component.ts index 045cda3b9..b43803949 100644 --- a/src/app/brew/brew-edit/brew-edit.component.ts +++ b/src/app/brew/brew-edit/brew-edit.component.ts @@ -61,7 +61,7 @@ export class BrewEditComponent implements OnInit { private readonly bleManager: CoffeeBluetoothDevicesService, private readonly uiAlert: UIAlert, private readonly visualizerService: VisualizerService, - private readonly hapticService: HapticService + private readonly hapticService: HapticService, ) { this.settings = this.uiSettingsStorage.getSettings(); // Moved from ionViewDidEnter, because of Ionic issues with ion-range @@ -104,7 +104,7 @@ export class BrewEditComponent implements OnInit { }, () => { // No - } + }, ); } else { this.dismiss(); @@ -121,7 +121,7 @@ export class BrewEditComponent implements OnInit { try { if (this.brewBrewing.brewBrewingGraphEl) { Plotly.purge( - this.brewBrewing.brewBrewingGraphEl.profileDiv.nativeElement + this.brewBrewing.brewBrewingGraphEl.profileDiv.nativeElement, ); } } catch (ex) {} @@ -130,7 +130,7 @@ export class BrewEditComponent implements OnInit { dismissed: true, }, undefined, - BrewEditComponent.COMPONENT_ID + BrewEditComponent.COMPONENT_ID, ); } private stopScaleTimer() { @@ -189,7 +189,7 @@ export class BrewEditComponent implements OnInit { .length > 0 ) { const savedPath: string = await this.brewBrewing.saveFlowProfile( - this.data.config.uuid + this.data.config.uuid, ); if (savedPath !== '') { this.data.flow_profile = savedPath; @@ -212,7 +212,17 @@ export class BrewEditComponent implements OnInit { this.uiToast.showInfoToast('TOAST_BREW_EDITED_SUCCESSFULLY'); this.uiAnalytics.trackEvent( BREW_TRACKING.TITLE, - BREW_TRACKING.ACTIONS.EDIT_FINISH + BREW_TRACKING.ACTIONS.EDIT_FINISH, + ); + this.uiAnalytics.trackEvent( + BREW_TRACKING.TITLE, + BREW_TRACKING.ACTIONS.EDIT_FINISH_PREPARATION_TYPE, + this.data.getPreparation().type, + ); + this.uiAnalytics.trackEvent( + BREW_TRACKING.TITLE, + BREW_TRACKING.ACTIONS.EDIT_FINISH_PREPARATION_STYLE, + this.data.getPreparation().style_type, ); this.dismiss(); } @@ -235,7 +245,7 @@ export class BrewEditComponent implements OnInit { } this.uiAnalytics.trackEvent( BREW_TRACKING.TITLE, - BREW_TRACKING.ACTIONS.EDIT + BREW_TRACKING.ACTIONS.EDIT, ); if (this.settings.security_check_when_going_back === true) { this.disableHardwareBack = this.platform.backButton.subscribeWithPriority( @@ -243,7 +253,7 @@ export class BrewEditComponent implements OnInit { (processNextHandler) => { // Don't do anything. this.confirmDismiss(); - } + }, ); } } diff --git a/src/app/preparation/preparation-add-type/preparation-add-type.component.ts b/src/app/preparation/preparation-add-type/preparation-add-type.component.ts index 5cf7e7cd6..8cedde088 100644 --- a/src/app/preparation/preparation-add-type/preparation-add-type.component.ts +++ b/src/app/preparation/preparation-add-type/preparation-add-type.component.ts @@ -37,13 +37,13 @@ export class PreparationAddTypeComponent implements OnInit { private readonly uiToast: UIToast, private readonly translate: TranslateService, private readonly uiAnalytics: UIAnalytics, - private readonly uiPreparationHelper: UIPreparationHelper + private readonly uiPreparationHelper: UIPreparationHelper, ) {} public ionViewWillEnter(): void { this.uiAnalytics.trackEvent( PREPARATION_TRACKING.TITLE, - PREPARATION_TRACKING.ACTIONS.ADD_TYPE + PREPARATION_TRACKING.ACTIONS.ADD_TYPE, ); } @@ -77,6 +77,17 @@ export class PreparationAddTypeComponent implements OnInit { ) { await this.uiPreparationHelper.connectDevice(newPreparation); } + + this.uiAnalytics.trackEvent( + PREPARATION_TRACKING.TITLE, + PREPARATION_TRACKING.ACTIONS.ADD_TYPE_FINISH, + this.data.type, + ); + this.uiAnalytics.trackEvent( + PREPARATION_TRACKING.TITLE, + PREPARATION_TRACKING.ACTIONS.ADD_STYLE_FINISH, + this.data.style_type, + ); } public async dismiss(_added: boolean) { @@ -86,7 +97,7 @@ export class PreparationAddTypeComponent implements OnInit { added: _added, }, undefined, - PreparationAddTypeComponent.COMPONENT_ID + PreparationAddTypeComponent.COMPONENT_ID, ); } @@ -95,7 +106,7 @@ export class PreparationAddTypeComponent implements OnInit { if (this.data.type !== PREPARATION_TYPES.CUSTOM_PREPARATION) { this.data.name = this.translate.instant( - 'PREPARATION_TYPE_' + this.data.type + 'PREPARATION_TYPE_' + this.data.type, ); } this.data.style_type = this.data.getPresetStyleType(); diff --git a/src/data/tracking/beanTracking.ts b/src/data/tracking/beanTracking.ts index 3401edddd..d93cf13dd 100644 --- a/src/data/tracking/beanTracking.ts +++ b/src/data/tracking/beanTracking.ts @@ -18,5 +18,7 @@ export default { SHOW_BREWS: 'SHOW_BREWS', CUPPING: 'CUPPING', UNARCHIVE: 'UNARCHIVE', + NFC_SCAN: 'NFC_SCAN', + NFC_WRITE: 'NFC_WRITE', }, }; diff --git a/src/data/tracking/bluetoothTracking.ts b/src/data/tracking/bluetoothTracking.ts new file mode 100644 index 000000000..9bb3ed0e1 --- /dev/null +++ b/src/data/tracking/bluetoothTracking.ts @@ -0,0 +1,14 @@ +export default { + TITLE: 'BLUETOOTH', + ACTIONS: { + SCALE_CONNECTED: 'SCALE_CONNECTED', + PRESSURE_CONNECTED: 'PRESSURE_CONNECTED', + TEMPERATURE_CONNECTED: 'TEMPERATURE_CONNECTED', + REFRACTOMETER_CONNECTED: 'REFRACTOMETER_CONNECTED', + + SCALE_USED: 'SCALE_USED', + PRESSURE_USED: 'PRESSURE_USED', + TEMPERATURE_USED: 'TEMPERATURE_USED', + REFRACTOMETER_USED: 'REFRACTOMETER_USED', + }, +}; diff --git a/src/data/tracking/brewTracking.ts b/src/data/tracking/brewTracking.ts index 9256c8431..6434a2f9a 100644 --- a/src/data/tracking/brewTracking.ts +++ b/src/data/tracking/brewTracking.ts @@ -20,5 +20,9 @@ export default { BRIX_CALCULATION: 'BRIX_CALCULATION', RATIO_CALCULATION: 'RATIO_CALCULATION', EXTRACTION_GRAPH: 'EXTRACTION_GRAPH', + ADD_FINISH_PREPARATION_TYPE: 'ADD_FINISH_PREPARATION_TYPE', + ADD_FINISH_PREPARATION_STYLE: 'ADD_FINISH_PREPARATION_STYLE', + EDIT_FINISH_PREPARATION_TYPE: 'EDIT_FINISH_PREPARATION_TYPE', + EDIT_FINISH_PREPARATION_STYLE: 'EDIT_FINISH_PREPARATION_STYLE', }, }; diff --git a/src/data/tracking/intentHandlerTracking.ts b/src/data/tracking/intentHandlerTracking.ts new file mode 100644 index 000000000..ce15de753 --- /dev/null +++ b/src/data/tracking/intentHandlerTracking.ts @@ -0,0 +1,9 @@ +export default { + TITLE: 'INTENT_HANDLER', + ACTIONS: { + VISUALIZER_IMPORT: 'VISUALIZER_IMPORT', + IMPORT_ROASTER_BEAN: 'IMPORT_ROASTER_BEAN', + ADD_USER_SHARED_BEAN: 'ADD_USER_SHARED_BEAN', + INTERNAL_CALL: 'INTERNAL_CALL', + }, +}; diff --git a/src/data/tracking/preparationTracking.ts b/src/data/tracking/preparationTracking.ts index 2eb91cd98..8f1d502c9 100644 --- a/src/data/tracking/preparationTracking.ts +++ b/src/data/tracking/preparationTracking.ts @@ -4,6 +4,8 @@ export default { ADD: 'ADD', ADD_FINISH: 'ADD_FINISH', ADD_TYPE: 'ADD_TYPE', + ADD_TYPE_FINISH: 'ADD_TYPE_FINISH', + ADD_STYLE_FINISH: 'ADD_STYLE_FINISH', POPOVER_ACTIONS: 'POPOVER_ACTIONS', REPEAT: 'REPEAT', EDIT: 'EDIT', diff --git a/src/popover/bluetooth-device-chooser-popover/bluetooth-device-chooser-popover.component.ts b/src/popover/bluetooth-device-chooser-popover/bluetooth-device-chooser-popover.component.ts index 2eede90e5..95701861b 100644 --- a/src/popover/bluetooth-device-chooser-popover/bluetooth-device-chooser-popover.component.ts +++ b/src/popover/bluetooth-device-chooser-popover/bluetooth-device-chooser-popover.component.ts @@ -17,6 +17,7 @@ import { UISettingsStorage } from '../../services/uiSettingsStorage'; import { UIAnalytics } from '../../services/uiAnalytics'; import { UIPreparationStorage } from '../../services/uiPreparationStorage'; import { Preparation } from '../../classes/preparation/preparation'; +import BLUETOOTH_TRACKING from '../../data/tracking/bluetoothTracking'; @Component({ selector: 'app-bluetooth-device-chooser-popover', @@ -228,6 +229,12 @@ export class BluetoothDeviceChooserPopoverComponent this.settings.scale_id = scale.id; this.settings.scale_type = scale.type; + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.SCALE_CONNECTED, + scale.type, + ); + if ( scale.type === ScaleType.DIFLUIDMICROBALANCE || scale.type === ScaleType.DIFLUIDMICROBALANCETI @@ -303,7 +310,11 @@ export class BluetoothDeviceChooserPopoverComponent this.settings.pressure_id = pressureDevice.id; this.settings.pressure_type = pressureDevice.type; - + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.PRESSURE_CONNECTED, + pressureDevice.type, + ); //this.uiAnalytics.trackEvent(SETTINGS_TRACKING.TITLE, SETTINGS_TRACKING.ACTIONS.SCALE.CATEGORY,scale.type); await this.saveSettings(); @@ -342,7 +353,11 @@ export class BluetoothDeviceChooserPopoverComponent await this.uiAlert.hideLoadingSpinner(); this.settings.temperature_id = temperatureDevice.id; this.settings.temperature_type = temperatureDevice.type; - + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.TEMPERATURE_CONNECTED, + temperatureDevice.type, + ); //this.uiAnalytics.trackEvent(SETTINGS_TRACKING.TITLE, SETTINGS_TRACKING.ACTIONS.SCALE.CATEGORY,scale.type); await this.saveSettings(); @@ -381,7 +396,11 @@ export class BluetoothDeviceChooserPopoverComponent await this.uiAlert.hideLoadingSpinner(); this.settings.refractometer_id = refractometerDevice.id; this.settings.refractometer_type = refractometerDevice.type; - + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.REFRACTOMETER_CONNECTED, + refractometerDevice.type, + ); //this.uiAnalytics.trackEvent(SETTINGS_TRACKING.TITLE, SETTINGS_TRACKING.ACTIONS.SCALE.CATEGORY,scale.type); await this.saveSettings(); diff --git a/src/services/coffeeBluetoothDevices/coffee-bluetooth-devices.service.ts b/src/services/coffeeBluetoothDevices/coffee-bluetooth-devices.service.ts index c761a9ab2..24dc64ceb 100644 --- a/src/services/coffeeBluetoothDevices/coffee-bluetooth-devices.service.ts +++ b/src/services/coffeeBluetoothDevices/coffee-bluetooth-devices.service.ts @@ -47,6 +47,8 @@ import { ArgosThermometer } from '../../classes/devices/argosThermometer'; import { TimemoreScale } from 'src/classes/devices/timemoreScale'; import { VariaAkuScale } from '../../classes/devices/variaAku'; import { UIHelper } from '../uiHelper'; +import BLUETOOTH_TRACKING from '../../data/tracking/bluetoothTracking'; +import { UIAnalytics } from '../uiAnalytics'; declare var ble: any; declare var cordova: any; @@ -83,6 +85,7 @@ export class CoffeeBluetoothDevicesService { private readonly translate: TranslateService, private readonly uiToast: UIToast, private readonly uiHelper: UIHelper, + private readonly uiAnalytics: UIAnalytics, ) { this.logger = new Logger('CoffeeBluetoothDevices'); this.failed = false; @@ -920,6 +923,11 @@ export class CoffeeBluetoothDevicesService { (data: PeripheralData) => { this.logger.log('AutoConnectScale - Scale device connected.'); _wasConnected = true; + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.SCALE_USED, + deviceType, + ); this.connectCallback(deviceType, data); successCallback(); @@ -1028,6 +1036,11 @@ export class CoffeeBluetoothDevicesService { this.logger.log( 'AutoConnectPressureDevice - Pressure device connected.', ); + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.PRESSURE_USED, + pressureType, + ); this.connectPressureCallback(pressureType, data); successCallback(); @@ -1123,7 +1136,11 @@ export class CoffeeBluetoothDevicesService { this.logger.log( 'AutoConnectTemperatureDevice - Temperature device connected.', ); - + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.TEMPERATURE_USED, + temperatureType, + ); this.connectTemperatureCallback(temperatureType, data); successCallback(); @@ -1179,6 +1196,11 @@ export class CoffeeBluetoothDevicesService { 'AutoConnectRefractometerDevice - Refractometer device connected.', ); + this.uiAnalytics.trackEvent( + BLUETOOTH_TRACKING.TITLE, + BLUETOOTH_TRACKING.ACTIONS.REFRACTOMETER_USED, + refractometerType, + ); this.connectRefractometerCallback(refractometerType, data); successCallback(); diff --git a/src/services/intentHandler/intent-handler.service.ts b/src/services/intentHandler/intent-handler.service.ts index 62ed82be7..12db518d4 100644 --- a/src/services/intentHandler/intent-handler.service.ts +++ b/src/services/intentHandler/intent-handler.service.ts @@ -12,6 +12,7 @@ import { VisualizerService } from '../visualizerService/visualizer-service.servi import { App, URLOpenListenerEvent } from '@capacitor/app'; import { BEAN_CODE_ACTION } from '../../enums/beans/beanCodeAction'; import { UIBrewHelper } from '../uiBrewHelper'; +import IntentHandlerTracking from '../../data/tracking/intentHandlerTracking'; @Injectable({ providedIn: 'root', @@ -137,6 +138,13 @@ export class IntentHandlerService { const actionType = data[0]; const id = data[1]; const action = data[2]; + try { + this.uiAnalytics.trackEvent( + IntentHandlerTracking.TITLE, + IntentHandlerTracking.ACTIONS.INTERNAL_CALL, + action as BEAN_CODE_ACTION, + ); + } catch (ex) {} if (actionType === 'bean') { if ((action as BEAN_CODE_ACTION) === BEAN_CODE_ACTION.DETAIL) { await this.uiBeanHelper.detailBeanByInternalShareCode(id); @@ -175,6 +183,10 @@ export class IntentHandlerService { } private importVisualizerShot(_shareCode) { + this.uiAnalytics.trackEvent( + IntentHandlerTracking.TITLE, + IntentHandlerTracking.ACTIONS.VISUALIZER_IMPORT, + ); this.visualizerService.importShotWithSharedCode(_shareCode); } private async addBeanFromServer(_qrCodeId: string) { @@ -182,6 +194,11 @@ export class IntentHandlerService { try { await this.uiAlert.showLoadingSpinner(); + this.uiAnalytics.trackEvent( + IntentHandlerTracking.TITLE, + IntentHandlerTracking.ACTIONS.IMPORT_ROASTER_BEAN, + _qrCodeId, + ); const beanData: ServerBean = await this.serverCommunicationService.getBeanInformation(_qrCodeId); await this.uiBeanHelper.addScannedQRBean(beanData); @@ -207,7 +224,10 @@ export class IntentHandlerService { try { await this.uiAlert.showLoadingSpinner(); - + this.uiAnalytics.trackEvent( + IntentHandlerTracking.TITLE, + IntentHandlerTracking.ACTIONS.ADD_USER_SHARED_BEAN, + ); await this.uiBeanHelper.addUserSharedBean(_userBeanJSON); } catch (ex) { this.uiAnalytics.trackEvent( diff --git a/src/services/uiAnalytics.ts b/src/services/uiAnalytics.ts index 6c0f7ed7e..00ec47a88 100755 --- a/src/services/uiAnalytics.ts +++ b/src/services/uiAnalytics.ts @@ -27,7 +27,7 @@ export class UIAnalytics { private readonly uiSettings: UISettingsStorage, private readonly uiAlert: UIAlert, private readonly uiLog: UILog, - private readonly router: Router + private readonly router: Router, ) {} public async initializeTracking(): Promise { @@ -37,7 +37,6 @@ export class UIAnalytics { await this.uiSettings.storageReady(); this.matomoTracker = Matomo.getTracker(); - const settings: Settings = this.uiSettings.getSettings(); if (settings.matomo_analytics === true) { this.enableTracking(); @@ -76,19 +75,19 @@ export class UIAnalytics { this.__trackPageFB(_pageName); } else { this.uiLog.info( - `ANALYTICS - DISABLED - But we would track page: Page:${_pageName}` + `ANALYTICS - DISABLED - But we would track page: Page:${_pageName}`, ); } } - public trackEvent(_category, _action, _name?, _value?: number) { + public trackEvent(_category, _action, _name?) { if (this.canTrack) { try { - this.__trackEventFB(_category, _action, _name, _value); + this.__trackEventFB(_category, _action, _name); } catch (ex) {} } else { this.uiLog.info( - `ANALYTICS - DISABLED - But we would track event: Category:${_category}, Action: ${_action}` + `ANALYTICS - DISABLED - But we would track event: Category:${_category}, Action: ${_action}`, ); } } @@ -113,20 +112,18 @@ export class UIAnalytics { } catch (ex) {} } - private __trackEventFB(_category, _action, _name?, _value?) { + private __trackEventFB(_category, _action, _name?) { if (this.canTrack) { try { - if (_name && _value) { - this.matomoTracker.trackEvent(_category, _action, _name, _value); + if (_name) { + this.matomoTracker.trackEvent(_category, _action, _name); this.uiLog.log( 'SUCCESS - Track event page - Category:' + _category + ' Action:' + _action + ' Name:' + - _name + - ' Value:' + - _value + _name, ); } else { this.matomoTracker.trackEvent(_category, _action); @@ -134,7 +131,7 @@ export class UIAnalytics { 'SUCCESS - Track event page - Category:' + _category + ' Action:' + - _action + _action, ); } } catch (ex) {}