From 0bab79bea40b4ce637ec98e38822311ba6f29e25 Mon Sep 17 00:00:00 2001 From: Andrea Barbasso <´andrea.barbasso@4science.com´> Date: Fri, 21 Feb 2025 16:22:13 +0100 Subject: [PATCH] [CST-18694] add TypeDoc comments --- src/app/statistics/matomo.service.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/app/statistics/matomo.service.ts b/src/app/statistics/matomo.service.ts index d507bb0a505..553eba851fc 100644 --- a/src/app/statistics/matomo.service.ts +++ b/src/app/statistics/matomo.service.ts @@ -11,16 +11,32 @@ import { environment } from '../../environments/environment'; import { NativeWindowService } from '../core/services/window.service'; import { OrejimeService } from '../shared/cookies/orejime.service'; +/** + * Service to manage Matomo analytics integration. + * Handles initialization and consent management for Matomo tracking. + */ @Injectable({ providedIn: 'root', }) export class MatomoService { + /** Injects the MatomoInitializerService to initialize the Matomo tracker. */ matomoInitializer = inject(MatomoInitializerService); + + /** Injects the MatomoTracker to manage Matomo tracking operations. */ matomoTracker = inject(MatomoTracker); + + /** Injects the OrejimeService to manage cookie consent preferences. */ orejimeService = inject(OrejimeService); + + /** Injects the NativeWindowService to access the native window object. */ _window = inject(NativeWindowService); + /** + * Initializes the Matomo tracker if in production environment. + * Sets up the changeMatomoConsent function on the native window object. + * Subscribes to cookie consent preferences and initializes the tracker accordingly. + */ init() { if (this._window.nativeWindow) { this._window.nativeWindow.changeMatomoConsent = this.changeMatomoConsent; @@ -42,6 +58,10 @@ export class MatomoService { } } + /** + * Changes the Matomo consent status based on the given consent value. + * @param consent - A boolean indicating whether consent is given for Matomo tracking. + */ changeMatomoConsent = (consent: boolean) => { if (consent) { this.matomoTracker.setConsentGiven();