Skip to content

Conversation

jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jun 19, 2025

  • Remove throws from identifyUser, and return ClientError.InvalidUser in error callback like the config errors

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the throwing behavior from identifyUser and switches to reporting ClientError.InvalidUser via the callback, aligning it with how other errors are handled.

  • Updated the synchronous identifyUser to call the callback with .InvalidUser instead of throwing.
  • Refactored the async wrapper to use the callback-based API in a throwing continuation.
  • Added new unit tests to verify error behavior for invalid users in both callback and async forms.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
DevCycle/DevCycleClient.swift Changed identifyUser to non-throwing, invoke error callback on invalid input, and refactored async
DevCycleTests/Models/DevCycleClientTests.swift Added tests for identifyUser errors when given an empty user ID in both callback and async cases
Comments suppressed due to low confidence (2)

DevCycle/DevCycleClient.swift:426

  • The method signature was updated to remove throws but any existing doc comments or API documentation should also be updated to reflect this change and indicate that errors are now delivered via the callback.
    public func identifyUser(user: DevCycleUser, callback: IdentifyCompletedHandler? = nil) {

DevCycleTests/Models/DevCycleClientTests.swift:804

  • The async test creates an XCTestExpectation but never waits for it, which may cause the test to complete before assertions are executed. Either remove the expectation and assert directly in the async context or add a wait(for:timeout:) (or await fulfillment(of:timeout:)) to ensure the expectation is fulfilled.
    func testAsyncIdentifyUserWithInvalidUserCallsCallbackWithError() async throws {

@jonathannorris
Copy link
Member Author

ugh @jsalaber now that change means this is an issue:
image

Which is probably a lot of folks are using identifyUser without setting a callback :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants