Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode autocomplete for Swift expects person.id, but codebase expects person.ID #110

Closed
doublerebel opened this issue Dec 14, 2021 · 2 comments · Fixed by #119
Closed

Xcode autocomplete for Swift expects person.id, but codebase expects person.ID #110

doublerebel opened this issue Dec 14, 2021 · 2 comments · Fixed by #119
Assignees
Labels
bug Something isn't working

Comments

@doublerebel
Copy link

doublerebel commented Dec 14, 2021

Describe the bug
Xcode autocomplete for Swift expects person.id, but codebase expects person.ID. This caused one of our devs to set the Person id with config.person.id =, but rollbar-apple will never send it. It checks for config.person.ID in buildRollbarPerson when preparing to send a message.

This means the .ID getters and setters are basically unusable in Swift. The other initializers and convenience methods still work, and internally set the correct value -- which I think is why this isn't caught in the tests. The docs only list a couple ways to set the Person properties, although I see in the codebase there are many ways to set the Person properties.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Xcode

  2. Install rollbar-apple as a dependency

  3. Create a RollbarConfig(), and attempt to autocomplete config.person.ID

  4. See autocomplete suggest the wrong property:
    image

  5. Fails to compile with error:

    'ID' has been renamed to 'id'

    image

Expected behavior
I expected .id to be the correct property, since that's what's listed as the data field key. I also expected the case to be consistent -- setting .ID externally to set .id internally was not obvious when debugging.

Screenshots
See above.

Rollbar-Apple SDK version: Tested with at least v2.0.0-alpha33 through 2.0.0-beta.23. (This mistake was made a while ago and we have had no Persons appear in Rollbar for iOS, while Android + backend have been working as expected.)

Calling the SDK from (x-mark all suitable):
[ ] Objective-C
[x] Swift
[ ] Other:

Runtime environment (please complete the following information as applicable):

  • Device: Several simulators and devices
  • OS: iOS
  • OS version: 14.x, 15.x

Additional context
The convenience method on the config object is not that convenient, since I can't set any of the fields to nil. However, creating and setting a Person using the Person initializers works well, e.g.:

config.person = RollbarPerson(id: id, email: email)

It would be great to see more details about initializing and setting a Person in the docs. Also, if for some reason the ID/id field is not set (or has been unset), but the email and/or username field is set, then the Person will be ignored. This should be documented as well.

Overall, thanks for a very useful service!!

@lavenj
Copy link

lavenj commented Jan 17, 2022

+1, would have lost person telemetry after migration to swift package if not for this bug report

@akornich akornich self-assigned this Jan 18, 2022
@akornich akornich added the bug Something isn't working label Feb 10, 2022
akornich added a commit to WideSpectrumComputing/rollbar-apple that referenced this issue Feb 15, 2022
@akornich
Copy link
Contributor

A quick note on the upcoming fix (will be available within v2.0.2 sometime tomorrow):
The SDK is written in Objective-C and it spells RollbarPerson ID as ID. However, Objective-C to Swift often does some updates/renaming to public API (enum values is one well-known example), so as a result that property appears on the Swift side as id and Xcode's autocomplete picks it up correctly.
I did update relevant API code comments so that they make it correctly to the Swift side. And the RollbarPerson-related API was also updated to properly communicate required-vs-optional properties. ID is a required property, while username and email are optional.
A few specific scenarios when updating the person's properties would not make the expected effect are fixed and covered by new dedicated unit tests.

@doublerebel , thanks a lot for catching and reporting these! Please, feel free to submit any new feature requests for the SDK that you can think of. We will be more than happy to address those. Have a happy Rollbaring!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants