Skip to content

Conversation

@eoghanmcilwaine
Copy link
Contributor

@eoghanmcilwaine eoghanmcilwaine commented May 8, 2019

Checklist

  • Feature

  • Bug

  • Security

  • Documentation

  • ChangeLog.md updated

  • Tests added

  • All testsuites passed

  • make dist completed successfully

@eoghanmcilwaine eoghanmcilwaine force-pushed the LRN-20221/feature/add-telemetry branch from 98bf98f to 3748f42 Compare May 8, 2019 06:27
@eoghanmcilwaine eoghanmcilwaine force-pushed the LRN-20221/feature/add-telemetry branch 4 times, most recently from f5cf571 to 07d4245 Compare May 13, 2019 00:40
@eoghanmcilwaine
Copy link
Contributor Author

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}
Copy link
Contributor

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

Copy link
Contributor Author

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 -

dist-check-version: PKG_VER=v$(shell sed -n "s/^.*VERSION\s\+=\s\+'\([^']\+\)'.*$$/\1/p" setup.py)

Copy link
Contributor

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

$(error Version number $(PKG_VER) in setup.py does not match git tag $(GIT_TAG))

Copy link
Contributor

@shtrom shtrom left a 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.

@eoghanmcilwaine eoghanmcilwaine force-pushed the LRN-20221/feature/add-telemetry branch from f6bf0c4 to 611382c Compare May 13, 2019 06:49
$(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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@eoghanmcilwaine eoghanmcilwaine force-pushed the LRN-20221/feature/add-telemetry branch from 611382c to febeb9b Compare May 13, 2019 07:56
Simplify deployment instructions in README
@eoghanmcilwaine eoghanmcilwaine merged commit 41a615f into master May 14, 2019
@eoghanmcilwaine eoghanmcilwaine deleted the LRN-20221/feature/add-telemetry branch May 14, 2019 09:58
- Add better context to `DataApiException`s
- Telemetry support

### Security fixes:
Copy link
Contributor

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.
"""
Copy link
Contributor

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)

Copy link
Contributor Author

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()
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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]',
Copy link
Contributor

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]',
    ...
)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cheers 😁 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants