Skip to content

Commit f68f1c9

Browse files
adds typedoc comments
1 parent 0aaaa77 commit f68f1c9

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/app/statistics/matomo.factory.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import { createDefaultMatomoScriptElement } from 'ngx-matomo-client';
22

33
import { MatomoService } from './matomo.service';
44

5+
/**
6+
* Creates a custom script factory function that integrates with the `MatomoService`.
7+
*
8+
* @param matomoService - The instance of `MatomoService` used to track the loading state.
9+
* @returns A function to initialize script to listen onload/onerror events by MatomoService
10+
*
11+
* @example
12+
* // In your app config or module providers:
13+
* {
14+
* provide: MATOMO_SCRIPT_FACTORY,
15+
* useFactory: customMatomoScriptFactory,
16+
* deps: [MatomoService]
17+
* }
18+
*/
519
export function customMatomoScriptFactory(matomoService: MatomoService) {
620
return (scriptUrl: string, document: Document): HTMLScriptElement => {
721
const script = createDefaultMatomoScriptElement(scriptUrl, document);

src/app/statistics/matomo.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ export class MatomoService {
176176
);
177177
}
178178

179+
/**
180+
* Checks if Matomo script loaded correctly
181+
* @returns An Observable that emits a boolean indicating whether Matomo script loaded correctly.
182+
*/
179183
isMatomoScriptLoaded$(): Observable<boolean> {
180184
return this.status$.pipe(
181185
map(status => status === 'loaded'),

0 commit comments

Comments
 (0)