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

currentRef is always resolves to referrer #3016

Open
condemil opened this issue Oct 21, 2024 · 3 comments
Open

currentRef is always resolves to referrer #3016

condemil opened this issue Oct 21, 2024 · 3 comments

Comments

@condemil
Copy link

Describe the Bug

I was reviewing the tracker source code and found a suspicious check on the following line:

let currentRef = referrer !== hostname ? referrer : '';

The hostname in here is location.hostname, which is just the host part of url (without port). And the referrer is document.referrer which is the full url. I see it as a potential bug as i always resolves to true.

Database

Umami Cloud

Relevant log output

No response

Which Umami version are you using? (if relevant)

No response

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@franciscao633
Copy link
Collaborator

Its just a condition to prevent the hostname of your website from being recorded as a referrer. Taking a quick look at the docs for document.referrer, I'm guessing this note below can potentially be an issue? But I think your correct, since once your on the website, handlePush will determine the currentRef.

If the user navigated to the page via a link like <a href="https://www.w3.org/">W3</a>, then it will output the previous domain like developer.mozilla.org. If the user navigated to the page directly, it will output an empty string.

It is working since umami.is doesn't refer to itself, but it will probably work with the below?

let currentRef = referrer

@condemil
Copy link
Author

Right, let currentRef = referrer; should be equal to the current behavior.

That means when the user browse through the website the previous url will be recorded as the referrer as there is no hostname check.

If you want to prevent sending referrer for the same hostname there should be some logic to extract hostname from the document.referrer and compare it with location.hostname.

@condemil
Copy link
Author

condemil commented Oct 21, 2024

Just to clarify, I'm talking about the case when a user navigates through full page refresh (like <a href=...> links), not SPA websites.

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