Closed GreenfieldC closed 10 months ago
Hi @GreenfieldC
Can you please provide a minimal repro ?
I can see your configuration contains:
TranslateModule.forChild()
and
NgxMatomoModule.forRoot(...)
which suggest a confusion in modules configuration. Is NgxMatomoModule.forRoot
called at multiple locations? (in lazy-loaded modules, for example)
Thanks for your fast reply. In the meantime I could solve my problem with importing the modules into my app.module.ts. Now Matomo gets initialized only ones.
Indeed, this is explained in README instructions, please take a look.
That's a common pattern in most Angular libraries (never call .forRoot
in a child module) docs on angular.io
When I open my app on my localhost and then click on the shopping card for instance, I get the error "Matomo has already been initialized".
I am not really sure how to fix the error as I only read your documentation and typed in the code as being told to.
This is my module set up:
[...] `import { UtilsService } from './services/utils.service'; import { NgxMatomoModule, NgxMatomoRouterModule } from 'ngx-matomo-client'; import { environment } from './environment/environment';
export function getCustomSettings(appLoadService: AppLoadService) { return async () => { await appLoadService.getSettings(); }; }
@NgModule({ imports: [ CommonModule, TranslateModule.forChild(), NgxMatomoModule.forRoot({ siteId: environment.customSettings.matomoConfig.matomoSiteId, trackerUrl: environment.customSettings.matomoConfig.matomoTrackerUrl, }), NgxMatomoRouterModule, ], exports: [ ],`[...]
package.json: "ngx-matomo-client": "5.0.4", (Angular 16.2.12)
P.S: Matomo shows me when ever I run the app though.