Skip to content

Commit

Permalink
[CST-18694] add TypeDoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Barbasso committed Feb 21, 2025
1 parent fd21209 commit 0bab79b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/app/statistics/matomo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 0bab79b

Please sign in to comment.