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

Missing clearUser method on react-native #1259

Closed
ghsdh3409 opened this issue Jan 22, 2021 · 8 comments
Closed

Missing clearUser method on react-native #1259

ghsdh3409 opened this issue Jan 22, 2021 · 8 comments
Labels
released This feature/bug fix has been released

Comments

@ghsdh3409
Copy link

Describe the bug

  • As an official reference document, there is clearUser method. But, after I upgrading v7, there is no clearUser.
  • Is this breaking change? If not, what should I use instead of clearUser?

Steps to reproduce

  1. Use Bugsnag.clearUser()

Environment

  • Bugsnag version: 7.6
  • React Native: 0.63.4
  • Device (e.g. iphonex): Android and iOS

Error screenshot

스크린샷 2021-01-22 오후 3 58 41

@xljones
Copy link

xljones commented Jan 22, 2021

Hey @ghsdh3409, the docs you've linked to are our legacy documents for the deprecated bugsnag-react-native package. The clearUser() method does not exist in the new React Native package.

In Bugsnag for React Native using bugsnag-js v7.3.0+, you can clear the user data though by calling Bugsnag.setUser(); without any arguments in the JS layer.

@xljones xljones closed this as completed Jan 22, 2021
@jdferreira-biai
Copy link

@xljones Thanks!

Btw, that should be added in the docs. I spent some time reading the docs looking for how to clear the user data.

@hannah-smartbear
Copy link

hannah-smartbear commented Nov 8, 2024

Hi @jdferreira-biai,

You can find information on how to clear user data using setUser in our docs here. Please let us know if you have any further questions!

@jdferreira-biai
Copy link

jdferreira-biai commented Nov 8, 2024

Hi @jdferreira-biai,

You can find information on how to clear user data using setUser in our docs here. Please let us know if you have any further questions!

@hannah-smartbear There is an issue. When I try to send null as value to the setUser function I get this type error:

Argument of type 'null' is not assignable to parameter of type 'string | undefined'. ts(2345)

Example:

import Bugsnag from '@bugsnag/js'

Bugsnag.setUser(null) // here i get the type error

I'm using @bugsnag/[email protected].

@mclack
Copy link
Contributor

mclack commented Nov 25, 2024

Hi @jdferreira-biai

Thanks for highlighting this.

This appears to be due to us enforcing the setUser() parameters as an optional string, allowing types of either string or undefined to be supplied to this method when using Typescript, but not null.

We have opened a PR to update this here. While I do not have a firm ETA on when this change will be released, we will look to put this through our full review process when priorities allow.

@mclack
Copy link
Contributor

mclack commented Feb 5, 2025

Hi @jdferreira-biai

I just wanted to update you here, as we recently released v8.2.0 of bugsnag-js, which corrects the setUser TS interface to allow for null arguments: https://github.com/bugsnag/bugsnag-js/releases/tag/v8.2.0

Please let us know if you have any further questions or issues. You can open a ticket with us directly by contacting [email protected].

@mclack mclack added the released This feature/bug fix has been released label Feb 5, 2025
@jdferreira-biai
Copy link

jdferreira-biai commented Feb 5, 2025

Hi @jdferreira-biai

I just wanted to update you here, as we recently released v8.2.0 of bugsnag-js, which corrects the setUser TS interface to allow for null arguments: https://github.com/bugsnag/bugsnag-js/releases/tag/v8.2.0

Please let us know if you have any further questions or issues. You can open a ticket with us directly by contacting [email protected].

Nice! Thanks for working on that. 👍🏻

So if I want to unset or clear the user I should do the following?

Bugsnag.setUser(null, null, null)

Also, it's there any difference if I do instead this?

Bugsnag.setUser()

(that's what I've been doing until now).

@mclack

@mclack
Copy link
Contributor

mclack commented Feb 7, 2025

Hi @jdferreira-biai

When calling Bugsnag.setUser() with no arguments, this should reset the user metadata to the default, which means that BugSnag will still attempt to capture the user's IP address, and this will be stored in the event as user.id.

However, when explicitly passing null arguments like Bugsnag.setUser(null, null, null), this should completely wipe all user metadata, meaning nothing would be reported along with the event, and no USER tab should appear.

Hopefully that makes sense, but please let us know if you have any other questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This feature/bug fix has been released
Projects
None yet
Development

No branches or pull requests

5 participants