-
Notifications
You must be signed in to change notification settings - Fork 112
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
fix: Don't track hash params by default #1391
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +770 B (+0.07%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
I recall people complaining (in the past) about query params as well, so masking query param values would be also good, eg: function maskUrl(url: string): string {
try {
const parsedUrl = new URL(url);
parsedUrl.searchParams.forEach((_, key) => {
parsedUrl.searchParams.set(key, 'masked');
});
if (parsedUrl.hash) {
parsedUrl.hash = 'masked';
}
return parsedUrl.toString();
} catch (e) {
console.error("Invalid URL provided:", e);
return url;
}
}
const originalUrl = "https://www.google.com?query=123&login=true#456";
const maskedUrl = maskUrl(originalUrl);
console.log(maskedUrl); // "https://www.google.com/?query=masked&login=masked#masked" Not a blocker for this PR, just remembering that I had to do something like this in the past. |
@@ -32,6 +32,16 @@ export const CAMPAIGN_PARAMS = [ | |||
] | |||
|
|||
export const Info = { |
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 know it's not this PR but "info" makes me sad 🤣
we should rename it "misc" :p
return { | ||
// NOTE: Hash params are typically sensitive and not designed to be sent to servers so we exclude them here by default | ||
href: location?.href?.split('#')[0], | ||
hrefIncludingHash: location?.href, |
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.
almost feels like we should capture the hash params separately so that if folk really want them they can capture them
instead of having href and hash
I don't think that massively affects queries so no strong opinion but would sit nicely to have query_params
, pathname
, and hash_params
as separate things
(no need to take that as blocking here i think generally we could do with better url handling)
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.
agree it would be nice for this to be configurable...
arguably if we allow the config we should add a scrub function so folk can capture via allowlist or denylist so they don't capture sensitive info unless they really want to
since it looks like hash params are not being queried for by many folk we can probably not take on the complexity now and ask them if they need it and add it on demand
I feel like this isn't specific to URLs. We should just have a hook for people to hook into and modify the final captured event payload. That way they can do whatever level of modifications they want and avoids the need for more and more complex config options tbh... |
+100 🧠 |
I'm in favour of this too. This would be cool: import {stripQueryParams, stripProperties} from "@posthog/js-transforms"
posthog.init("my-token", {
transforms: [
stripQueryParams(["some-oauth-token", "some-ad-id"]),
stripProperties(["$browser"])
]
} |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
Changes
Hash params are typically not necessary to be tracked and often even undeseriable as they can be used for storing tokens etc. that never leave the browser.
I don't think we should track these by default. This is technically a breaking change so a little hard to guage but I strongly feel like the default should be not to track
We probably want to offer a config option to allow this...
Checklist