Skip to content

Return response objects from all client methods#122

Open
hownowstephen wants to merge 1 commit intomainfrom
MESS-675_return-response-objects
Open

Return response objects from all client methods#122
hownowstephen wants to merge 1 commit intomainfrom
MESS-675_return-response-objects

Conversation

@hownowstephen
Copy link
Copy Markdown
Contributor

@hownowstephen hownowstephen commented May 7, 2026

Summary

  • send_request() now returns the requests.Response object instead of response.text
  • Track API methods (identify, track, pageview, backfill, delete, add_device, delete_device, suppress, unsuppress, merge_customers) now return the response instead of None
  • APIClient methods (send_email, send_push, etc.) continue to return parsed JSON dicts — switched from json.loads(resp) to resp.json()

Breaking change

Track API methods previously returned None. Code that checked result is None or relied on the falsy return will need updating. However, the most common usage pattern (cio.identify(...) without capturing return) is unaffected.

Example

# Before: no way to inspect the response
cio.identify(id="123", name="Alice")

# After: response available if needed
resp = cio.identify(id="123", name="Alice")
print(resp.status_code)  # 200

Closes #85

Test plan

  • Updated test_client_base.py assertions for Response objects
  • All existing Track API tests pass (use hooks, don't assert return values)
  • All existing APIClient tests pass (return value contract unchanged — still dicts)
  • Full test suite passes (28 tests)
  • Lint passes

Note

Medium Risk
This is a user-visible return-type change for ClientBase.send_request and all Track API calls, which can break callers that relied on None/string responses; runtime behavior otherwise stays the same.

Overview
Changes client return contracts to expose HTTP responses. ClientBase.send_request() now returns the full requests.Response object (instead of response.text), and all Track API methods (e.g. identify, track, delete, merge_customers) now return that response rather than None.

Keeps App API methods returning parsed JSON. APIClient transactional send methods switch from json.loads(resp) to resp.json() to match the new response type. Tests are updated to assert on status_code and 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.

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
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.

returning responses rather than None

1 participant