-
Notifications
You must be signed in to change notification settings - Fork 444
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
feat: improve forwarding-events with preserveBehavior
#530
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
2ae8e1f
to
87f4dbb
Compare
Thanks @franpeza I think this is a nice improvement. my only concern is to have to different way of doing the same thing. |
thanks @gioboa, what I was trying to expose was some possible ways to allow to inform the property, but the one I implemented is precisely the one you mentioned (and my favourite one BTW) So that would be the only way of enabling this new setting. Don't know if there's any open issue regarding this topic, not on my side at least. I will try to make some time today or tomorrow to document the property with this shape:
|
11ee113
to
0854f3d
Compare
there seems to be some kind of problem with |
I'll fix it --- UPDATE --- ✅ Fixed |
thanks @gioboa |
Tests are so unstable 😢 I can't figure out the why |
The most unstable seems to be the webkit one, yep I just added some documentation about the new setting, please take a look if you can :) |
preserveBehavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double checked this PR with the core team and it looks awesome.
Thanks @franpeza
Let's merge it.
Thanks for merging it!! |
What is it?
Description
This PR adds the ability to preserve the behavior of forwarded functions. This comes in candy for some scenarios, for example, some third parties integrations that monitor the global
dataLayer
array in order to work. When GA is handled by partytown the array will be empty, this new functionality allows to keep the events there.Even if the motivation for this is GA and the dataLayer array, this would work for any other forwarded method, as it makes the trick including a call to the original method in the patched version (in fact, in the tests added there is a case where the forwarded method is
unshift
instead ofpush
).If you want to enable this new setting, you would do it like this:
forward: ['simpleProperty', ['dataLayer.push', { preserveBehavior: true }]],
I also contemplated the possibility of doing so:
forward: ['simpleProperty', { property: 'dataLayer.push', preserveBehavior: true }],
but I prefer the first way. Anyway I'm open to implement any other way of doing it.
Use cases and why
Checklist:
If you think this PR is worth, I could add the documentation of the new setting.
Waiting for your feedback, thank you!