-
Notifications
You must be signed in to change notification settings - Fork 716
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
Fixing issue #6892: collect and report aggregate stats about client browsers through telemetry #7658
Conversation
- Collect the user agent from the request - call update_log adapted kolibri/core/logger/models.py - definition UserSessionLog: added user_agent string
- Collect the user agent from the request - call update_log adapted kolibri/core/logger/models.py - definition UserSessionLog: added user_agent string kolibri/core/logger/models.py - Added import from ua parser - In UserSessionLog.update_log, parse the user_agent string and add the device_info to the logentry requirements/base.txt: added ua_parser. Generated core/logger/migrations/0008_usersessionlog_device_info.py to added the device info column in the usersessionlog table.
- Added the calculations of the device_info summary as dis to extract_facility_statistics. kolibri/core/analytics/test/test_utils.py - Updated the test_extract_facility_statistic
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.
Everything looks good - one place where the code cold be clearer (in the place with the multi-line string concatenation as you suspected).
Tests only failed because of linting - the easiest way to manage this is to run:
pre-commit install
pre-commit run --all-files
This will run our linting pass on all the files
Replacing multiline per rtibbles suggestion Co-authored-by: Richard Tibbles <[email protected]>
Thanks for the tip. |
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.
Thanks for the PR! I pushed the linting fixes so we can get this merged straight away. Great stuff!
Test failure appears to be erroneous, but Travis is not letting me restart the job. Nothing in the PR is touching the code paths that the failing test covers. Merging. Will fix on the release branch if it continues to fail. |
Summary
The change collects the HTTP user agent in
(kolibri/core/auth/api.py)SessionViewset.get_session_response
and passes it on toUserSessionLog.update_log
. The latter function uses theua_parser
module to parse the HTTP user agent string into the requested string. and saves it to the database.The data is summarized in extract_facility_statistics.
Other changes:
ua_parser 0.10.0
was added to the dependencieslogger/migrations/0008_usersessionlog_device_info.py
was generatedtest_extract_facility_statistic
was adapted to add the new fieldReviewer guidance
update_log
definition has been adapted. I could only find one call to the function. So I did not default the new argument.ua_parser
is very fault resistant, I used that in the code. I don't check forNone
on the familiesI tested this using all available browsers (chrome, edge, firefox, comodo dragon) on all available os's (windows 10, ubuntu). The pingback is not tested.
References
Contributor Checklist
PR process:
Testing:
Reviewer Checklist
yarn
andpip
)