From dad446b4f1afc63dd0e3fd08285116a0c81b2611 Mon Sep 17 00:00:00 2001
From: Lindner <marlon.lindner@mni.thm.de>
Date: Fri, 8 May 2020 22:21:34 +0200
Subject: [PATCH] implemented matomo with the ngx-matomo package

---
 package-lock.json        | 5 +++++
 package.json             | 1 +
 src/app/app.component.ts | 4 ++++
 src/app/app.module.ts    | 2 ++
 4 files changed, 12 insertions(+)

diff --git a/package-lock.json b/package-lock.json
index 05ec0897a..bca23c998 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9451,6 +9451,11 @@
         "prismjs": "^1.16.0"
       }
     },
+    "ngx-matomo": {
+      "version": "0.1.4",
+      "resolved": "https://registry.npmjs.org/ngx-matomo/-/ngx-matomo-0.1.4.tgz",
+      "integrity": "sha512-AKZMnJGyytZqAxuSh+k/AulyQhgqlnnsmtkfvHMJyNuh5g+wVpIbwac36RyeFU3El6INgZVso2CCLElV3bQnBQ=="
+    },
     "nice-try": {
       "version": "1.0.5",
       "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
diff --git a/package.json b/package.json
index 1803e9968..ff38d3a0c 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
     "is-docker": "^1.1.0",
     "material-design-icons": "^3.0.1",
     "ngx-markdown": "^9.0.0",
+    "ngx-matomo": "^0.1.4",
     "rxjs": "^6.5.4",
     "tslib": "^1.10.0",
     "tslint-eslint-rules": "^5.3.1",
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index a8e507353..a7feff40f 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -4,6 +4,8 @@ import { SwUpdate } from '@angular/service-worker';
 import { NotificationService } from './services/util/notification.service';
 import { Rescale } from './models/rescale';
 import { CustomIconService } from './services/util/custom-icon.service';
+import { MatomoInjector } from 'ngx-matomo';
+import { environment } from '../environments/environment';
 
 @Component({
   selector: 'app-root',
@@ -16,11 +18,13 @@ export class AppComponent implements OnInit {
 
   constructor(private translationService: TranslateService,
               private update: SwUpdate,
+              private matomoInjector: MatomoInjector,
               public notification: NotificationService,
               private customIconService: CustomIconService) {
     translationService.setDefaultLang(this.translationService.getBrowserLang());
     sessionStorage.setItem('currentLang', this.translationService.getBrowserLang());
     customIconService.init();
+    if (environment.name === 'prod') { this.matomoInjector.init('https://arsnova.thm.de/stats/', 6); }
   }
 
   public static rescale: Rescale = new Rescale();
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index b5a72c472..552bb9153 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -61,6 +61,7 @@ import { QrCodeDialogComponent } from './components/shared/_dialogs/qr-code-dial
 import { MatIconModule } from '@angular/material/icon';
 import { HttpClientModule } from '@angular/common/http';
 import { RemoveFromHistoryComponent } from './components/shared/_dialogs/remove-from-history/remove-from-history.component';
+import { MatomoModule } from 'ngx-matomo';
 
 export function dialogClose(dialogResult: any) {
 }
@@ -99,6 +100,7 @@ export function initializeApp(appConfig: AppConfig) {
     OverlayComponent
   ],
   imports: [
+    MatomoModule,
     AppRoutingModule,
     BrowserModule,
     BrowserAnimationsModule,
-- 
GitLab