@@ -10,9 +10,6 @@ import 'package:gcp/gcp.dart';
10
10
import 'package:sendgrid_mailer/sendgrid_mailer.dart' as sendgrid;
11
11
import 'package:shelf/shelf.dart' ;
12
12
import 'package:shelf_router/shelf_router.dart' ;
13
- import 'package:symbolizer/model.dart' ;
14
- import 'package:symbolizer/parser.dart' ;
15
- import 'package:symbolizer/bot.dart' ;
16
13
17
14
import 'package:github_label_notifier/github_utils.dart' ;
18
15
import 'package:github_label_notifier/redirecting_http.dart' ;
@@ -178,19 +175,13 @@ Sent by dart-github-label-notifier.web.app
178
175
/// The handler will search the body of the open issue for specific keywords
179
176
/// and send emails to all subscribers to a specific label.
180
177
Future <void > onIssueOpened (Map <String , dynamic > event) async {
181
- SymbolizationResult ? symbolizedCrashes;
182
-
183
178
final repositoryName = event['repository' ]['full_name' ];
184
179
print ("opened issue $repositoryName " );
185
180
final subscription = await db.lookupKeywordSubscription (repositoryName);
186
181
if (subscription == null ) return ;
187
- if (subscription.keywords.contains ('crash' ) &&
188
- containsCrash (event['issue' ]['body' ])) {
189
- symbolizedCrashes = await _trySymbolize (event['issue' ]);
190
- }
191
182
192
- final match = (symbolizedCrashes is SymbolizationResultOk &&
193
- symbolizedCrashes.results.isNotEmpty )
183
+ final match = (subscription.keywords. contains ( 'crash' ) &&
184
+ _containsCrash (event[ 'issue' ][ 'body' ]) )
194
185
? 'crash'
195
186
: subscription.match (event['issue' ]['body' ]);
196
187
if (match == null ) {
@@ -210,51 +201,6 @@ Future<void> onIssueOpened(Map<String, dynamic> event) async {
210
201
211
202
final escape = htmlEscape.convert;
212
203
213
- final symbolizedCrashesText = symbolizedCrashes
214
- ? .when (
215
- ok: (results) {
216
- return [
217
- '' ,
218
- ...results.expand ((r) => [
219
- if (r.symbolized != null )
220
- '# engine ${r .engineBuild !.engineHash } ${r .engineBuild !.variant .pretty } crash'
221
- else
222
- '# engine crash' ,
223
- for (var note in r.notes)
224
- if (note.message != null )
225
- '# ${noteMessage [note .kind ]}: ${note .message }'
226
- else
227
- '# ${noteMessage [note .kind ]}' ,
228
- r.symbolized ?? r.crash.frames.toString (),
229
- ]),
230
- ''
231
- ];
232
- },
233
- error: (note) => null )
234
- ? .join ('\n ' ) ??
235
- '' ;
236
-
237
- final symbolizedCrashesHtml = symbolizedCrashes
238
- ? .when (
239
- ok: (results) {
240
- return results.expand ((r) => [
241
- if (r.symbolized != null )
242
- '<p>engine ${r .engineBuild !.engineHash } ${r .engineBuild !.variant .pretty } crash</p>'
243
- else
244
- '<p>engine crash</p>' ,
245
- for (var note in r.notes)
246
- if (note.message != null )
247
- '<em>${noteMessage [note .kind ]}: <pre>${escape (note .message !)}</pre></em>'
248
- else
249
- '<em>${noteMessage [note .kind ]}</em>' ,
250
- '<pre>${escape (r .symbolized ?? r .crash .frames .toString ())}</pre>' ,
251
- ]);
252
- },
253
- error: (note) => null ,
254
- )
255
- ? .join ('' ) ??
256
- '' ;
257
-
258
204
final personalizations = [
259
205
for (final to in subscribers)
260
206
sendgrid.Personalization ([sendgrid.Address (to)])
@@ -270,7 +216,7 @@ $issueUrl
270
216
Reported by $issueReporterUsername
271
217
272
218
Matches keyword: $match
273
- $ symbolizedCrashesText
219
+
274
220
You are getting this mail because you are subscribed to label ${subscription .label }.
275
221
--
276
222
Sent by dart-github-label-notifier.web.app
@@ -279,7 +225,6 @@ Sent by dart-github-label-notifier.web.app
279
225
<p><strong><a href="$issueUrl ">${escape (issueTitle )}</a> (${escape (repositoryName )}#${escape (issueNumber .toString ())})</strong></p>
280
226
<p>Reported by <a href="$issueReporterUrl ">${escape (issueReporterUsername )}</a></p>
281
227
<p>Matches keyword: <b>$match </b></p>
282
- $symbolizedCrashesHtml
283
228
<p>You are getting this mail because you are subscribed to label ${subscription .label }</p>
284
229
<hr>
285
230
<p>Sent by <a href="https://dart-github-label-notifier.web.app/">GitHub Label Notifier</a></p>
@@ -292,18 +237,7 @@ $symbolizedCrashesHtml
292
237
}
293
238
294
239
Future <void > onIssueCommentCreated (Map <String , dynamic > event) async {
295
- final body = event['comment' ]['body' ];
296
-
297
- if (Bot .isCommand (body)) {
298
- final response = await http.post (
299
- Uri .http (symbolizerServer, 'command' ),
300
- body: jsonEncode (event),
301
- );
302
- if (response.statusCode != HttpStatus .ok) {
303
- throw WebHookError (HttpStatus .internalServerError,
304
- 'Failed to process ${event ['comment' ]['html_url' ]}: ${response .body }' );
305
- }
306
- }
240
+ // Do nothing.
307
241
}
308
242
309
243
class WebHookError {
@@ -324,23 +258,6 @@ String getRequiredHeaderValue(Request request, String header) {
324
258
HttpStatus .badRequest, 'Missing $header header value.' ));
325
259
}
326
260
327
- Future <SymbolizationResult > _trySymbolize (Map <String , dynamic > body) async {
328
- try {
329
- final response = await http
330
- .post (
331
- Uri .http (symbolizerServer, 'symbolize' ),
332
- body: jsonEncode (body),
333
- )
334
- .timeout (const Duration (seconds: 20 ));
335
- return SymbolizationResult .fromJson (jsonDecode (response.body));
336
- } catch (e, st) {
337
- return SymbolizationResult .error (
338
- error: SymbolizationNote (
339
- kind: SymbolizationNoteKind .exceptionWhileSymbolizing,
340
- message: '$e \n $st ' ));
341
- }
342
- }
343
-
344
261
Future <http.Response > Function (Uri url,
345
262
{Object ? body,
346
263
Encoding ? encoding,
@@ -351,3 +268,14 @@ Future<http.Response> Function(Uri url,
351
268
return http.post (newUrl, body: body, encoding: encoding, headers: headers);
352
269
};
353
270
}
271
+
272
+ final _androidCrashMarker =
273
+ '*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***' ;
274
+
275
+ final _iosCrashMarker = RegExp (
276
+ r'(Incident Identifier:\s+([A-F0-9]+-?)+)|(Exception Type:\s+EXC_CRASH)' );
277
+
278
+ /// Returns [true] if the given text is likely to contain a crash.
279
+ bool _containsCrash (String text) {
280
+ return text.contains (_androidCrashMarker) || text.contains (_iosCrashMarker);
281
+ }
0 commit comments