Skip to content

feat(django): Gate user identity behind data_collection config#6868

Open
ericapisani wants to merge 2 commits into
masterfrom
py-2583-django-user-info
Open

feat(django): Gate user identity behind data_collection config#6868
ericapisani wants to merge 2 commits into
masterfrom
py-2583-django-user-info

Conversation

@ericapisani

@ericapisani ericapisani commented Jul 23, 2026

Copy link
Copy Markdown
Member

Apply the data_collection.user_info setting to Django user identity (id, email, username) collection, giving it precedence over the legacy send_default_pii boolean when explicitly configured. This mirrors the existing behavior for client IP/user info already shipped for Flask, WSGI, and ASGI.

The user extraction logic in _after_get_response is pulled into a shared helper used by both the WSGI and ASGI event processors, and the parametrized send_default_pii/data_collection test matrix is extracted into tests/integrations/django/utils.py for reuse across the WSGI and ASGI test suites.

Refs PY-2583
Refs #6746

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

PY-2583

@ericapisani
ericapisani force-pushed the py-2583-django-user-info branch from cb1a6ba to 0f5f3fa Compare July 23, 2026 13:43
@ericapisani
ericapisani marked this pull request as ready for review July 23, 2026 13:44
@ericapisani
ericapisani requested a review from a team as a code owner July 23, 2026 13:44
@ericapisani
ericapisani marked this pull request as draft July 23, 2026 13:54
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

96422 passed | ⏭️ 6370 skipped | Total: 102792 | Pass Rate: 93.8% | Execution Time: 351m 29s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +522
Passed Tests 📈 +492
Failed Tests
Skipped Tests 📈 +30

All tests are passing successfully.

✅ Patch coverage is 85.37%. Project has 2513 uncovered lines.
✅ Project coverage is 89.67%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/django/init.py 82.86% ⚠️ 6 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.67%    89.67%        —%
==========================================
  Files          193       193         —
  Lines        24321     24337       +16
  Branches      8572      8586       +14
==========================================
+ Hits         21809     21824       +15
- Misses        2512      2513        +1
- Partials      1397      1399        +2

Generated by Codecov Action

@ericapisani
ericapisani marked this pull request as ready for review July 23, 2026 14:33
Comment thread tests/integrations/django/asgi/test_asgi.py
Apply the data_collection.user_info setting to Django user identity (id, email, username) collection, giving it precedence over the legacy send_default_pii boolean when explicitly configured. This mirrors the existing behavior for client IP/user info already shipped for Flask, WSGI, and ASGI.

The user extraction logic in _after_get_response is pulled into a shared helper used by both the WSGI and ASGI event processors, and the parametrized send_default_pii/data_collection test matrix is extracted into tests/integrations/django/utils.py for reuse across the WSGI and ASGI test suites.

Refs PY-2583
The new test was the only DB-touching test without @pytest.mark.forked. Running in the parent process leaked the created user into the shared in-memory sqlite DB (UNIQUE constraint failures in test_basic) and caused the parent to hold the session-scoped django_db_setup fixture, so forked children skipped postgres test DB creation but still destroyed it on teardown (database does not exist errors).
@ericapisani
ericapisani force-pushed the py-2583-django-user-info branch from 615580f to 4ee42d0 Compare July 23, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant