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

feat: add support for disabling tracking via localStorage #105

Merged
merged 4 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,14 @@ const preflight = computed((): PreflightResult => {
if (!host || !isValidHost(endpoint.value))
return 'host';

const {
location: { hostname },
} = window;
const hostname = window.location.hostname;
const storage = window.localStorage;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure what the difference in access between window.localStorage and just using localStorage is, but I also can't find any information on the internet about this, so if this also works, I don't have an oponion :D


if (ignoreLocal && hostname === 'localhost')
return 'localhost';

// Disable tracking when umami.disabled=1 in localStorage
if (localStorage.getItem('umami.disabled') === '1')
if (storage.getItem('umami.disabled') === '1')
return 'local-storage';

const domains = domainList.value;
Expand Down