-
Notifications
You must be signed in to change notification settings - Fork 14
[FEATURE] Add telemetry to request meta by default #18
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
Conversation
98bf98f to
3748f42
Compare
f5cf571 to
07d4245
Compare
|
Hey @shtrom would you be able to do another review on this when you get a chance? Cheers ;) |
| # update and commit local version file used by tracking telemetry | ||
| echo -e "\\nWriting version file..." | ||
| sed -i "s/^VERSION *=.*/VERSION = '${new_version}'/" ${VERSION_FILE} | ||
| sed -i "s/^__version__ *=.*/__version__ = '${new_version}'/" ${VERSION_FILE} |
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.
Ah, we also need to fix the Makefile now, to check the _version.py file, rather than the setup.py
https://github.com/Learnosity/learnosity-sdk-python/blob/master/Makefile#L50
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.
Oh yeah, missed that one, thanks! Will update this line -
learnosity-sdk-python/Makefile
Line 50 in b53f296
| dist-check-version: PKG_VER=v$(shell sed -n "s/^.*VERSION\s\+=\s\+'\([^']\+\)'.*$$/\1/p" setup.py) |
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.
Yup, and this one so as to not confuse people
learnosity-sdk-python/Makefile
Line 54 in b53f296
| $(error Version number $(PKG_VER) in setup.py does not match git tag $(GIT_TAG)) |
shtrom
left a comment
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.
Cleanup in the README and fix in the Makefile needed, but otherwise good to go.
f6bf0c4 to
611382c
Compare
| $(PYTHON) setup.py bdist_wheel --universal | ||
| dist-upload: dist-check-version clean test dist-upload-twine | ||
| dist-check-version: PKG_VER=v$(shell sed -n "s/^.*VERSION\s\+=\s\+'\([^']\+\)'.*$$/\1/p" setup.py) | ||
| dist-check-version: PKG_VER=v$(shell sed -n "s/^.*__version__\s\+=\s\+'\([^']\+\)'.*$$/\1/p" learnosity_sdk/_version.py) |
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.
You should be able to use \s to match any whitespace (space, tab, ...) (thought my \+ in the initial line was misguided, and * is indeed better).
Also, I'd rather not be too specific on the format of the version, we just want to extract anything that's between the two quotes, which is what my \([^']\+\) was doing.
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.
@shtrom were you commenting on an earlier fixup where I had done this? (To make the sed regex run on macOS)
sed -n "s/^__version__[ ]*=[ ]*'\([0-9a-zA-Z\.]*\)'$$/\1/p" learnosity_sdk/_version.py
I've since changed it back to something closer to the original regex. As it's probably more robust if it only works on linux.
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.
Ah, yeah, I did, and was confused by a fixup, so I just copy/refresh/pasted my comment.
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.
You can try to run a make dist-check-version, and make sure that the version is properly extracted from the version file by looking at the command it runs.
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'd like to 2nd using * instead of \+ here just to account for the event where a space is somehow accidentally removed.
611382c to
febeb9b
Compare
Simplify deployment instructions in README
| - Add better context to `DataApiException`s | ||
| - Telemetry support | ||
|
|
||
| ### Security fixes: |
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.
This probably should have been mentioned in the previous PR, but would you mind fixing up this line to be ### Security instead, to match how we've done it in other places (and the examples)?
| """ | ||
| We use telemetry to enable better support and feature planning. It is | ||
| however not advised to disable it, and it will not interfere with any usage. | ||
| """ |
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'd suggest moving this comment down to where we have the enable/disable methods as it's more likely someone will search for those than the private variable. (Just to increase visibility)
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.
Cool 👍
| output['action'] = self.action | ||
|
|
||
| if self.__telemetry_enabled: | ||
| output['meta'] = self.get_meta() |
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 don't account for it in PHP, but in Node and Java I've made sure that we edit or add the meta object, instead of completely replacing it. I'm not sure if this is particularly important but might be useful to do here in case one of our APIs starts needing a meta field in any of its requests.
https://github.com/Learnosity/learnosity-sdk-nodejs/blob/master/index.js#L41-L51
https://github.com/Learnosity/learnosity-sdk-java/blob/master/src/main/java/learnositysdk/request/Telemetry.java#L56-L63
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.
Seems a bit yucky to prejudge the actions of a future developer by checking for a condition that definitely isn't true at the moment, no? Output is created as an empty dict ~40 lines earlier and stuff is added to it as needed.
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.
Actually, now that you point that out - the meta is supposed to be added to the actual request object. Not the root level object for the request.
So my point here is that a user could add a meta field to their request data (again, possible in the case that one of our many APIs starts using that field) and this would overwrite that data which the user is trying to send to our sever.
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.
Ah, that makes sense, thanks @flakeparadigm.
|
|
||
| setuptools.setup( | ||
| author='Cera Davies', | ||
| author_email='[email protected]', |
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 should probably update these Author details. Not sure what email we should use, though. Might need to double check with @sebablanco?
setuptools.setup(
author='Learnosity',
author_email='[email protected]',
...
)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.
Lol yes, I noticed this and had made a note to find out what the email should be.
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.
@alangarf has just created [email protected] for this.
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.
Cheers 😁 👍
Checklist
Feature
Bug
Security
Documentation
ChangeLog.md updated
Tests added
All testsuites passed
make distcompleted successfully