Giter Site home page Giter Site logo

Comments (7)

luke-belton avatar luke-belton commented on June 4, 2024 1

Hi @parrotbait - thanks for raising this. Please could you share the code you're using to set the userID? Feel free to write into [email protected] with links to events in your dashboard where this isn't working as expected and we'd be happy to investigate further 👍

from bugsnag-cocoa.

parrotbait avatar parrotbait commented on June 4, 2024

I've updated the issue above further with the service calls captured via proxy, it's an on-premise hosted Bugsnag instance so you won't be able to access them.

I can share only pseudo code of what I've tried but it won't be especially useful I feel.

let userID: String? = AuthenticationService.shared.user.id // this can be `nil` if the user isn't logged in.
Bugsnag.setUser(userID, withEmail: email, andName: name)

I've also tried something like:

Bugsnag.addOnSession { session in
	let userID: String? = AuthenticationService.shared.user.id
	session.setUser(userID, withEmail: nil, andName: nil)
}

Using both of these approaches Bugsnag on iOS still sends along the device and app hash instead of nil for display on the console.

from bugsnag-cocoa.

luke-belton avatar luke-belton commented on June 4, 2024

Hi @parrotbait - calling session.setUser inside the addOnSession callback will only update the metadata that is sent with the session payload to Bugsnag (i.e. it won't impact event payloads, which are ultimately what are shown in your Bugsnag dashboard). In your session payload above you can see that this is working as expected according to the "user": {} element.

To set the current user globally, you're best to either do this via the setUser config method, or using the setUser method on the Bugsnag client. In my own testing the following code correctly clears the current user, overriding the default setting which is to set the userId to the deviceId:

Bugsnag.setUser(nil, withEmail: nil, andName: nil)

Where in your app are you calling Bugsnag.setUser?

from bugsnag-cocoa.

parrotbait avatar parrotbait commented on June 4, 2024

Ah ok - that makes sense.

I've called setUser on the config before the starts(with:) call, and also directly on the Bugsnag client after start(with:) so we clear down the Bugsnag fallback hash should the user be nil on the config.

I'm also calling setUser on the Bugsnag client when users authenticate, which can happen at somewhat arbitrary times during the app lifecycle.

from bugsnag-cocoa.

luke-belton avatar luke-belton commented on June 4, 2024

Hi @parrotbait - I've managed to reproduce what you're seeing here now. As documented here, if no userID is set we fall back on the Bugsnag generated deviceID. To prevent collection of this, you should instead set the value to an empty string, i.e.

Bugsnag.setUser("", withEmail: nil, andName: nil)

The current behaviour on bugsnag-cocoa actually differs between handled and unhandled events, and in fact your approach above does work for handled events (which is what I initially tested). This discrepancy is unintentional and we're just completing some internal discussions to decide the best way forward. I'll make sure we keep this thread updated with any changes in the future.

from bugsnag-cocoa.

parrotbait avatar parrotbait commented on June 4, 2024

Ah, that's good to know. Thanks for looking into it.

from bugsnag-cocoa.

johnkiely1 avatar johnkiely1 commented on June 4, 2024

Hey @parrotbait, just to let you know we have updated the behaviour in v6.22.0 to be consistent.

We will now use device.id in place of user.id for all events and sessions if BugsnagClient.user.id is set to nil.

To prevent collection completely, set it to an empty string or update it in OnSendError / OnSession

from bugsnag-cocoa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.