@@ -31,8 +31,11 @@ class SlackActionEndpoint(Endpoint):
31
31
authentication_classes = ()
32
32
permission_classes = ()
33
33
34
- def api_error (self , error ):
35
- logger .info ("slack.action.api-error" , extra = {"response" : error .body })
34
+ def api_error (self , error , action_type , logging_data ):
35
+ logging_data = logging_data .copy ()
36
+ logging_data ["response" ] = error .body
37
+ logging_data ["action_type" ] = action_type
38
+ logger .info ("slack.action.api-error" , extra = logging_data )
36
39
return self .respond (
37
40
{
38
41
"response_type" : "ephemeral" ,
@@ -155,11 +158,15 @@ def post(self, request):
155
158
channel_id = data .get ("channel" , {}).get ("id" )
156
159
user_id = data .get ("user" , {}).get ("id" )
157
160
161
+ logging_data ["channel_id" ] = channel_id
162
+ logging_data ["user_id" ] = user_id
163
+
158
164
integration = slack_request .integration
159
165
logging_data ["integration_id" ] = integration .id
160
166
161
167
# Determine the issue group action is being taken on
162
168
group_id = slack_request .callback_data ["issue" ]
169
+ logging_data ["group_id" ] = group_id
163
170
164
171
# Actions list may be empty when receiving a dialog response
165
172
action_list = data .get ("actions" , [])
@@ -175,6 +182,8 @@ def post(self, request):
175
182
logger .error ("slack.action.invalid-issue" , extra = logging_data )
176
183
return self .respond (status = 403 )
177
184
185
+ logging_data ["organization_id" ] = group .organization .id
186
+
178
187
# Determine the acting user by slack identity
179
188
try :
180
189
idp = IdentityProvider .objects .get (type = "slack" , external_id = slack_request .team_id )
@@ -205,7 +214,7 @@ def post(self, request):
205
214
try :
206
215
self .on_status (request , identity , group , action , data , integration )
207
216
except client .ApiError as e :
208
- return self .api_error (e )
217
+ return self .api_error (e , "status_dialog" , logging_data )
209
218
210
219
group = Group .objects .get (id = group .id )
211
220
attachment = build_group_attachment (group , identity = identity , actions = [action ])
@@ -230,6 +239,7 @@ def post(self, request):
230
239
defer_attachment_update = False
231
240
232
241
# Handle interaction actions
242
+ action_type = None
233
243
try :
234
244
for action in action_list :
235
245
action_type = action ["name" ]
@@ -242,7 +252,7 @@ def post(self, request):
242
252
self .open_resolve_dialog (data , group , integration )
243
253
defer_attachment_update = True
244
254
except client .ApiError as e :
245
- return self .api_error (e )
255
+ return self .api_error (e , action_type , logging_data )
246
256
247
257
if defer_attachment_update :
248
258
return self .respond ()
0 commit comments