-
Notifications
You must be signed in to change notification settings - Fork 643
feat(integrations): Gate user info behind data_collection config #6876
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
Changes from all commits
5a2c705
4ee42d0
86566bd
057caa4
c7cb8f8
6918597
9038fe5
7377073
1634927
093a47e
6e3c9ca
64e29e9
f409f02
11fb505
d28ee71
2fbf67a
c210fa3
236efc7
c265efd
077e667
350f483
2dd69af
72bc9db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -437,10 +437,26 @@ | |
| if "headers" in aws_event: | ||
| request["headers"] = _filter_headers(aws_event["headers"]) | ||
|
|
||
| if should_send_default_pii(): | ||
| client_options = sentry_sdk.get_client().options | ||
| if has_data_collection_enabled(client_options): | ||
| if client_options["data_collection"]["user_info"]: | ||
| user_info = sentry_event.setdefault("user", {}) | ||
|
|
||
| identity = aws_event.get("requestContext", {}).get("identity") | ||
| if identity is None: | ||
| identity = {} | ||
|
|
||
| id = identity.get("userArn") | ||
| if id is not None: | ||
| user_info.setdefault("id", id) | ||
|
|
||
| ip = identity.get("sourceIp") | ||
|
Check warning on line 453 in sentry_sdk/integrations/aws_lambda.py
|
||
| if ip is not None: | ||
| user_info.setdefault("ip_address", ip) | ||
| elif should_send_default_pii(): | ||
| user_info = sentry_event.setdefault("user", {}) | ||
|
|
||
| identity = aws_event.get("identity") | ||
| identity = aws_event.get("requestContext", {}).get("identity") | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a bug that was found in adding test coverage for this. Docs for the expected payload can be found here but the tl;dr image from the page:
|
||
| if identity is None: | ||
| identity = {} | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Need to add some ignore rules in this directory, because the unit tests will add the Sentry SDK and its dependencies | ||
| # into this directory to create a Lambda function package that contains everything needed to instrument a Lambda function using Sentry. | ||
|
|
||
| # Ignore everything | ||
| * | ||
|
|
||
| # But not index.py | ||
| !index.py | ||
|
|
||
| # And not .gitignore itself | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import os | ||
|
|
||
| import sentry_sdk | ||
| from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration | ||
|
|
||
| sentry_sdk.init( | ||
| dsn=os.environ.get("SENTRY_DSN"), | ||
| traces_sample_rate=1.0, | ||
| integrations=[AwsLambdaIntegration()], | ||
| _experiments={ | ||
| "data_collection": { | ||
| "user_info": False, | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| def handler(event, context): | ||
| return {"event": event} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Need to add some ignore rules in this directory, because the unit tests will add the Sentry SDK and its dependencies | ||
| # into this directory to create a Lambda function package that contains everything needed to instrument a Lambda function using Sentry. | ||
|
|
||
| # Ignore everything | ||
| * | ||
|
|
||
| # But not index.py | ||
| !index.py | ||
|
|
||
| # And not .gitignore itself | ||
| !.gitignore |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import os | ||
|
|
||
| import sentry_sdk | ||
| from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration | ||
|
|
||
| sentry_sdk.init( | ||
| dsn=os.environ.get("SENTRY_DSN"), | ||
| traces_sample_rate=1.0, | ||
| integrations=[AwsLambdaIntegration()], | ||
| _experiments={ | ||
| "data_collection": { | ||
| "user_info": True, | ||
| } | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| def handler(event, context): | ||
| return {"event": event} |

Uh oh!
There was an error while loading. Please reload this page.