Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use partytown to third party scripts like glaze, dynatrace, etc? #302

Open
ghost opened this issue Nov 16, 2022 · 14 comments
Assignees

Comments

@ghost
Copy link

ghost commented Nov 16, 2022

Is your feature request related to a problem? Please describe.
We use multiple third-party analytics in our svelte application. We integrated partytown in our svelte app for executing those analytics scripts and calls through partytown but we were able to achieve it only for Google Tag Manager, we need to know if the same is possible for others.

Describe the solution you'd like
Just like the forward configs used for services like Google tag manager and facebook pixel, can we have any config feature/documentation for services like glaze, dynatrace, medallia, etc. if it is possible to trigger those respective calls through partytown.

Describe alternatives you've considered
We used text/partytown as type for downloding glaze script but only script execution is handled by partytown and the corresponding log calls are not triggered. Without out partytown if we run the script in main thread, the respective log calls are triggered as expected.

@mhevery
Copy link
Contributor

mhevery commented Nov 17, 2022

In theory, this should work, but if it does not, we need steps to reproduce it.
Can we have an HTML file showing how you have it set up and what steps we need to take to reproduce the problem? Without that, it is not possible to know what is going on and what needs to be fixed.

@ghost
Copy link
Author

ghost commented Nov 18, 2022

In theory, this should work, but if it does not, we need steps to reproduce it. Can we have an HTML file showing how you have it set up and what steps we need to take to reproduce the problem? Without that, it is not possible to know what is going on and what needs to be fixed.

Hi Mr.Hevery, I have created a sample application for reproducing dynatrace issue.
link: https://codesandbox.io/s/github/vasikaranb-nagarro/partytown_poc/tree/dynatrace

there, in index.html , if you change the script type as text/javascript in the dynatrace script you can see log calls getting triggered for url change. But the same is not happening with type partytown.

<script type="text/partytown" src="https://js-cdn.dynatrace.com/jstag/147f84b2bdc/bf45848ori/3cd9a81926e1a501_complete.js"></script>

Github link : https://github.com/vasikaranb-nagarro/partytown_poc/tree/dynatrace
To reproduce locally, Please clone the repo (branch: dynatrace) and do npm dev

@ghost
Copy link
Author

ghost commented Nov 22, 2022

For Glaze.ai, the issue with partytown is, glaze fetches changes from window.location.href to make log calls. and it works fine with partytown nomally, but if we have base URL for the application, then it fails because partytown doesnt update its self.location.href if we have base href.

Steps to reproduce:

  1. clone https://github.com/vasikaranb-nagarro/partytown_poc/tree/glaze
  2. npm install and npm dev
  3. glaze logs will be triggered if we remove base href from index.html and config(base url) from app.svelte

Solution needed:
Can self.location object in partytown webworker be updated with url change even if we have base href

@mhevery mhevery self-assigned this Dec 6, 2022
@mhevery
Copy link
Contributor

mhevery commented Dec 6, 2022

I will try to look into it later this week.

@mhevery
Copy link
Contributor

mhevery commented Dec 8, 2022

I tried to debug it, but I really have no idea what I am looking for or how to reproduce it. Can you provide a more steps by steps instructions os to what to click and what to look for? https://www.loom.com/share/5f155e209111469cb89c3b97aa8f265b

@ghost
Copy link
Author

ghost commented Dec 9, 2022

I tried to debug it, but I really have no idea what I am looking for or how to reproduce it. Can you provide a more steps by steps instructions os to what to click and what to look for? https://www.loom.com/share/5f155e209111469cb89c3b97aa8f265b

Hi Misko,

I am adding the steps to reproduce the issue.

Dynatrace

  1. Please take a pull from https://github.com/vasikaranb-nagarro/partytown_poc/tree/dynatrace as dynatrace URL has been updated now.
  2. npm install and npm dev
  3. in index.html file you can see the dynatrace script tagged under javacsript type
    image
  4. In the browser -> inspect -> network tab, you can see dynatrace XHR calls getting triggered in every URL change (click tweets button in home page and back button in tweets page)
    image
  5. Now change the dynatrace script type to partytown in same index.html file. We don't see those calls getting triggered

Analysis : dynatrace uses window object to push data and trigger calls.
image
Since webworkers doesnt have window object or its access, this scenario is failing.
For GTM, partytown has a config called 'forward' which forwards the respective data to window.dataLayer object. Can we have similar config for dynatrace?

Glaze

  1. Please take a pull from https://github.com/vasikaranb-nagarro/partytown_poc/tree/glaze
  2. npm install and npm dev
  3. In index.html we have glaze script with javascript type.
    image
  4. In the browser->inspect->network tab, we can see glaze log calls in every URL change. ( Click tweets button in home page and back button in tweets page)
    image
  5. Now, if we change the glaze script to partytown type, those calls will not be triggered.

Analysis: This glaze issue is happening only when we have base href in the application
image
With some debugging I found that partytown has location object on its own (self.location). and this location.href is not getting updated with URL change if we have base href. most probably the issue is with the set href() methods in partytown-atomics.js files.

@ghost ghost closed this as completed Dec 9, 2022
@ghost ghost reopened this Dec 9, 2022
@ghost
Copy link
Author

ghost commented Dec 21, 2022

Hi Misko, were you able to reproduce the issue with above steps? Please let me know if any more information is needed.

FYI, By mistake closed this issue but re-opened it immediately.

@mhevery
Copy link
Contributor

mhevery commented Dec 21, 2022

I am sorry, I got buried with other things. Still on my list.

mhevery added a commit to mhevery/partytown that referenced this issue Dec 23, 2022
@mhevery
Copy link
Contributor

mhevery commented Dec 23, 2022

#331

@mhevery
Copy link
Contributor

mhevery commented Dec 24, 2022

Still more work to do here...

@ghost
Copy link
Author

ghost commented Jan 12, 2023

Hi Misko, Hope you are doing good. please let me know if the recent version has any fix related to this issue.

@mhevery
Copy link
Contributor

mhevery commented Jan 12, 2023 via email

@sushil-netspend
Copy link

sushil-netspend commented Apr 18, 2023

Hi Misko, is there any update on this, did you get a chance to look at it?

@mhevery
Copy link
Contributor

mhevery commented Apr 20, 2023

Sorry, our focus currently is on Qwik. We would need someone to debug this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants