Skip to content

Commit

Permalink
Refactor Matomo tracking configuration and update script paths
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebouget committed Nov 27, 2024
1 parent a6bd0c6 commit c4082ce
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 9 additions & 16 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.dev.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const APP_CONFIG = {
production: false,
environment: 'DEV',
TRACKER_ID: '2198',
};
1 change: 0 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const APP_CONFIG = {
production: true,
environment: 'PROD',
TRACKER_ID: '2198',
};
1 change: 0 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const APP_CONFIG = {
production: false,
environment: 'LOCAL',
TRACKER_ID: '2198',
};
1 change: 0 additions & 1 deletion src/environments/environment.web.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const APP_CONFIG = {
production: false,
environment: 'WEB',
TRACKER_ID: '2198',
};

0 comments on commit c4082ce

Please sign in to comment.