Skip to content

Commit

Permalink
removed sentry error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Jul 10, 2023
1 parent ee1941d commit 7bf8a1b
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 396 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Changed
- Adjusted subscription styling to be more consistent - contribution from @micahmo
- Removed Sentry error logging

### Fixed
- Fixed issue with styling differences in compact and normal view for community/instance - contribution from @machinaeZER0
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ You can also run your local development environment for Android via the Docker c
### Environment File
This is an example of the `.env` that can be used for Thunder.
```bash
# Sentry Credentials
SENTRY_DSN=""
# Empty Environment File
```

## Conventions
Expand Down
15 changes: 0 additions & 15 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ PODS:
- FlutterMacOS
- permission_handler_apple (9.1.0):
- Flutter
- Sentry/HybridSDK (8.7.3):
- SentryPrivate (= 8.7.3)
- sentry_flutter (0.0.1):
- Flutter
- FlutterMacOS
- Sentry/HybridSDK (= 8.7.3)
- SentryPrivate (8.7.3)
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1):
Expand All @@ -44,7 +37,6 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
Expand All @@ -54,8 +46,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- FMDB
- Sentry
- SentryPrivate

EXTERNAL SOURCES:
device_info_plus:
Expand All @@ -72,8 +62,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
sentry_flutter:
:path: ".symlinks/plugins/sentry_flutter/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
Expand All @@ -94,9 +82,6 @@ SPEC CHECKSUMS:
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
permission_handler_apple: 8f116445eff3c0e7c65ad60f5fef5490aa94b4e4
Sentry: c7a86f43510a7d5678d4de28d78c28ab351d295b
sentry_flutter: f2710a4f537e9a7143b02562b8754ccdc8224751
SentryPrivate: 2eaabf598a46d4b9b8822aef766df2a84caf2e6f
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
Expand Down
4 changes: 1 addition & 3 deletions lib/account/bloc/account_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:bloc/bloc.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:equatable/equatable.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:stream_transform/stream_transform.dart';

import 'package:thunder/account/models/account.dart';
Expand Down Expand Up @@ -59,12 +59,10 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
} catch (e, s) {
exception = e;
attemptCount++;
await Sentry.captureException(e, stackTrace: s);
}
}
emit(state.copyWith(status: AccountStatus.failure, errorMessage: exception.toString()));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
emit(state.copyWith(status: AccountStatus.failure, errorMessage: e.toString()));
}
});
Expand Down
16 changes: 1 addition & 15 deletions lib/community/bloc/community_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:shared_preferences/shared_preferences.dart';
import 'package:stream_transform/stream_transform.dart';

Expand Down Expand Up @@ -95,8 +95,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {

return emit(state.copyWith(status: CommunityStatus.success, communityId: state.communityId, listingType: state.listingType));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(state.copyWith(
status: CommunityStatus.failure,
errorMessage: e.toString(),
Expand Down Expand Up @@ -134,8 +132,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {

return emit(state.copyWith(status: CommunityStatus.success, communityId: state.communityId, listingType: state.listingType));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(state.copyWith(
status: CommunityStatus.failure,
errorMessage: e.toString(),
Expand All @@ -158,8 +154,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {

return emit(state.copyWith(status: CommunityStatus.success, communityId: state.communityId, listingType: state.listingType, communityName: state.communityName));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(state.copyWith(
status: CommunityStatus.failure,
errorMessage: e.toString(),
Expand Down Expand Up @@ -337,13 +331,11 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {
} catch (e, s) {
exception = e;
attemptCount++;
await Sentry.captureException(e, stackTrace: s);
}
}

emit(state.copyWith(status: CommunityStatus.failure, errorMessage: exception.toString(), listingType: state.listingType, communityId: state.communityId, communityName: state.communityName));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
emit(state.copyWith(status: CommunityStatus.failure, errorMessage: e.toString(), listingType: state.listingType, communityId: state.communityId, communityName: state.communityName));
}
}
Expand Down Expand Up @@ -388,8 +380,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {
subscribedType: fullCommunityView.communityView.subscribed,
));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(
state.copyWith(
status: CommunityStatus.failure,
Expand Down Expand Up @@ -450,8 +440,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {
communityName: state.communityName,
));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(
state.copyWith(
status: CommunityStatus.failure,
Expand Down Expand Up @@ -495,8 +483,6 @@ class CommunityBloc extends Bloc<CommunityEvent, CommunityState> {
blockedCommunity: blockedCommunity,
));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);

return emit(
state.copyWith(
status: CommunityStatus.failure,
Expand Down
3 changes: 0 additions & 3 deletions lib/core/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:collection/collection.dart';
import 'package:uuid/uuid.dart';
Expand Down Expand Up @@ -137,11 +136,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
// Restore the original baseUrl
lemmyClient.changeBaseUrl(originalBaseUrl);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: AuthStatus.failure, account: null, isLoggedIn: false, errorMessage: s.toString()));
}

await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: AuthStatus.failure, account: null, isLoggedIn: false, errorMessage: e.toString()));
}
});
Expand Down
3 changes: 1 addition & 2 deletions lib/core/theme/bloc/theme_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/scheduler.dart';
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:shared_preferences/shared_preferences.dart';
import 'package:stream_transform/stream_transform.dart';
import 'package:thunder/core/singletons/preferences.dart';
Expand Down Expand Up @@ -56,7 +56,6 @@ class ThemeBloc extends Bloc<ThemeEvent, ThemeState> {
),
);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: ThemeStatus.failure));
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/core/update/check_github_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:thunder/core/models/version.dart';

Expand Down Expand Up @@ -35,7 +34,6 @@ Future<Version> fetchVersion() async {

return Version(version: currentVersion ?? 'N/A', latestVersion: 'N/A', hasUpdate: false);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return Version(version: 'N/A', latestVersion: 'N/A', hasUpdate: false);
}
}
6 changes: 0 additions & 6 deletions lib/inbox/bloc/inbox_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stream_transform/stream_transform.dart';
import 'package:thunder/account/models/account.dart';
Expand Down Expand Up @@ -158,13 +157,11 @@ class InboxBloc extends Bloc<InboxEvent, InboxState> {
} catch (e, s) {
exception = e;
attemptCount++;
await Sentry.captureException(e, stackTrace: s);
}
}

emit(state.copyWith(status: InboxStatus.failure, errorMessage: exception.toString()));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
emit(state.copyWith(status: InboxStatus.failure, errorMessage: e.toString()));
}
}
Expand All @@ -191,7 +188,6 @@ class InboxBloc extends Bloc<InboxEvent, InboxState> {

emit(state.copyWith(status: InboxStatus.success, replies: replies));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: InboxStatus.failure, errorMessage: e.toString()));
}
}
Expand Down Expand Up @@ -220,7 +216,6 @@ class InboxBloc extends Bloc<InboxEvent, InboxState> {

add(GetInboxEvent(showAll: !state.showUnreadOnly));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: InboxStatus.failure, errorMessage: e.toString()));
}
}
Expand All @@ -246,7 +241,6 @@ class InboxBloc extends Bloc<InboxEvent, InboxState> {
add(GetInboxEvent(showAll: !state.showUnreadOnly));
return emit(state.copyWith(status: InboxStatus.success));
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return emit(state.copyWith(status: InboxStatus.failure, errorMessage: e.toString()));
}
}
Expand Down
35 changes: 2 additions & 33 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:shared_preferences/shared_preferences.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flex_color_scheme/flex_color_scheme.dart';
Expand All @@ -20,18 +20,6 @@ import 'package:thunder/routes.dart';
import 'package:thunder/core/singletons/database.dart';
import 'package:thunder/core/theme/bloc/theme_bloc.dart';

// Ignore specific exceptions to send to Sentry
FutureOr<SentryEvent?> beforeSend(SentryEvent event, {Hint? hint}) async {
if (event.exceptions != null &&
event.exceptions!.isNotEmpty &&
event.exceptions!.first.value != null &&
event.exceptions!.first.value!.contains('The request returned an invalid status code of 400.')) {
return null;
}

return event;
}

void main() async {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
Expand All @@ -45,26 +33,7 @@ void main() async {
// Load up sqlite database
await DB.instance.database;

// Load up SharedPreferences to check if Sentry error tracking is enabled - it is disabled by default
await UserPreferences.instance.refetchPreferences();

SharedPreferences prefs = UserPreferences.instance.sharedPreferences;
bool enableSentryErrorTracking = prefs.getBool('setting_error_tracking_enable_sentry') ?? false;
String? sentryDSN = enableSentryErrorTracking ? dotenv.env['SENTRY_DSN'] : null;

if (sentryDSN != null) {
await SentryFlutter.init(
(options) {
options.dsn = kDebugMode ? '' : sentryDSN;
options.debug = kDebugMode;
options.tracesSampleRate = kDebugMode ? 1.0 : 0.1;
options.beforeSend = beforeSend;
},
appRunner: () => runApp(const ThunderApp()),
);
} else {
runApp(const ThunderApp());
}
runApp(const ThunderApp());
}

class ThunderApp extends StatelessWidget {
Expand Down
Loading

0 comments on commit 7bf8a1b

Please sign in to comment.