BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.85k stars 426 forks source link

[🐞] Segment parsing URL for UTMs is not working #502

Open alexandprivate opened 7 months ago

alexandprivate commented 7 months ago

Describe the bug

Segment parses the URL automatically looking for UTMs params, this manipulation involves location.search, when you visit the URL with UTMs params Segment automatically adds them to the context property in the event payload.

Documentation - https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#utm-trackingadds

This is reproducible with any project loading partytown with segment

Reproduction

localhost:3000?utm_source=mysource&utm_medium=email

Steps to reproduce

Negative

Positive

Browser Info

Chrome, Safari

Additional Information

Seems that we need to forward location.search somehow but does not work, when you forward location. the URL changes on load and partytown shows a function instead:

From : http://localhost:10701/playground?utm_source=mysource&utm_medium=email
To: http://localhost:10701/function()%7B(t._ptf=t._ptf%7C%7C[]).push(i,arguments)%7D

Same result happens if you forward localtio.search or location.href, or location.pathname

dsacramone commented 1 month ago

@alexandprivate Did you sort this out, if so, how?