diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a9fa551..6be1327 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -50,7 +50,7 @@ export class AppComponent implements OnInit { } this.appCenterAnalytics.setEnabled(true).then(() => { - this.appCenterAnalytics.trackEvent('My Event', { TEST: 'HELLO_WORLD' }).then(() => { + this.appCenterAnalytics.trackEvent('Started app', { time: new Date().toISOString() }).then(() => { console.log('Custom event tracked'); }); }); diff --git a/src/app/services/game-helper.service.ts b/src/app/services/game-helper.service.ts index cba68b4..d2cd649 100644 --- a/src/app/services/game-helper.service.ts +++ b/src/app/services/game-helper.service.ts @@ -9,6 +9,7 @@ import AudioController from './AudioController.service'; import { ConnectionController } from './ConnectionController.service'; import { EventEmitter as EventEmitterO } from 'events'; import { BackgroundMode } from '@ionic-native/background-mode/ngx'; +import { AppCenterAnalytics } from '@ionic-native/app-center-analytics/ngx'; const { LocalNotifications, BetterCrewlinkNativePlugin } = Plugins; @@ -39,7 +40,8 @@ export class GameHelperService extends EventEmitterO implements IGameHelperServi private androidPermissions: AndroidPermissions, public platform: Platform, public cManager: ConnectionController, - private backgroundMode: BackgroundMode + private backgroundMode: BackgroundMode, + private appCenterAnalytics: AppCenterAnalytics ) { super(); this.load(); @@ -66,6 +68,14 @@ export class GameHelperService extends EventEmitterO implements IGameHelperServi connect() { this.disconnect(false); + this.appCenterAnalytics.trackEvent('connect', { + gameCode: this.settings.gamecode.toUpperCase(), + username: this.settings.username, + micrphone: this.settings.selectedMicrophone.deviceId, + natfixEnabled: this.settings.natFix ? 'true' : 'false', + time: new Date().toISOString(), + }); + this.requestPermissions().then((haspermissions) => { if (!haspermissions) { console.log('permissions failed'); @@ -91,6 +101,11 @@ export class GameHelperService extends EventEmitterO implements IGameHelperServi BetterCrewlinkNativePlugin.disconnect(); } this.cManager.disconnect(true); + + this.appCenterAnalytics.trackEvent('disconnect', { + disableBackgroundMode: disableBackgroundMode ? 'true' : 'false', + time: new Date().toISOString(), + }); } muteMicrophone() {