-
Notifications
You must be signed in to change notification settings - Fork 50
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
enableAutoOutboundTracking breaks target="_blank" and probably noopener security #12
Comments
Yes, the timeout in plausible-tracker/src/lib/tracker.ts Line 286 in a5f8e94
target="_blank" .
For |
Also, an issue we had on the main tracker script was middle clicking on the mouse to open the link in a new tab. Outbound link tracking was messing with the default behaviour there which was fixed. Is this issue also present in this tracker script? |
I'm not sure but shouldn't you also replace the |
When using
does not run when using |
Okay great! To prevent all the special cases for each browser, it might be an idea to update the way you delay the click event. If you redispatch the event, you don't need to check on shift keys, middle mouse etc. I've made an example |
BTW, the current behaviour in plausible does stop noopener when not using |
Darn, yeah that's true. I do like the idea of just falling back to browser defaults as much as possible. Your demo is great, thanks for that. However, middle clicking and shift-clicking does not open the link in a new tab for me :/ Running FireFox on Elementary OS. |
Oh too bad, does work on Chrome and Safari on MacOS. |
I tested again:
The only thing I can think of is the second time the event is dispatched, it has Thanks @SimonBackx for making this demo, it's great. But I cannot merge it since it doesn't work consistently everywhere. I think the best solution is switching to |
Yes, the sendBeacon approach seems the right one! |
Not sure if this belongs here, but plausible-tracker/src/lib/tracker.ts Line 288 in a5f8e94
|
Thanks for reporting @maurice-g. I can't see a way to fix it other than moving to a completely different method for tracking like |
I understand. But I do think this would warrant an entry in the docs to warn users that this function might break functionality. |
I agree. It's very unfortunate that this doesn't work out of the box. Edit: My PR adding a warning about this was just merged 🎉 |
So is it correct that #16 would solve this issue? Unfortunately I don't know this technology and don't have enough time to invest right now otherwise I'd try to contribute :) |
Yes, using |
Had to dig for a good while to realize that my Unless you're planning to move to For now this is blocking us from migrating our production environment to plausible, because unfortunately we rely on shipping some content in iframes and we can't have outbound links break in these... |
thanks @abett! there are no short term plans about the beacon api that we can tell you about. we are a small team with limited development resources so need to focus on most frequently requested features first. in the meanwhile you could use our default script and not the oubtound link click script. thanks for understanding! |
Thanks for the quick reply @metmarkosaric, completely understand your priorities. I found this blog post of yours from a year ago - if I adjust the GA script you shared to send a plausible event instead, does it achieve the same outcome as |
you're welcome! could you try that please and let us know if it works? would be a nice workaround until we get the beacon api working |
Hoping I haven't included a typo here, yes it worked as following:
|
that's great news @abett, thanks for sharing! i've added a link to your comment in our docs |
Thanks @abett plausible-tracker/src/lib/tracker.ts Lines 292 to 295 in a837ff4
For target |
thanks @Joelius300! it's something we may be able to look at but i cannot make any promise. all of our development resources are focused on the data import and performance improvements at the moment. |
No worries 👍🏼 in that case I might submit a PR for your consideration when you have time. |
Opened #21 with a fix. It has no tests currently so it's not ready for merge yet but I hope it helps as a start. For anyone needing this feature right now, I'm using my fixed fork in a project of mine with git submodule. Let yourself get inspired ((no warranties)) 😄 |
Looking back at the comment by @ukutaht in April, I realized that there would now be a discrepancy between the linked script and the npm module. In the js script you're also sending events on ctrl, shift and middle click (at least that's what I can tell from the code). With this PR, ctrl and middle click purposefully aren't sent and I completely forgot about shift and meta, which probably should be treated like ctrl. So I guess it would be good to define a behavior for all those cases and consistently implement it in the npm module and js script without breaking links. Although out of scope of this PR, is there a reason you aren't using the npm module for the tracker in the main repo? I'm assuming it's about the size, right? As an outsider with not that much experience my first thought was just how hard it must be to keep those two in sync without accidentally breaking the same feature policy. |
Hey guys! Sorry, I'm a bit confused... so what's the solution? 😁 If we want to have |
I stumbled upon this issue after our company deployed Plausible's outbound-tracking code and we immediately noticed almost exact same thing as #12 (comment). Pardon my ignorance (I'm not entirely versed in these JS+browser API things), but why is the line: plausible-tracker/src/lib/tracker.ts Line 288 in a5f8e94
... even necessary? Why does the Plausible tracking code need to do the actual request? Why doesn't it let it just pass and let the browser deal with the navigation itself (which also gives our app a chance to handle the click event the way we need it, without Plausible tracking code force-navigating away)? 🤔 |
@smuuf The script prevents the browser from executing the default behavior (which is to immediately switch sites (as fast as possible)), to quickly send an analytics request. Then it waits for a small delay in which the analytics request can be completed. Afterwards, the default behavior has to be invoked manually because it was suppressed originally, therefore a write to @smuuf @maximedupre as mentioned in my previous comment, there is an open PR to fix this (#21), which you can use by getting inspired from the links in my comment. @ everyonewhocares The only thing missing to allow #21 to be merged is tests as far as I understand. I do not have the time or interest to dive into the testing infrastructure used in this project but if you do, feel free to comment how to approach them or outright implement some tests on top of my PR (e.g. in your own fork, could then supersede my PR). |
So how about this problem? |
This is a pretty critical issue, is there any plan to assign it to someone? |
Can you please consider prioritizing this issue higher? |
Hello, Since this package have not been update for two years, I made a fork. I rewrite the tracker to be more modular and I fix this issue. |
Any update on this besides @Barbapapazes new fork (and the fix above from @abett)? The fix doesn't work for me (under Nuxt 3) -- and I'd like to stick with the canonical plausible instead of a fork. |
Hey @metmarkosaric! Since the package doesn't get updated regularly, do you think you can make @Barbapapazes the maintainer of this package and let him update it? It seems like his package is much better than the original one! Well done @Barbapapazes! |
@Barbapapazes, have you considered making a PR into this repo? |
Versions
Describe the bug
When loading plausible with link tracking, links with target _blank are no longer opened in a new tab.
Expected behavior
Instead, the link should open in a new tab.
Steps to reproduce
Steps:
Your Environment
Additional context
Might also be interesting to check if the rel attributes are respected (noopener) from a security perspective.
The text was updated successfully, but these errors were encountered: