diff --git a/snuba/admin/static/index.tsx b/snuba/admin/static/index.tsx index 470ceb0a4d..463beffc77 100644 --- a/snuba/admin/static/index.tsx +++ b/snuba/admin/static/index.tsx @@ -31,6 +31,7 @@ client.getSettings().then((settings) => { replaysSessionSampleRate: settings.replaysSessionSampleRate, replaysOnErrorSampleRate: settings.replaysOnErrorSampleRate, }); + Sentry.setUser({ email: settings.userEmail }); } }); diff --git a/snuba/admin/static/types.tsx b/snuba/admin/static/types.tsx index e1e2884c22..b90a01891a 100644 --- a/snuba/admin/static/types.tsx +++ b/snuba/admin/static/types.tsx @@ -7,6 +7,7 @@ type Settings = { tracesSampleRate: number; replaysSessionSampleRate: number; replaysOnErrorSampleRate: number; + userEmail: string; }; export { AllowedTools, Settings }; diff --git a/snuba/admin/views.py b/snuba/admin/views.py index 924a33dd2c..605d5f1ca9 100644 --- a/snuba/admin/views.py +++ b/snuba/admin/views.py @@ -6,6 +6,7 @@ from dataclasses import asdict from typing import Any, List, Mapping, Optional, Sequence, Tuple, cast +import sentry_sdk import simplejson as json import structlog from flask import Flask, Response, g, jsonify, make_response, request @@ -96,7 +97,9 @@ def authorize() -> None: if request.endpoint != "health": user = authorize_request() logger.info("authorize.finished", user=user) - g.user = user + with sentry_sdk.push_scope() as scope: + scope.user = {"email": user.email} + g.user = user @application.route("/") @@ -123,6 +126,7 @@ def settings_endpoint() -> Response: "tracesSampleRate": settings.ADMIN_TRACE_SAMPLE_RATE, "replaysSessionSampleRate": settings.ADMIN_REPLAYS_SAMPLE_RATE, "replaysOnErrorSampleRate": settings.ADMIN_REPLAYS_SAMPLE_RATE_ON_ERROR, + "userEmail": g.user.email, } ), 200,