71
71
retry_decorator = retry (
72
72
on = (RequestException , ApiHostError , ApiTimeoutError ),
73
73
ignore = (ClientError ,),
74
- ignore_and_capture = (SentryAppSentryError , AssertionError ),
74
+ ignore_and_capture = (SentryAppSentryError , AssertionError , ValueError ),
75
75
)
76
76
77
77
# We call some models by a different name, publicly, than their class name.
@@ -227,15 +227,10 @@ def _process_resource_change(
227
227
# Looks up the human name for the model. Defaults to the model name.
228
228
name = RESOURCE_RENAMES .get (model .__name__ , model .__name__ .lower ())
229
229
230
- try :
231
- event = SentryAppEventType (f"{ name } .{ action } " )
232
- except ValueError as e :
233
- raise SentryAppSentryError (
234
- message = f"{ SentryAppWebhookFailureReason .INVALID_EVENT } " ,
235
- ) from e
236
-
230
+ event = SentryAppEventType (f"{ name } .{ action } " )
237
231
with SentryAppInteractionEvent (
238
- operation_type = SentryAppInteractionType .PREPARE_WEBHOOK , event_type = event
232
+ operation_type = SentryAppInteractionType .PREPARE_WEBHOOK ,
233
+ event_type = event ,
239
234
).capture ():
240
235
project_id : int | None = kwargs .get ("project_id" , None )
241
236
group_id : int | None = kwargs .get ("group_id" , None )
@@ -386,11 +381,7 @@ def clear_region_cache(sentry_app_id: int, region_name: str) -> None:
386
381
def workflow_notification (
387
382
installation_id : int , issue_id : int , type : str , user_id : int | None , * args : Any , ** kwargs : Any
388
383
) -> None :
389
- try :
390
- event = SentryAppEventType (f"issue.{ type } " )
391
- except ValueError as e :
392
- raise SentryAppSentryError (message = SentryAppWebhookFailureReason .INVALID_EVENT ) from e
393
-
384
+ event = SentryAppEventType (f"issue.{ type } " )
394
385
with SentryAppInteractionEvent (
395
386
operation_type = SentryAppInteractionType .PREPARE_WEBHOOK ,
396
387
event_type = event ,
@@ -417,22 +408,28 @@ def workflow_notification(
417
408
def build_comment_webhook (
418
409
installation_id : int , issue_id : int , type : str , user_id : int , * args : Any , ** kwargs : Any
419
410
) -> None :
420
- webhook_data = get_webhook_data (installation_id , issue_id , user_id )
421
- install , _ , user = webhook_data
422
- data = kwargs .get ("data" , {})
423
- project_slug = data .get ("project_slug" )
424
- comment_id = data .get ("comment_id" )
425
- payload = {
426
- "comment_id" : data .get ("comment_id" ),
427
- "issue_id" : issue_id ,
428
- "project_slug" : data .get ("project_slug" ),
429
- "timestamp" : data .get ("timestamp" ),
430
- "comment" : data .get ("comment" ),
431
- }
432
- send_webhooks (installation = install , event = type , data = payload , actor = user )
433
- # `type` is comment.created, comment.updated, or comment.deleted
411
+ event = SentryAppEventType (type )
412
+ with SentryAppInteractionEvent (
413
+ operation_type = SentryAppInteractionType .PREPARE_WEBHOOK ,
414
+ event_type = event ,
415
+ ).capture ():
416
+ webhook_data = get_webhook_data (installation_id , issue_id , user_id )
417
+ install , _ , user = webhook_data
418
+ data = kwargs .get ("data" , {})
419
+ project_slug = data .get ("project_slug" )
420
+ comment_id = data .get ("comment_id" )
421
+ payload = {
422
+ "comment_id" : data .get ("comment_id" ),
423
+ "issue_id" : issue_id ,
424
+ "project_slug" : data .get ("project_slug" ),
425
+ "timestamp" : data .get ("timestamp" ),
426
+ "comment" : data .get ("comment" ),
427
+ }
428
+
429
+ send_webhooks (installation = install , event = event , data = payload , actor = user )
430
+ # `event` is comment.created, comment.updated, or comment.deleted
434
431
analytics .record (
435
- type ,
432
+ event ,
436
433
user_id = user_id ,
437
434
group_id = issue_id ,
438
435
project_slug = project_slug ,
@@ -526,15 +523,9 @@ def notify_sentry_app(event: GroupEvent, futures: Sequence[RuleFuture]):
526
523
527
524
528
525
def send_webhooks (installation : RpcSentryAppInstallation , event : str , ** kwargs : Any ) -> None :
529
- try :
530
- event = SentryAppEventType (event )
531
- except ValueError as e :
532
- raise SentryAppSentryError (
533
- message = f"{ SentryAppWebhookFailureReason .INVALID_EVENT } " ,
534
- ) from e
535
-
536
526
with SentryAppInteractionEvent (
537
- operation_type = SentryAppInteractionType .SEND_WEBHOOK , event_type = event
527
+ operation_type = SentryAppInteractionType .SEND_WEBHOOK ,
528
+ event_type = SentryAppEventType (event ),
538
529
).capture ():
539
530
servicehook : ServiceHook
540
531
try :
0 commit comments