Skip to content

[RUM] React Native - Update setUser method to setUserInfo #28949

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,47 @@

{{< img src="real_user_monitoring/browser/advanced_configuration/user-api.png" alt="User API in RUM UI" >}}

{{< tabs >}}
{{% tab "SDK version >= 2.6.5" %}}
<!-- source of truth: https://github.com/DataDog/dd-sdk-reactnative/pull/818 -->

| Attribute | Type | Description |
| ----------- | ------ | ------------------------------------------------------------------------------- |
| `usr.id` | String | (Required) Unique user identifier. |
| `usr.name` | String | (Optional) User friendly name, displayed by default in the RUM UI. |
| `usr.email` | String | (Optional) User email, displayed in the RUM UI if the user name is not present. |
| `usr.extraInfo` | Object | (Optional) Include custom attributes such as subscription type, any user specific information that enhance user context in RUM sessions. |

To identify user sessions, use the `setUserInfo` API, for example:

```js
DdSdkReactNative.setUserInfo({
id: '1337',
name: 'John Smith',
email: '[email protected]',
extraInfo: {
type: 'premium'
}
});
```

If you want to add or update user information, you can use the following code to modify the existing user's details.

```js
DdSdkReactNative.addUserExtraInfo({
hasPaid: 'true'
});
```

If you want to clear the user information (for example, when the user signs out), you can do so by passing an empty object, as follows:

Check notice on line 360 in content/en/real_user_monitoring/mobile_and_tv_monitoring/react_native/advanced_configuration.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.sentencelength

Suggestion: Try to keep your sentence length to 25 words or fewer.

```js
DdSdkReactNative.setUser({});
```

{{% /tab %}}
{{% tab "Legacy" %}}

| Attribute | Type | Description |
| ----------- | ------ | ------------------------------------------------------------------------------- |
| `usr.id` | String | (Required) Unique user identifier. |
Expand Down Expand Up @@ -356,6 +397,9 @@
DdSdkReactNative.setUser({});
```

{{% /tab %}}
{{< /tabs >}}

### Global attributes

You can also keep global attributes to track information about a specific session, such as A/B testing configuration, ad campaign origin, or cart status.
Expand Down
Loading