mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
[CST-18694] add TypeDoc comments
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user