Closed aicokleinovink closed 2 years ago
Hi @aicokleinovink
Had you tried solution described in #31 ?
I just took a look at that solution, thanks for your quick reply. I understand this is an Angular shortcoming when importing a module like this. However, with the older versions of this package it was possible to initialize matomo in a later stage using the init
function if I'm not wrong? I'm only running into this issue just now while upgrading from a 0.something
version to 3.0.0
.
The solution you provided doesn't really seem like a good way to do this my opinion.
with the older versions of this package it was possible to initialize matomo in a later stage using the init function
No, the initialization is done automatically when NgxMatomoTrackerModule
is loaded.
I'm only running into this issue just now while upgrading from a 0.something version to 3.0.0.
There is no 0.x
version of this lib: are you talking about version 1.x
for Angular <= 12?
What version of angular are you using? Take a look at the compatibility table shown in the README
The solution you provided doesn't really seem like a good way to do this my opinion.
Why?
There is a (long) discussion about this on angular feature request 23279, especially comment by alxhub few days ago.
The problem is that some DI token may be instantiated BEFORE APP_INITIALIZER
completes.
I understand the quick workaround using fetch
before application bootstrap may not work in some environments (especially on mobile/WebView, etc…)
Maybe in the future a feature for asynchronous initialization will be implemented in this lib, of course feel free to provide a PR it will be greatly appreciated :)
There is no 0.x version of this lib: are you talking about version 1.x for Angular <= 12?
You're totally right, I just found out the application I'm working on was previously using this ngx-matomo package.
Fetching data may take quite a while unfortunately, so waiting for that before bootstrapping the application is a no-go.
Thanks so much for your time, I'll close this issue. I will take a look and see if I can provide a PR.
Fetching data may take quite a while unfortunately, so waiting for that before bootstrapping the application is a no-go.
I totally understand, but I have no simple solution for you right now.
I will try to find some time to work on it and I will keep you informed!
I will take a look and see if I can provide a PR.
Thank you so much! Even partial or draft work will be useful :)
@aicokleinovink I'm working on a solution, it should be released soon ;)
@aicokleinovink would it suit your needs if you can set tracker config properties (and only these: trackerUrl, siteId, etc.) asynchronously?
Other optional properties would still need to be set in forRoot
(requireConsent, etc.)
:tada: This issue has been resolved in version 2.5.0 :tada:
The release is available on:
v2.5.0
Your semantic-release bot :package::rocket:
:tada: This issue has been resolved in version 3.1.0 :tada:
The release is available on:
v3.1.0
Your semantic-release bot :package::rocket:
@aicokleinovink @lousley New feature released: check the new section in README ;-) (Available only in versions ≥ 2.5.0 for Angular 13 and ≥ 3.1.0 for Angular 14)
When importing the tracker module:
How can the
siteId
andtrackerUrl
first be retrieved async from a service, before matomo actually is trying to do something with these initial values?I tried something like this:
But how will I be able to set the url and site id after that??