76634: Add documentation

This commit is contained in:
Bruno Roemers
2021-02-02 14:40:56 +01:00
parent 3f6cf777b6
commit 3a486eb81f

View File

@@ -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(),