Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
errors now get sent to GlitchTip
Browse files Browse the repository at this point in the history
  • Loading branch information
harleyjones committed May 4, 2024
1 parent b5d3bee commit e5f3f5c
Show file tree
Hide file tree
Showing 65 changed files with 489 additions and 394 deletions.
15 changes: 15 additions & 0 deletions lib/catcher/errors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'dart:developer';

import 'package:quacker/catcher/exceptions.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

class Catcher {
static void reportSyntheticException(SyntheticException error) {
Sentry.captureException(error);
}

static void reportException(Object? e, [StackTrace? stackTrace]) {
log('Error', error: e, stackTrace: stackTrace);
Sentry.captureException(e, stackTrace: stackTrace);
}
}
25 changes: 25 additions & 0 deletions lib/catcher/exceptions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:http/http.dart';

class HttpException {
final Response response;

HttpException(this.response);

get statusCode => response.statusCode;
get reasonPhrase => response.reasonPhrase;
get body => response.body;
get uri => response.request?.url.toString();

@override
String toString() {
return 'HttpException{statusCode: $statusCode, reasonPhrase: $reasonPhrase, uri: $uri, body: $body';
}
}

class ManuallyReportedException {
final Object? exception;

ManuallyReportedException(this.exception);
}

class SyntheticException {}
18 changes: 10 additions & 8 deletions lib/client/client.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:dart_twitter_api/src/utils/date_utils.dart';
import 'package:dart_twitter_api/twitter_api.dart';
import 'package:ffcache/ffcache.dart';
import 'package:quacker/catcher/errors.dart';
import 'package:quacker/catcher/exceptions.dart';
import 'package:quacker/client/client_regular_account.dart';
import 'package:quacker/client/client_unauthenticated.dart';
import 'package:quacker/generated/l10n.dart';
Expand All @@ -30,7 +31,7 @@ class _QuackerTwitterClient extends TwitterClient {
if (response?.statusCode != null && response!.statusCode >= 200 && response.statusCode < 300) {
return response;
} else {
return Future.error(HttpException(response?.body ?? response?.statusCode.toString() ?? ""));
return Future.error(HttpException(response!));
}
});
}
Expand All @@ -48,7 +49,7 @@ class _QuackerTwitterClient extends TwitterClient {
}
}

class UnknownProfileResultType implements Exception {
class UnknownProfileResultType with SyntheticException implements Exception {
final String type;
final String message;
final String uri;
Expand All @@ -61,7 +62,7 @@ class UnknownProfileResultType implements Exception {
}
}

class UnknownProfileUnavailableReason implements Exception {
class UnknownProfileUnavailableReason with SyntheticException implements Exception {
final String reason;
final String uri;

Expand Down Expand Up @@ -205,13 +206,14 @@ class Twitter {
if (code == 'Suspended') {
throw TwitterError(code: 63, message: result['reason'], uri: uri.toString());
} else {
Catcher.reportSyntheticException(UnknownProfileUnavailableReason(code, uri.toString()));
throw TwitterError(code: -1, message: result['reason'], uri: uri.toString());
}
case 'User':
// This means everything's fine
break;
default:
// an error happened
Catcher.reportSyntheticException(UnknownProfileResultType(resultType, result['reason'], uri.toString()));
break;
}
}
Expand Down Expand Up @@ -272,9 +274,9 @@ class Twitter {
if (itemType == 'TimelineTweet') {
if (item['item']['itemContent']['tweet_results']?['result'] != null) {
tweets.add(TweetWithCard.fromGraphqlJson(item['item']['itemContent']['tweet_results']['result']));
} else {
tweets.add(TweetWithCard.tombstone({}));
}
} else {
Catcher.reportSyntheticException(UnknownTimelineItemType(itemType, entryId));
}
}

Expand Down Expand Up @@ -1205,7 +1207,7 @@ class SearchHasNoTimelineException {
}
}

class UnknownTimelineItemType implements Exception {
class UnknownTimelineItemType with SyntheticException implements Exception {
final String type;
final String entryId;

Expand Down
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const optionWizardCompleted = 'option.wizard_completed';

const optionDisableScreenshots = 'disable_screenshots';

const optionErrorsEnabled = 'errors._enabled';
const optionGlitchTipErrorsEnabled = 'errors.glitchtip_enabled';

const optionHelloLastBuild = 'hello.last_build';

Expand Down
9 changes: 5 additions & 4 deletions lib/generated/intl/messages_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class MessageLookup extends MessageLookupByLibrary {
"download_path": MessageLookupByLibrary.simpleMessage("مسار التنزيل"),
"downloading_media":
MessageLookupByLibrary.simpleMessage("تحميل الوسائط..."),
"enable_": MessageLookupByLibrary.simpleMessage("تفعيل الحارس؟"),
"enable_glitchtip":
MessageLookupByLibrary.simpleMessage("تفعيل الحارس؟"),
"ended_timeago_format_endsAt_allowFromNow_true": m3,
"ends_timeago_format_endsAt_allowFromNow_true": m4,
"enter_your_twitter_username":
Expand Down Expand Up @@ -445,7 +446,7 @@ class MessageLookup extends MessageLookupByLibrary {
"when_a_new_app_update_is_available":
MessageLookupByLibrary.simpleMessage(
"عندما يكون هناك تحديث جديد للتطبيق"),
"whether_errors_should_be_reported_to_":
"whether_errors_should_be_reported_to_glitchtip":
MessageLookupByLibrary.simpleMessage(
"ما إذا يجب على الأخطاء البرمجية أن يُبلّغ عنها إلى الحارس"),
"whether_to_hide_tweets_marked_as_sensitive":
Expand All @@ -454,7 +455,7 @@ class MessageLookup extends MessageLookupByLibrary {
"which_tab_is_shown_when_the_app_opens":
MessageLookupByLibrary.simpleMessage(
"أي تبويب يظهر عندما يفتح التطبيق"),
"would_you_like_to_enable_automatic_error_reporting":
"would_you_like_to_enable_glitchtipautomatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"هل تُحب أن تفعل مُبَلغ الأخطاء الآلي؟"),
"yes": MessageLookupByLibrary.simpleMessage("نعم"),
Expand All @@ -467,7 +468,7 @@ class MessageLookup extends MessageLookupByLibrary {
"your_profile_must_be_public_otherwise_the_import_will_not_work":
MessageLookupByLibrary.simpleMessage(
"يجب أن يكون ملف التعريف الخاص بك عاما، وإلا لن يعمل الاستيراد"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"تقريرك سيُبعث إلى مشروع حراسة فريتر، ويمكن العثور على تفاصيل الخصوصية في:")
};
Expand Down
11 changes: 6 additions & 5 deletions lib/generated/intl/messages_be.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Шлях для спампоўкі"),
"downloading_media":
MessageLookupByLibrary.simpleMessage("Загрузка медыя..."),
"enable_": MessageLookupByLibrary.simpleMessage("Актываваць ?"),
"enable_glitchtip":
MessageLookupByLibrary.simpleMessage("Актываваць GlitchTip?"),
"ended_timeago_format_endsAt_allowFromNow_true": m3,
"ends_timeago_format_endsAt_allowFromNow_true": m4,
"enter_your_twitter_username": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -430,15 +431,15 @@ class MessageLookup extends MessageLookupByLibrary {
"when_a_new_app_update_is_available":
MessageLookupByLibrary.simpleMessage(
"Калі новае абнаўленне даступна"),
"whether_errors_should_be_reported_to_":
"whether_errors_should_be_reported_to_glitchtip":
MessageLookupByLibrary.simpleMessage("Паведамляць пра памылкі ў "),
"whether_to_hide_tweets_marked_as_sensitive":
MessageLookupByLibrary.simpleMessage(
"Ці варта хаваць твіты, пазначаныя як чуллівыя"),
"which_tab_is_shown_when_the_app_opens":
MessageLookupByLibrary.simpleMessage(
"Якая ўкладка адлюстроўваецца пры адкрыцці дадатку"),
"would_you_like_to_enable_automatic_error_reporting":
"would_you_like_to_enable_glitchtipautomatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"Вы хочаце ўключыць аўтаматычнае інфармаванне аб памылках?"),
"yes": MessageLookupByLibrary.simpleMessage("Так"),
Expand All @@ -452,8 +453,8 @@ class MessageLookup extends MessageLookupByLibrary {
"your_profile_must_be_public_otherwise_the_import_will_not_work":
MessageLookupByLibrary.simpleMessage(
"Ваш профіль павінен быць адкрытым, інакш імпарт ня будзе працаваць"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"Ваша справаздача будзе даслана ў Quacker, а інфармацыю пра канфідэнцыйнасць можна знайсці тут:")
"Ваша справаздача будзе даслана ў GlitchTip Quacker, а інфармацыю пра канфідэнцыйнасць можна знайсці тут:")
};
}
4 changes: 2 additions & 2 deletions lib/generated/intl/messages_be_Latn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Niemahčyma zahruzić tvity dla stužki"),
"unsubscribe": MessageLookupByLibrary.simpleMessage("Adpisacca"),
"would_you_like_to_enable_automatic_error_reporting":
"would_you_like_to_enable_glitchtipautomatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"Ci žadajecie vy ŭklučyć aŭtamatyčnaje infarmavańnie ab pamyłkach?"),
"you_have_not_saved_any_tweets_yet":
MessageLookupByLibrary.simpleMessage(
"Vy jašče nie zachavali nivodnaha tvitu!"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"Vaša spravazdača budzie dasłana ŭ Quacker, a infarmacyju pra kanfidencyjnaść možna znajści tut:")
};
Expand Down
12 changes: 5 additions & 7 deletions lib/generated/intl/messages_ca.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Ruta de descàrrega"),
"downloading_media":
MessageLookupByLibrary.simpleMessage("Descarregant suports..."),
"enable_": MessageLookupByLibrary.simpleMessage("Habilitar ?"),
"enable_glitchtip":
MessageLookupByLibrary.simpleMessage("Habilitar GlitchTip?"),
"ended_timeago_format_endsAt_allowFromNow_true": m3,
"ends_timeago_format_endsAt_allowFromNow_true": m4,
"enter_your_twitter_username": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -429,7 +430,7 @@ class MessageLookup extends MessageLookupByLibrary {
"when_a_new_app_update_is_available":
MessageLookupByLibrary.simpleMessage(
"Quan hi ha disponible una nova actualització d\'una aplicació"),
"whether_errors_should_be_reported_to_":
"whether_errors_should_be_reported_to_glitchtip":
MessageLookupByLibrary.simpleMessage(
"Si s\'han d\'informar els errors a "),
"whether_to_hide_tweets_marked_as_sensitive":
Expand All @@ -438,9 +439,6 @@ class MessageLookup extends MessageLookupByLibrary {
"which_tab_is_shown_when_the_app_opens":
MessageLookupByLibrary.simpleMessage(
"Quina pestanya es mostra quan s\'obre l\'aplicació"),
"would_you_like_to_enable_automatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"Voleu habilitar l\'informe automàtic d\'errors?"),
"yes": MessageLookupByLibrary.simpleMessage("Sí"),
"yes_please": MessageLookupByLibrary.simpleMessage("Sí, si us plau"),
"you_have_not_saved_any_tweets_yet":
Expand All @@ -452,8 +450,8 @@ class MessageLookup extends MessageLookupByLibrary {
"your_profile_must_be_public_otherwise_the_import_will_not_work":
MessageLookupByLibrary.simpleMessage(
"El teu perfil ha de ser públic, en cas contrari la importació no funcionarà"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"L\'informe s\'enviarà al projecte de Quacker, els detalls de privadesa es poden trobar a:")
"L\'informe s\'enviarà al projecte GlitchTip de Quacker, els detalls de privadesa es poden trobar a:")
};
}
11 changes: 6 additions & 5 deletions lib/generated/intl/messages_cs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Cesta pro stažené"),
"downloading_media":
MessageLookupByLibrary.simpleMessage("Stahování médií..."),
"enable_": MessageLookupByLibrary.simpleMessage("Povolit ?"),
"enable_glitchtip":
MessageLookupByLibrary.simpleMessage("Povolit GlitchTip?"),
"ended_timeago_format_endsAt_allowFromNow_true": m3,
"ends_timeago_format_endsAt_allowFromNow_true": m4,
"enter_your_twitter_username": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -452,7 +453,7 @@ class MessageLookup extends MessageLookupByLibrary {
"when_a_new_app_update_is_available":
MessageLookupByLibrary.simpleMessage(
"Když je dostupná aktualizace aplikace"),
"whether_errors_should_be_reported_to_":
"whether_errors_should_be_reported_to_glitchtip":
MessageLookupByLibrary.simpleMessage(
"Nastavit, zda mají být chyby nahlašovány do "),
"whether_to_hide_tweets_marked_as_sensitive":
Expand All @@ -461,7 +462,7 @@ class MessageLookup extends MessageLookupByLibrary {
"which_tab_is_shown_when_the_app_opens":
MessageLookupByLibrary.simpleMessage(
"Karta, která bude zobrazena při otevření aplikace"),
"would_you_like_to_enable_automatic_error_reporting":
"would_you_like_to_enable_glitchtipautomatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"Chcete povolit automatické nahlašování?"),
"yes": MessageLookupByLibrary.simpleMessage("Ano"),
Expand All @@ -475,8 +476,8 @@ class MessageLookup extends MessageLookupByLibrary {
"your_profile_must_be_public_otherwise_the_import_will_not_work":
MessageLookupByLibrary.simpleMessage(
"Váš profil musí být veřejný, jinak nebude import fungovat"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"Vaše nahlášení bylo odesláno do projektu Quackeru. Podrobnosti o soukromí lze nalézt na:")
"Vaše nahlášení bylo odesláno do GlitchTip projektu Quackeru. Podrobnosti o soukromí lze nalézt na:")
};
}
11 changes: 6 additions & 5 deletions lib/generated/intl/messages_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class MessageLookup extends MessageLookupByLibrary {
"download_path": MessageLookupByLibrary.simpleMessage("Download-Pfad"),
"downloading_media": MessageLookupByLibrary.simpleMessage(
"Medien werden heruntergeladen..."),
"enable_": MessageLookupByLibrary.simpleMessage(" aktivieren?"),
"enable_glitchtip":
MessageLookupByLibrary.simpleMessage("GlitchTip aktivieren?"),
"ended_timeago_format_endsAt_allowFromNow_true": m3,
"ends_timeago_format_endsAt_allowFromNow_true": m4,
"enter_your_twitter_username": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -455,7 +456,7 @@ class MessageLookup extends MessageLookupByLibrary {
"when_a_new_app_update_is_available":
MessageLookupByLibrary.simpleMessage(
"Sobald ein neues Update der App verfügbar ist"),
"whether_errors_should_be_reported_to_":
"whether_errors_should_be_reported_to_glitchtip":
MessageLookupByLibrary.simpleMessage(
"Ob Fehlermeldungen an gesendet werden sollen"),
"whether_to_hide_tweets_marked_as_sensitive":
Expand All @@ -464,7 +465,7 @@ class MessageLookup extends MessageLookupByLibrary {
"which_tab_is_shown_when_the_app_opens":
MessageLookupByLibrary.simpleMessage(
"Welcher Tab beim Öffnen der App angezeigt wird"),
"would_you_like_to_enable_automatic_error_reporting":
"would_you_like_to_enable_glitchtipautomatic_error_reporting":
MessageLookupByLibrary.simpleMessage(
"Möchtest du die automatische Fehlermeldungen aktivieren?"),
"yes": MessageLookupByLibrary.simpleMessage("Ja"),
Expand All @@ -478,8 +479,8 @@ class MessageLookup extends MessageLookupByLibrary {
"your_profile_must_be_public_otherwise_the_import_will_not_work":
MessageLookupByLibrary.simpleMessage(
"Ein öffentliches Profil ist erforderlich, sonst funktioniert der Import nicht"),
"your_report_will_be_sent_to_fritter__project":
"your_report_will_be_sent_to_quacker_glitchtip_project":
MessageLookupByLibrary.simpleMessage(
"Deine Meldung wird an Quackers -Projektseite gesendet. Einzelheiten zum Datenschutz findest du unter:")
"Deine Meldung wird an Quackers GlitchTip-Projektseite gesendet. Einzelheiten zum Datenschutz findest du unter:")
};
}
Loading

0 comments on commit e5f3f5c

Please sign in to comment.