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

SentryUser forces setting userId property #200

Closed
3 of 9 tasks
marcomonteiro opened this issue Aug 23, 2017 · 1 comment
Closed
3 of 9 tasks

SentryUser forces setting userId property #200

marcomonteiro opened this issue Aug 23, 2017 · 1 comment
Assignees

Comments

@marcomonteiro
Copy link

Platform:

  • iOS
  • tvOS
  • MacOS
  • watchOS

Swift:

  • Yes -> If yes, which version?
  • No

sentry-cocoa installed with:

  • CocoaPods
  • Carthage
  • Manually

Version of sentry-cocoa:
3.4.3


SentryUser forces use of optional userId property

The Sentry documentation for capturing the user states:

Users consist of a few key pieces of information which are used to construct a unique identity in Sentry. Each of these is optional, but one must be present in order for the user to be captured.

Although I could create a SentryUser using init the SDK though effective forces supplying a userId because the serialize method will attempt to capture the value of the userId property which would be nil and cause a crash.

- (NSDictionary<NSString *, id> *)serialize {
    NSMutableDictionary *serializedData = @{
            @"id": self.userId
    }.mutableCopy;

    [serializedData setValue:self.email forKey:@"email"];
    [serializedData setValue:self.username forKey:@"username"];
    [serializedData setValue:[self.extra sentry_sanitize] forKey:@"extra"];

    return serializedData;
}

In my particular case I don't have the userId available, only the username. Ideally the SDK would match the constraints/requirements of the Sentry API.

@HazAT HazAT self-assigned this Aug 23, 2017
HazAT added a commit that referenced this issue Aug 23, 2017
@marcomonteiro
Copy link
Author

marcomonteiro commented Aug 23, 2017

Hi Daniel. Thanks for working on this so quickly. Just a thought. Since the Sentry API expects that one of the fields be present do you think there should be some kind of error or (eek) exception thrown if attempting to serialize a SentryUser without at least one value set? Or maybe even simply returning nil. I haven't dug deep into the SDK code to know the implications though.

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

No branches or pull requests

2 participants