mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-25 23:34:56 +08:00
Remove flutter_sentry
We need to use sentry 4.0 in order for the tests to work. This kinda ports it, but also removes flutter_sentry. I'll need to properly port it later.
This commit is contained in:
@ -15,56 +15,55 @@ import 'package:gitjournal/utils/logger.dart';
|
|||||||
|
|
||||||
SentryClient _sentryClient;
|
SentryClient _sentryClient;
|
||||||
Future<SentryClient> _initSentry() async {
|
Future<SentryClient> _initSentry() async {
|
||||||
return SentryClient(
|
return SentryClient(SentryOptions(
|
||||||
dsn: environment['sentry'],
|
dsn: environment['sentry'],
|
||||||
environmentAttributes: await _environmentEvent,
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<SentryClient> getSentryClient() async {
|
Future<SentryClient> getSentryClient() async {
|
||||||
return _sentryClient ??= await _initSentry();
|
return _sentryClient ??= await _initSentry();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Event> get _environmentEvent async {
|
Future<SentryEvent> get _environmentEvent async {
|
||||||
final packageInfo = await PackageInfo.fromPlatform();
|
final packageInfo = await PackageInfo.fromPlatform();
|
||||||
final deviceInfoPlugin = DeviceInfoPlugin();
|
final deviceInfoPlugin = DeviceInfoPlugin();
|
||||||
OperatingSystem os;
|
SentryOperatingSystem os;
|
||||||
Device device;
|
SentryDevice device;
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
final androidInfo = await deviceInfoPlugin.androidInfo;
|
final androidInfo = await deviceInfoPlugin.androidInfo;
|
||||||
os = OperatingSystem(
|
os = SentryOperatingSystem(
|
||||||
name: 'android',
|
name: 'android',
|
||||||
version: androidInfo.version.release,
|
version: androidInfo.version.release,
|
||||||
);
|
);
|
||||||
device = Device(
|
device = SentryDevice(
|
||||||
model: androidInfo.model,
|
model: androidInfo.model,
|
||||||
manufacturer: androidInfo.manufacturer,
|
manufacturer: androidInfo.manufacturer,
|
||||||
modelId: androidInfo.product,
|
modelId: androidInfo.product,
|
||||||
);
|
);
|
||||||
} else if (Platform.isIOS) {
|
} else if (Platform.isIOS) {
|
||||||
final iosInfo = await deviceInfoPlugin.iosInfo;
|
final iosInfo = await deviceInfoPlugin.iosInfo;
|
||||||
os = OperatingSystem(
|
os = SentryOperatingSystem(
|
||||||
name: iosInfo.systemName,
|
name: iosInfo.systemName,
|
||||||
version: iosInfo.systemVersion,
|
version: iosInfo.systemVersion,
|
||||||
);
|
);
|
||||||
device = Device(
|
device = SentryDevice(
|
||||||
model: iosInfo.utsname.machine,
|
model: iosInfo.utsname.machine,
|
||||||
family: iosInfo.model,
|
family: iosInfo.model,
|
||||||
manufacturer: 'Apple',
|
manufacturer: 'Apple',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final environment = Event(
|
final environment = SentryEvent(
|
||||||
release: '${packageInfo.version} (${packageInfo.buildNumber})',
|
release: '${packageInfo.version} (${packageInfo.buildNumber})',
|
||||||
contexts: Contexts(
|
contexts: Contexts(
|
||||||
operatingSystem: os,
|
operatingSystem: os,
|
||||||
device: device,
|
device: device,
|
||||||
app: App(
|
app: SentryApp(
|
||||||
name: packageInfo.appName,
|
name: packageInfo.appName,
|
||||||
version: packageInfo.version,
|
version: packageInfo.version,
|
||||||
build: packageInfo.buildNumber,
|
build: packageInfo.buildNumber,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
userContext: User(
|
user: SentryUser(
|
||||||
id: AppSettings.instance.pseudoId,
|
id: AppSettings.instance.pseudoId,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -116,7 +115,7 @@ Future<void> logExceptionWarning(Object e, StackTrace stackTrace) async {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await captureSentryException(e, stackTrace, level: SeverityLevel.warning);
|
await captureSentryException(e, stackTrace, level: SentryLevel.warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Breadcrumb> breadcrumbs = [];
|
List<Breadcrumb> breadcrumbs = [];
|
||||||
@ -125,25 +124,28 @@ void captureErrorBreadcrumb({
|
|||||||
@required String name,
|
@required String name,
|
||||||
Map<String, String> parameters,
|
Map<String, String> parameters,
|
||||||
}) {
|
}) {
|
||||||
var b = Breadcrumb(name, DateTime.now(), data: parameters);
|
var b = Breadcrumb(
|
||||||
|
message: name,
|
||||||
|
timestamp: DateTime.now(),
|
||||||
|
data: parameters,
|
||||||
|
);
|
||||||
breadcrumbs.add(b);
|
breadcrumbs.add(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> captureSentryException(
|
Future<void> captureSentryException(
|
||||||
Object exception,
|
Object exception,
|
||||||
StackTrace stackTrace, {
|
StackTrace stackTrace, {
|
||||||
SeverityLevel level = SeverityLevel.error,
|
SentryLevel level = SentryLevel.error,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final sentry = await getSentryClient();
|
final sentry = await getSentryClient();
|
||||||
final Event event = Event(
|
final event = (await _environmentEvent).copyWith(
|
||||||
exception: exception,
|
exception: exception,
|
||||||
stackTrace: Trace.from(stackTrace).terse,
|
|
||||||
breadcrumbs: breadcrumbs,
|
breadcrumbs: breadcrumbs,
|
||||||
level: level,
|
level: level,
|
||||||
);
|
);
|
||||||
|
|
||||||
return sentry.capture(event: event);
|
return sentry.captureEvent(event, stackTrace: Trace.from(stackTrace).terse);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Failed to report with Sentry: $e");
|
print("Failed to report with Sentry: $e");
|
||||||
}
|
}
|
||||||
|
23
pubspec.lock
23
pubspec.lock
@ -393,13 +393,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.4"
|
version: "0.0.4"
|
||||||
flutter_sentry:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_sentry
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.4.4"
|
|
||||||
flutter_staggered_grid_view:
|
flutter_staggered_grid_view:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -861,7 +854,14 @@ packages:
|
|||||||
name: sentry
|
name: sentry
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "4.1.0-nullsafety.1"
|
||||||
|
sentry_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: sentry_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.6"
|
||||||
share:
|
share:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1112,13 +1112,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
usage:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: usage
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "3.4.2"
|
|
||||||
uuid:
|
uuid:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -42,7 +42,6 @@ dependencies:
|
|||||||
flutter_email_sender: ^3.0.1
|
flutter_email_sender: ^3.0.1
|
||||||
flutter_emoji: ">= 2.0.0"
|
flutter_emoji: ">= 2.0.0"
|
||||||
flutter_markdown: ^0.6.1
|
flutter_markdown: ^0.6.1
|
||||||
flutter_sentry: ^0.4.4
|
|
||||||
flutter_runtime_env: ^0.0.4
|
flutter_runtime_env: ^0.0.4
|
||||||
flutter_staggered_grid_view: ^0.3.0
|
flutter_staggered_grid_view: ^0.3.0
|
||||||
flutter_svg: ^0.21.0-nullsafety.0
|
flutter_svg: ^0.21.0-nullsafety.0
|
||||||
@ -63,7 +62,8 @@ dependencies:
|
|||||||
provider: ^4.3.2+2
|
provider: ^4.3.2+2
|
||||||
quick_actions: ^0.4.0+10
|
quick_actions: ^0.4.0+10
|
||||||
receive_sharing_intent: ^1.4.0+2
|
receive_sharing_intent: ^1.4.0+2
|
||||||
sentry: ">=3.0.0 <4.0.0"
|
sentry: ^4.0.6
|
||||||
|
sentry_flutter: ^4.0.6
|
||||||
share: ^0.6.3+5
|
share: ^0.6.3+5
|
||||||
shared_preferences: ^2.0.5
|
shared_preferences: ^2.0.5
|
||||||
#ssh_key: ^0.6.0
|
#ssh_key: ^0.6.0
|
||||||
|
Reference in New Issue
Block a user