Skip to content

feat(browser-reporting): Add ReportingEndpoint header when staff loads Sentry #93138

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 3 commits into from
Jun 10, 2025

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Jun 9, 2025

We want to start collecting browser reports on a temporary endpoint in S4S. This will only be enabled for staff members.

This is a temporary solution until we can build the proper Relay endpoint.

It is intentional that:

  • It requires no auth since browsers do not send reports using user credentials
  • It is sent to s4s as we don't want any impact on saas

The endpoint will be added in a different pull request. We will have an option to shut down the reporting if needed.

armenzg added 2 commits June 9, 2025 14:37
We want to start collecting browser reports on a temporary endpoint in S4S.
This will only be enable for staff members.

This is a temporary solution until we can build the proper Relay endpoint.
@armenzg armenzg self-assigned this Jun 9, 2025
@armenzg armenzg requested a review from lobsterkatie June 9, 2025 18:42
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 9, 2025
@armenzg armenzg changed the title feat: Add ReportingEndpoint header when staff loads Sentry feat(browser-reporting): Add ReportingEndpoint header when staff loads Sentry Jun 9, 2025
@armenzg armenzg marked this pull request as ready for review June 9, 2025 18:49
@armenzg armenzg requested review from a team as code owners June 9, 2025 18:49
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93138      +/-   ##
==========================================
+ Coverage   87.89%   87.90%   +0.01%     
==========================================
  Files       10298    10309      +11     
  Lines      591455   592226     +771     
  Branches    23007    23007              
==========================================
+ Hits       519876   520614     +738     
- Misses      71143    71176      +33     
  Partials      436      436              

@armenzg armenzg requested a review from a team June 10, 2025 11:31
Comment on lines +23 to +24
staff = getattr(request, "staff", None)
if staff and staff.is_active:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure there's a helper for this that's supposed to be used instead?

from django.http.response import HttpResponseBase


class ReportingEndpointMiddleware:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may find the functional approach to middleware easier -- for instance sentry.middleware.env

@armenzg armenzg merged commit 7bc01e0 into master Jun 10, 2025
60 checks passed
@armenzg armenzg deleted the add/headers/armenzg branch June 10, 2025 14:40
Copy link

sentry-io bot commented Jun 11, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ RetryError: Timeout of 60.0s exceeded /api/0/organizations/{organization_id_or_slug}/... View Issue
  • ‼️ ServiceUnavailable: GET https://www.googleapis.com/download/storage/v1/b/sentryio-filestore-control-control/o/a9%2F5773%2Fb5e01140599fa187313a1068b6?alt=media: We encountered an internal error. Please try again.: ('Request failed with status code', 503, 'Expected one of', ... /doc-integration-avatar/{avatar_id}/ View Issue
  • ‼️ SnubaError: HTTPConnectionPool(host='snuba-api', port=80): Max retries exceeded with url: /events/snql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7877d6d41b50>: Failed to establish a new connection: [Errno 111] Connection refused')) /api/0/projects/{organization_id_or_slug}/{proj... View Issue
  • ‼️ OperationalError: [Errno 111] Connection refused /api/0/organizations/{organization_id_or_slug}/... View Issue
  • ‼️ SnubaError: HTTPConnectionPool(host='snuba-api', port=80): Max retries exceeded with url: /outcomes_raw/snql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x79e707bf70b0>: Failed to establish a new connection: [Errno 111] Connection re... /api/0/projects/{organization_id_or_slug}/{proj... View Issue

Did you find this useful? React with a 👍 or 👎

lobsterkatie added a commit that referenced this pull request Jun 11, 2025
#93306)

This adds an API endpoint, `api/0/reporting-api-experiment`, to collect deprecation, intervention, and crash reports enabled by the recently added[1] `Reporting-Endpoints` header This will hopefully get us a bit more real-world data to work with when deciding how we want to group/process/etc the reports.

Since we don't yet  know what kind of volume we're going to see, by default the endpoint is a no-op, and just returns a 404. However, if the new `issues.browser_reporting.collector_endpoint_enabled` option is set to `True` (as we are planning to do in S4S), the endpoint will log the incoming report to GCP and collect a metric on the overall report type.

DISCLAIMER: This is proving hell on wheels to test locally. You have to proxy through an https server, it's unclear if the CORS and CSRF set up is correct, Chrome offers almost no data about the requests it's sending (and none at all unless you flip a hidden flag[2]), you have to run Chrome from the command line with a different hidden flag[3] in order to have the reports immediately rather than after a random delay... So thus far this endpoint has only been observed working a small handful of times, under circumstances that now seem unreplicable. However, since the entire thing is experimental and temporary (and by default doesn't do anything), we decided in the interest of time to just give it a shot and see what comes through.

If we want to guarantee reports will be sent (to test if it's working at all), adding `navigator.vibrate(2000)` to our FE pageload will generate an intervention report, and adding `new Range().expand("dogs.are.great", 0, 1)` anywhere in our FE will generate a deprecation report.


[1] #93138
[2] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#use_devtools
[3] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#save_time
vishnupsatish pushed a commit that referenced this pull request Jun 12, 2025
#93306)

This adds an API endpoint, `api/0/reporting-api-experiment`, to collect deprecation, intervention, and crash reports enabled by the recently added[1] `Reporting-Endpoints` header This will hopefully get us a bit more real-world data to work with when deciding how we want to group/process/etc the reports.

Since we don't yet  know what kind of volume we're going to see, by default the endpoint is a no-op, and just returns a 404. However, if the new `issues.browser_reporting.collector_endpoint_enabled` option is set to `True` (as we are planning to do in S4S), the endpoint will log the incoming report to GCP and collect a metric on the overall report type.

DISCLAIMER: This is proving hell on wheels to test locally. You have to proxy through an https server, it's unclear if the CORS and CSRF set up is correct, Chrome offers almost no data about the requests it's sending (and none at all unless you flip a hidden flag[2]), you have to run Chrome from the command line with a different hidden flag[3] in order to have the reports immediately rather than after a random delay... So thus far this endpoint has only been observed working a small handful of times, under circumstances that now seem unreplicable. However, since the entire thing is experimental and temporary (and by default doesn't do anything), we decided in the interest of time to just give it a shot and see what comes through.

If we want to guarantee reports will be sent (to test if it's working at all), adding `navigator.vibrate(2000)` to our FE pageload will generate an intervention report, and adding `new Range().expand("dogs.are.great", 0, 1)` anywhere in our FE will generate a deprecation report.


[1] #93138
[2] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#use_devtools
[3] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#save_time
andrewshie-sentry pushed a commit that referenced this pull request Jun 19, 2025
…s Sentry (#93138)

We want to start collecting browser reports on a temporary endpoint in
S4S. This will only be enabled for staff members.

This is a temporary solution until we can build the proper Relay
endpoint.

It is intentional that:
* It requires no auth since browsers do not send reports using user
credentials
* It is sent to s4s as we don't want any impact on saas

The endpoint will be added in a different pull request. We will have an
option to shut down the reporting if needed.
andrewshie-sentry pushed a commit that referenced this pull request Jun 19, 2025
#93306)

This adds an API endpoint, `api/0/reporting-api-experiment`, to collect deprecation, intervention, and crash reports enabled by the recently added[1] `Reporting-Endpoints` header This will hopefully get us a bit more real-world data to work with when deciding how we want to group/process/etc the reports.

Since we don't yet  know what kind of volume we're going to see, by default the endpoint is a no-op, and just returns a 404. However, if the new `issues.browser_reporting.collector_endpoint_enabled` option is set to `True` (as we are planning to do in S4S), the endpoint will log the incoming report to GCP and collect a metric on the overall report type.

DISCLAIMER: This is proving hell on wheels to test locally. You have to proxy through an https server, it's unclear if the CORS and CSRF set up is correct, Chrome offers almost no data about the requests it's sending (and none at all unless you flip a hidden flag[2]), you have to run Chrome from the command line with a different hidden flag[3] in order to have the reports immediately rather than after a random delay... So thus far this endpoint has only been observed working a small handful of times, under circumstances that now seem unreplicable. However, since the entire thing is experimental and temporary (and by default doesn't do anything), we decided in the interest of time to just give it a shot and see what comes through.

If we want to guarantee reports will be sent (to test if it's working at all), adding `navigator.vibrate(2000)` to our FE pageload will generate an intervention report, and adding `new Range().expand("dogs.are.great", 0, 1)` anywhere in our FE will generate a deprecation report.


[1] #93138
[2] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#use_devtools
[3] https://developer.chrome.com/docs/capabilities/web-apis/reporting-api#save_time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants