-
-
Notifications
You must be signed in to change notification settings - Fork 192
feat: add sentry_value_new_user
#1228
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
Conversation
|
user
object creation helper functionsentry_value_new_user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new function, sentry_value_new_user, to construct a user object with the correct key casing as defined in the documentation. Key changes include implementation of the user object creation functions in src/sentry_value.c, test case additions in tests/unit/test_value.c, and updates in related examples and documentation files.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/unit/test_value.c | Added tests to validate new user object creation, including edge cases. |
tests/assertions.py | Updated expected user id type from integer to string. |
src/sentry_value.c | Implemented sentry_value_new_user and helper function sentry_value_new_user_n. |
include/sentry.h | Added API prototypes and documentation for the new user functions. |
examples/example.c | Updated usage example to reflect string type for user id. |
CHANGELOG.md | Updated changelog to document the new feature. |
Files not reviewed (1)
- tests/unit/tests.inc: Language not supported
TEST_CHECK(sentry_value_is_null(user_null)); | ||
sentry_value_decref(user_null); | ||
|
||
sentry_value_t user_empty_str = sentry_value_new_user("", "", "", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding an inline comment explaining that providing empty strings as parameters should result in a null user, to clarify the expected behavior in this test.
sentry_value_t user_empty_str = sentry_value_new_user("", "", "", ""); | |
sentry_value_t user_empty_str = sentry_value_new_user("", "", "", ""); | |
// Providing empty strings as parameters should result in a null user. |
Copilot uses AI. Check for mistakes.
if (ip_address && ip_address_len) { | ||
sentry_value_set_by_key( | ||
rv, "ip_address", sentry_value_new_string(ip_address)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] It would be beneficial to add a comment describing the criteria under which the user object is considered invalid (i.e. when all parameters are empty or null), clarifying why the function returns null.
} | |
} | |
// If none of the provided parameters (id, username, email, ip_address) are valid | |
// (i.e., all are null or empty), the user object is considered invalid. | |
// In this case, a warning is logged, and a null value is returned. |
Copilot uses AI. Check for mistakes.
The only thing left is updating the docs to eliminate manual key-setting. |
…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]>
…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]>
Came up in discussion of #1225 ; when creating a user object, it's not immediately obvious which fields are expected and how they should be cased. Hence we add a
sentry_value_new_user(id, username, email, ip_address)
function that constructs the user object with the correct keys (as defined in the develop docs).The function should be used as follows:
ToDo:
set_user
calls to use newnew_user
function output sentry-docs#13624