Return response objects from all client methods#122
Open
hownowstephen wants to merge 1 commit intomainfrom
Open
Return response objects from all client methods#122hownowstephen wants to merge 1 commit intomainfrom
hownowstephen wants to merge 1 commit intomainfrom
Conversation
send_request() now returns the requests.Response object instead of response.text. Track API methods (identify, track, etc.) return the response instead of None, letting callers inspect status codes, headers, and body. APIClient methods continue to return parsed JSON dicts. Closes #85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
send_request()now returns therequests.Responseobject instead ofresponse.textidentify,track,pageview,backfill,delete,add_device,delete_device,suppress,unsuppress,merge_customers) now return the response instead ofNonesend_email,send_push, etc.) continue to return parsed JSON dicts — switched fromjson.loads(resp)toresp.json()Breaking change
Track API methods previously returned
None. Code that checkedresult is Noneor relied on the falsy return will need updating. However, the most common usage pattern (cio.identify(...)without capturing return) is unaffected.Example
Closes #85
Test plan
test_client_base.pyassertions for Response objectsNote
Medium Risk
This is a user-visible return-type change for
ClientBase.send_requestand all Track API calls, which can break callers that relied onNone/string responses; runtime behavior otherwise stays the same.Overview
Changes client return contracts to expose HTTP responses.
ClientBase.send_request()now returns the fullrequests.Responseobject (instead ofresponse.text), and all Track API methods (e.g.identify,track,delete,merge_customers) now return that response rather thanNone.Keeps App API methods returning parsed JSON.
APIClienttransactional send methods switch fromjson.loads(resp)toresp.json()to match the new response type. Tests are updated to assert onstatus_codeand response objects rather than raw strings.Reviewed by Cursor Bugbot for commit e7c4362. Bugbot is set up for automated code reviews on this repo. Configure here.