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

Support gzip encoding from posthog-js #2701

Merged
merged 6 commits into from
Dec 8, 2020
Merged

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Dec 8, 2020

  • update rrweb to latest
  • Support gzip-js compression
  • Add test for gzip-js encoded captures

Companion PR: PostHog/posthog-js#151

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests

This is subtly different from `gzip` since it requires text/plain
encoding (we can't send application/json due to CORS).

We need a separate name for this because of this as older versions of
posthog don't support text/plain
@timgl timgl temporarily deployed to posthog-text-plain-deco-yenyek December 8, 2020 11:26 Inactive
@@ -155,6 +155,24 @@ def test_emojis_in_text(self, patch_process_event_with_plugins):
"💻 Writing code",
)

@patch("posthog.models.team.TEAM_CACHE", {})
@patch("posthog.api.capture.celery_app.send_task")
def test_js_gzip(self, patch_process_event_with_plugins):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth adding a test for an incorrectly formatted payload with gzip-js to make sure it's handled gracefully?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. Unsure what the expected behavior here is - silently eating errors in the util would lead to problems elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm making a proposal change for this, will just make sure a proper error response is returned instead of a cryptic 500

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind, as the /capture endpoint is not on DRF, handling the exception requires a more comprehensive refactor, tabling this for now into a separate issue.

@timgl timgl temporarily deployed to posthog-text-plain-deco-yenyek December 8, 2020 13:57 Inactive
Copy link
Contributor

@paolodamico paolodamico 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 added a few test assertions to include the compression algorithms.

@timgl timgl temporarily deployed to posthog-text-plain-deco-yenyek December 8, 2020 13:59 Inactive
@timgl timgl temporarily deployed to posthog-text-plain-deco-yenyek December 8, 2020 14:07 Inactive
@paolodamico paolodamico merged commit f94b15a into master Dec 8, 2020
@paolodamico paolodamico deleted the text-plain-decompress branch December 8, 2020 16:17
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.

None yet

3 participants