Skip to content

Commit 2444b8f

Browse files
feat(native): update set_user calls to use new new_user function output (#13624)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> Relevant vercel preview pages - https://sentry-docs-plsrr24j2.sentry.dev/platforms/native/enriching-events/scopes/#configuring-the-scope - https://sentry-docs-plsrr24j2.sentry.dev//platforms/native/enriching-events/identify-user/ - https://sentry-docs-plsrr24j2.sentry.dev/platforms/native/data-management/sensitive-data/#examples ## DESCRIBE YOUR PR Related to the change in getsentry/sentry-native#1228 From now on, we provide the `sentry_value_new_user(id, username, email, ip_address)` function that fills out the correct keys. This should reduce user error & confusion with what keys are processed by Sentry (see the [original issue](getsentry/sentry-native#1225) the function was added for). ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Mischan Toosarani-Hausberger <[email protected]>
1 parent be78202 commit 2444b8f

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

platform-includes/enriching-events/scopes/configure-scope/native.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ The Native SDK maintains all data in a single global scope.
55

66
sentry_set_tag("my-tag", "my value");
77

8-
sentry_value_t user = sentry_value_new_object();
9-
sentry_value_set_by_key(user, "id", sentry_value_new_int32(42));
10-
sentry_value_set_by_key(user, "email", sentry_value_new_string("[email protected]"));
8+
// Set a user with id, username, email, and ip_address
9+
sentry_value_t user = sentry_value_new_user("42", "Jane Doe", "[email protected]", "{{auto}}");
1110
sentry_set_user(user);
1211
```

platform-includes/enriching-events/set-user/native.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
```c
22
#include <sentry.h>
33

4-
sentry_value_t user = sentry_value_new_object();
5-
sentry_value_set_by_key(user, "ip_address", sentry_value_new_string("{{auto}}"));
6-
sentry_value_set_by_key(user, "email", sentry_value_new_string("[email protected]"));
4+
// Set a user with id, username, email, and ip_address
5+
sentry_value_t user = sentry_value_new_user("42", "Jane Doe", "[email protected]", "{{auto}}");
6+
// Set additional custom user data
7+
sentry_value_set_by_key(user, "custom_key", sentry_value_new_string("custom_value"));
78
sentry_set_user(user);
89
```
910
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
The Native SDK maintains all data in a single global scope.
2-
31
```c
42
#include <sentry.h>
53

6-
sentry_value_t user = sentry_value_new_object();
7-
sentry_value_set_by_key(user, "id", sentry_value_new_int32(client_user->id));
8-
// OR
9-
sentry_value_set_by_key(user, "username", sentry_value_new_string(client_user->username));
4+
// At least one parameter must be non-NULL. In this case, the user value will only
5+
// contain the id. username, email, and ip_address will be ignored.
6+
sentry_value_t user = sentry_value_new_user("42", NULL, NULL, NULL);
107
sentry_set_user(user);
118
```

0 commit comments

Comments
 (0)