-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ref(toolbar): check queryReferrer from query param and refactor tests for readability #79220
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #79220 +/- ##
==========================================
- Coverage 78.27% 78.26% -0.01%
==========================================
Files 7137 7136 -1
Lines 314581 314610 +29
Branches 51361 51368 +7
==========================================
+ Hits 246225 246244 +19
- Misses 61906 61915 +9
- Partials 6450 6451 +1 |
src/sentry/middleware/devtoolbar.py
Outdated
query_string = get_query_string(request) or None | ||
if query_string: | ||
params = query_string.lstrip("?").split("&") | ||
params = list(filter(lambda s: s != "queryReferrer=devtoolbar", params)) | ||
query_string = f"?{'&'.join(params)}" if params else None | ||
|
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.
what's going on here?
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.
From description:
For SQL query convenience, the analytics event will exclude this from the query string.
It finds the "queryReferrer=devtoolbar" in the query string and scrubs it out
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.
Why do we need that for query convenience? What will queries look like with or without it?
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.
Hm ok thinking about it now, I don't think there's a guarantee on the positioning of params, so our queries would look like WHERE query_string LIKE '%key=val%'
regardless. So this doesn't make queries more convenient.
This does reduce the amount of data stored though. Lmk if you want to keep it or not, I don't have a preference anymore
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.
we could chop it out and keep the code simple. if we need something like that later it can be added back in.
Follow-up to #78778
Confirmed with Ryan the toolbar sends
queryReferrer
as a query param, not a HTTP header. For ex,<path>/?queryReferrer=devtoolbar
. For SQL query convenience, the analytics event will exclude this from the query string.Also refactors tests for better readability, removing the helper in the unit test class completely.
Also marks some more fields as
required=False
in the event definition. We need this foruser_id
in case of unauthenticated or anonymous requests. Note events with null user_id won't be sent to amplitude. Fixes SENTRY-3GMT