Return response objects from all client methods#122
Merged
hownowstephen merged 2 commits intomainfrom May 8, 2026
Merged
Conversation
washam-cio
approved these changes
May 7, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a91619d. Configure here.
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
Update test_2xx_status_codes_accepted to assert on Response object instead of text. Add missing return to batch() method.
a91619d to
b07b660
Compare
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 small but behavior-changing API shift:
send_requestand all Track API calls now returnrequests.Response, which may break callers that assumedNone/string returns or compared return values directly. Core request/response handling is touched, but logic changes are straightforward and covered by updated tests.Overview
Updates the core HTTP layer so
ClientBase.send_request()returns the fullrequests.Responseobject (instead ofresponse.text).Propagates this through the Track client so methods like
identify,track,delete,merge_customers, andbatchnow return the response rather thanNone, enabling callers to inspect status codes/headers.Keeps
APIClientreturn values as parsed JSON dicts, but switches parsing toresp.json()and removes the now-unusedjsonimport. Tests are updated to assert onResponseattributes (e.g.,status_code) instead of raw strings.Reviewed by Cursor Bugbot for commit b07b660. Bugbot is set up for automated code reviews on this repo. Configure here.