File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,20 @@ import { createDefaultMatomoScriptElement } from 'ngx-matomo-client';
22
33import { 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+ */
519export function customMatomoScriptFactory ( matomoService : MatomoService ) {
620 return ( scriptUrl : string , document : Document ) : HTMLScriptElement => {
721 const script = createDefaultMatomoScriptElement ( scriptUrl , document ) ;
Original file line number Diff line number Diff 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' ) ,
You can’t perform that action at this time.
0 commit comments