Using script tag with custom parameter
and this is my solid code root.tsx
Problem is that data-website-id doesn't work.
14 Replies
@Alex Lohr mb u know?
We use solid's spread, so we should receive the same things as solid props.
Let me look what solid does to data attributes
The data attribute should be set on the script. Can you tell me what is expected by the script?
https://umami.is/docs/tracker-configuration <- this one?
Yes, that is correct
Could you please elaborate a bit more on what "doesn't work" mean exactly?
https://umami.is/docs/sending-stats
The website parameter is empty when sending the request. I will try make simple plain js website tomorrow to see if umami script fills it correctly.
Docs also say it should be on head section of the site, but i am not sure if that makes a difference in solid start context. Edit. Script loader appends to head
Script that is
@Alex Lohr
Okay I solved it, createScriptLoader works well on plain solidjs project, but for some reason at least on my solid start project, only src attribute was set on head script tag for umami. I tried testing plain solid start project, but it had already moved to vinxi.
Here is the code I used to workaround:
Can you create a minimum reproduction of the issue?
https://github.com/illispi/ScriptStartIssue
Here you go. Not sure what the issue is since its only start specific, plain solidjs works fine
GitHub
GitHub - illispi/ScriptStartIssue
Contribute to illispi/ScriptStartIssue development by creating an account on GitHub.
Thanks, I'll have a look
Solid start does something to spread so it does not work like it should.
This is indeed an error in the older solid-start.
That repo has the latest vinxi 0.4 build.
Do you think i should file issue on solid start?
I'll have to check deeper later.
I have had a deeper look. This is due to setAttribute not setting any attributes through spread if there is a shared context.
We can solve this if we call spread outside of the reactive context, e.g. using setTimeout()
I'm not sure if that is a good solution, so I'll discuss this with my colleagues.
There is a workaround. The script node is returned from the createScriptLoader call, so you can use
createScriptLoader(...).setAttribute('...', '...')
as a workaround.Okay, thanks
A solution will be published within the next days.
Sorry it took a bit longer. I just rebased the PR, so it should be merged and released soon-ish.
Just merged the branch. It should be up before next year.