[CST-18694] add TypeDoc comments

This commit is contained in:
Andrea Barbasso
2025-02-21 16:22:13 +01:00
parent fd2120904c
commit 0bab79bea4

View File

@@ -11,16 +11,32 @@ import { environment } from '../../environments/environment';
import { NativeWindowService } from '../core/services/window.service'; import { NativeWindowService } from '../core/services/window.service';
import { OrejimeService } from '../shared/cookies/orejime.service'; import { OrejimeService } from '../shared/cookies/orejime.service';
/**
* Service to manage Matomo analytics integration.
* Handles initialization and consent management for Matomo tracking.
*/
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class MatomoService { export class MatomoService {
/** Injects the MatomoInitializerService to initialize the Matomo tracker. */
matomoInitializer = inject(MatomoInitializerService); matomoInitializer = inject(MatomoInitializerService);
/** Injects the MatomoTracker to manage Matomo tracking operations. */
matomoTracker = inject(MatomoTracker); matomoTracker = inject(MatomoTracker);
/** Injects the OrejimeService to manage cookie consent preferences. */
orejimeService = inject(OrejimeService); orejimeService = inject(OrejimeService);
/** Injects the NativeWindowService to access the native window object. */
_window = inject(NativeWindowService); _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() { init() {
if (this._window.nativeWindow) { if (this._window.nativeWindow) {
this._window.nativeWindow.changeMatomoConsent = this.changeMatomoConsent; 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) => { changeMatomoConsent = (consent: boolean) => {
if (consent) { if (consent) {
this.matomoTracker.setConsentGiven(); this.matomoTracker.setConsentGiven();