feat: Add gzip compression turned on by default#84
Conversation
This is *technically* a breaking change because we're now always sending data gzip compressed and people might not want that, but this will not break anyone's code so we'll release it as a minor knowing that it's an improvement. It's always been possible to swap the client off, but we weren't documenting how to do that exactly - this is now solved too.
|
@martosaur I believe you monitor your Github mentions, would love a review here :) |
posthog-elixir Compliance ReportDate: 2026-02-12 04:01:12 UTC ✅ All Tests Passed!29/29 tests passed Capture Tests✅ 29/29 tests passed View Details
|
| def client(api_key, api_host) do | ||
| client = | ||
| Req.new(base_url: api_host, retry: :transient) | ||
| Req.new(base_url: api_host, retry: :transient, compress_body: true) |
There was a problem hiding this comment.
some SDKs provide a client config for that eg https://github.com/PostHog/posthog-js/blob/a3cc497d977298637155a2c15030f3fcfe1e613f/packages/types/src/posthog-config.ts#L1228-L1234
also remote config returns supportedCompression which then we know if the server supports gzip or not
not a blocker, as this is already the default behaviour for many SDKs, and PH Cloud supports gzip.
There was a problem hiding this comment.
Exposing that to the client is a bit complicated and very not-Elixir. The best way to do this in Elixir really is to let people override the client - like we explained in the README.
There was a problem hiding this comment.
what i meant is the posthog config client, something next to api_key and api_host, where compress_body is optiona and defaults to true
its a much better UX to expose a compress_body config rather than telling the user to replace the whole http client.
Simpleness wins here, not a blocker.
There was a problem hiding this comment.
We can absolutely do that in the future if we wanna reduce the number of times people need to redefine the client, but you can also look at the docs above and see that "replacing the client" is very easy in Elixir.
Also, I'm pretty sure Elixir-heavy companies will find replacing the client to be a much sounder approach than just throwing yet another new config - this also simplifies the whole implementation, there's less things for people to think about if they don't have the 200 options we have in posthog-js, for example.
There was a problem hiding this comment.
happy to disagree with what would be easier, a boolean vs replacing the client (I did see the docs).
obv 200 options bloats and isn't great either.
alright, PR is approved anyway so it was just a suggestion
|
Looks good to me! |
This is technically a breaking change because we're now always sending data gzip compressed and people might not want that, but this will not break anyone's code so we'll release it as a minor knowing that it's an improvement. It's always been possible to swap the client off, but we weren't documenting how to do that exactly - this is now solved too.