From 3a486eb81f0ba4caac29e5c335f5a0d323c1577c Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Tue, 2 Feb 2021 14:40:56 +0100 Subject: [PATCH] 76634: Add documentation --- src/app/statistics/google-analytics.service.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/statistics/google-analytics.service.ts b/src/app/statistics/google-analytics.service.ts index 2392184b35..1a35300315 100644 --- a/src/app/statistics/google-analytics.service.ts +++ b/src/app/statistics/google-analytics.service.ts @@ -5,6 +5,10 @@ import {getFirstCompletedRemoteData} from '../core/shared/operators'; import {isEmpty} from '../shared/empty.util'; import {DOCUMENT} from '@angular/common'; +/** + * Set up Google Analytics on the client side. + * See: {@link addTrackingIdToPage}. + */ @Injectable() export class GoogleAnalyticsService { @@ -14,6 +18,12 @@ export class GoogleAnalyticsService { @Inject(DOCUMENT) private document: Document ) { } + /** + * Call this method once when Angular initializes on the client side. + * It requests a Google Analytics tracking id from the rest backend + * (property: google.analytics.key), adds the tracking snippet to the + * page and starts tracking. + */ addTrackingIdToPage(): void { this.configService.findByPropertyName('google.analytics.key').pipe( getFirstCompletedRemoteData(),