Skip to content
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

AnalyticsEvent.endpoint includes the HTTP request method #66

Merged
merged 14 commits into from
Jun 16, 2022

Conversation

eastandwestwind
Copy link
Contributor

@eastandwestwind eastandwestwind commented Jun 13, 2022

Purpose
Allows http method to be captured in analytics events

Closes #65

@PSalant726 PSalant726 added the enhancement New feature or request label Jun 13, 2022
Copy link
Contributor

@PSalant726 PSalant726 left a comment

Choose a reason for hiding this comment

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

This is a great start, but there are a few more changes we'll need on this PR:

  1. Please update L60 of the Makefile:

    @$(RUN_NO_DEPS) black --check fideslog/

    such that it becomes:

        @$(RUN_NO_DEPS) black --check --exclude="sdk/python/_version\.py" fideslog/

    This is because this will be the first PR opened since versioneer was added to the repo, and so the CI checks have never been run with those auto-generated files included. We need to ignore _version.py from this check, or it will always fail.

  2. In sdk/python/event.py:

    • Please update the AnalyticsEvent constructor docstring to match the updated documentation in api/models/analytics_event.py:

      :param endpoint: For events submitted as a result of making API server requests, the API endpoint path that was requested. If a fully-qualified URL is provided, only the URL path will be persisted.

    • Please update the validation code to match the new validation code in api/models/analytics_event.py:

      self.endpoint = None
      if endpoint is not None:
      assert urlparse(endpoint).path != "", "endpoint must include a URL path"
      self.endpoint = endpoint

  3. In tests/api/test_models.py, please update the test_full_payload fixture:

    "endpoint": "https://www.example.com/path/string",

.gitignore Outdated Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
fideslog/api/models/analytics_event.py Outdated Show resolved Hide resolved
fideslog/api/models/analytics_event.py Outdated Show resolved Hide resolved
@PSalant726 PSalant726 changed the title 65-endpoint-method- requires http method as part of endpoint AnalyticsEvent prop AnalyticsEvent.endpoint includes the HTTP request method Jun 14, 2022
@eastandwestwind
Copy link
Contributor Author

Updated based on your suggestions, thanks for the review, @PSalant726 !

Re: isort and pytest and black- I suspect something weird is going on with my editor, where I run auto-format for black and isort, and the changes do not appear in git diff. Similarly, running pytest fails locally bc the command-line is not picking up on recently updated code in intelliJ. I'll see if I can sort this out tomorrow

Copy link
Contributor

@PSalant726 PSalant726 left a comment

Choose a reason for hiding this comment

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

Thanks for making all the static analysis related changes! Sorry you got stuck with those, that's my fault 😞

This is looking really good now - just some minor suggestions!

.gitignore Show resolved Hide resolved
fideslog/api/models/analytics_event.py Outdated Show resolved Hide resolved
fideslog/api/models/analytics_event.py Outdated Show resolved Hide resolved
fideslog/sdk/python/__init__.py Show resolved Hide resolved
fideslog/sdk/python/event.py Outdated Show resolved Hide resolved
fideslog/sdk/python/event.py Outdated Show resolved Hide resolved
PSalant726
PSalant726 previously approved these changes Jun 15, 2022
Copy link
Contributor

@PSalant726 PSalant726 left a comment

Choose a reason for hiding this comment

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

LGTM! Just one UX question for you.

fideslog/api/models/analytics_event.py Outdated Show resolved Hide resolved
fideslog/sdk/python/__init__.py Show resolved Hide resolved
The only way to guarantee that we store just the URL path is to accept
a full URL, validate it, and then truncate it to only the URL path.

Also prevents the Python SDK from importing from the API server code.
By modifying the API endpoint URL within the `AnalyticsEvent`
validation mechanism, we prevent continued validations of
`AnalyticsEvent` instances from succeeding. In order to guarantee that
API endpoint URLs only have their paths stored in the database,
truncation must occur immediately prior to writing the new record.
Copy link
Contributor Author

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

@PSalant726 Just 1 blocking change request, otherwise looking good!

fideslog/api/database/data_access.py Show resolved Hide resolved
fideslog/api/database/data_access.py Show resolved Hide resolved
fideslog/api/models/analytics_event.py Show resolved Hide resolved
Copy link
Contributor Author

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

Thumbs up, tested manually full-stack and all looks good.

@PSalant726 PSalant726 merged commit 2e5f1ab into main Jun 16, 2022
@PSalant726 PSalant726 deleted the 65-endpoint-method branch June 16, 2022 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow request method in endpoint prop of AnalyticsEvent
2 participants