-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
chore(sentry-apps): Allow Sentry App tokens to appear on group activity payload #93078
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
base: master
Are you sure you want to change the base?
chore(sentry-apps): Allow Sentry App tokens to appear on group activity payload #93078
Conversation
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #93078 +/- ##
===========================================
+ Coverage 46.13% 87.89% +41.75%
===========================================
Files 10279 10295 +16
Lines 590206 591220 +1014
Branches 22977 22977
===========================================
+ Hits 272316 519647 +247331
+ Misses 317443 71126 -246317
Partials 447 447 |
@@ -22,6 +28,35 @@ class RpcApiApplication(RpcModel): | |||
client_secret: str = Field(repr=False, default="") | |||
|
|||
|
|||
class RpcSentryAppAvatar(RpcModel): | |||
id: int = -1 | |||
ident: str | None = None |
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.
what is ident
? / could we call it uuid?
@@ -87,6 +87,11 @@ def get_sentry_app_by_id(self, *, id: int) -> RpcSentryApp | None: | |||
def get_sentry_app_by_slug(self, *, slug: str) -> RpcSentryApp | None: | |||
pass | |||
|
|||
@rpc_method | |||
@abc.abstractmethod | |||
def get_sentry_apps_by_proxy_users(self, *, proxy_user_ids: list[int]) -> list[RpcSentryApp]: |
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.
I forget but can we declare rpc methods & models and use them in the same PR? I forget if the soaking is needed only when editing existing models/methods?
str(app.proxy_user_id): { | ||
"id": str(app.id), | ||
"name": app.name, | ||
"slug": app.slug, | ||
"avatars": [ | ||
{ | ||
"avatarType": avatar.get_avatar_type_display(), | ||
"avatarUuid": avatar.ident, | ||
"avatarUrl": avatar.absolute_url(), | ||
"color": avatar.color, | ||
"photoType": avatar.get_avatar_photo_type(), | ||
} | ||
for avatar in app.avatars | ||
], | ||
} | ||
for app in sentry_apps_list | ||
if app.proxy_user_id |
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.
Q: should we be using the existing serializer for Sentry apps? Is the concern that the existing serializer is too bulky?
sentry_app_avatar_map = defaultdict(list) | ||
for avatar in sentry_app_avatars: | ||
sentry_app_avatar_map[avatar.sentry_app_id].append(avatar) |
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.
Kinda random thing I learned but we can do .prefetch_related() to get the associated sentry_app_avatars
per sentry_app
e.g
sentry_apps = SentryApp.objects.filter(proxy_user_id__in=proxy_user_ids).prefetch_related('sentryappavatar')
...
sentry_app_avatar_map = defaultdict(list)
for app in sentry_apps:
sentry_app_avatar_map[app.id] = app.sentryappavatar.all()
In the event a token issued from a sentry app is used to create an activity, we attribute it to the proxy user instead of a sentry app.
To get the sentry app to appear (and minimize API/RPC calls) I added a new rpc method that will return the sentry app, and its avatars (everything the FE will need) to properly render the source of the activity.
Thinking about this more, I would rather read
is_sentry_app
off of the user property, so I will modify the RPC method to do that instead of using all user_ids.