From c4082cebf6ab49e2b2f4c7b56d84561e203775db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bouget?= Date: Wed, 27 Nov 2024 16:27:58 +0100 Subject: [PATCH] Refactor Matomo tracking configuration and update script paths --- angular.json | 2 +- src/app/app.component.ts | 25 +++++++++---------------- src/environments/environment.dev.ts | 1 - src/environments/environment.prod.ts | 1 - src/environments/environment.ts | 1 - src/environments/environment.web.ts | 1 - 6 files changed, 10 insertions(+), 21 deletions(-) diff --git a/angular.json b/angular.json index 632a2f2..f0b1e2b 100644 --- a/angular.json +++ b/angular.json @@ -32,7 +32,7 @@ "assets": ["src/favicon.ico", "src/assets"], "styles": ["src/styles.scss"], "scripts": [ - "../visualization-component/dist/khiops-webcomponent/khiops-webcomponents.bundle.js" + "node_modules/khiops-visualization/khiops-webcomponents.bundle.js" ], "customWebpackConfig": { "path": "./angular.webpack.js", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e87b9a0..8328d59 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -38,19 +38,20 @@ export class AppComponent implements AfterViewInit { private matomoTracker: MatomoTracker ) { this.translate.setDefaultLang('en'); + + // Disable cookies to prevent coookie consent + this.matomoTracker.disableCookies(); + this.matomoTracker.setDoNotTrack(true); + if (this.electronService.isElectron) { + this.matomoTracker.trackPageView(); + this.matomoTracker.enableFileTracking(); + // Get machine ID via IPC this.electronService.ipcRenderer ?.invoke('get-machine-id') .then((machineId: string) => { - // this.matomoTracker.disableCookies(); - // this.matomoTracker.setDoNotTrack(true); - - this.matomoTracker.requireConsent(); - this.matomoTracker.requireCookieConsent(); - this.matomoTracker.trackPageView(); this.matomoTracker.setVisitorId(machineId); - this.matomoTracker.enableFileTracking(); }) .catch((error: any) => { console.error('Error getting machine ID:', error); @@ -88,15 +89,7 @@ export class AppComponent implements AfterViewInit { this.setTheme(data); }, onSendEvent: (event: any) => { - if (event.message === 'forgetConsentGiven') { - this.matomoTracker.forgetConsentGiven(); - this.matomoTracker.forgetCookieConsentGiven(); - this.matomoTracker.deleteCookies(); - } else if (event.message === 'setConsentGiven') { - this.matomoTracker.rememberConsentGiven(); - this.matomoTracker.rememberCookieConsentGiven(); - this.matomoTracker.forgetUserOptOut(); - } else if (event.message === 'trackEvent') { + if (event.message === 'trackEvent') { this.matomoTracker.trackEvent( event.data?.category, event.data?.action, diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts index 9b2c5c2..3fe3326 100644 --- a/src/environments/environment.dev.ts +++ b/src/environments/environment.dev.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: false, environment: 'DEV', - TRACKER_ID: '2198', }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index ed66e6c..eb2269c 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: true, environment: 'PROD', - TRACKER_ID: '2198', }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d1dba75..fd538c5 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: false, environment: 'LOCAL', - TRACKER_ID: '2198', }; diff --git a/src/environments/environment.web.ts b/src/environments/environment.web.ts index bb878d3..a82fe78 100644 --- a/src/environments/environment.web.ts +++ b/src/environments/environment.web.ts @@ -1,5 +1,4 @@ export const APP_CONFIG = { production: false, environment: 'WEB', - TRACKER_ID: '2198', };