From 3be9292d8999e572d7dc7ee27f1c0dc8d4bee768 Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Wed, 23 Oct 2024 11:58:48 +0200 Subject: [PATCH] fix: #29 Package version in client payload (#203) * client version * add client config tests --- lib/src/messages/raygun_client_message.dart | 2 ++ lib/src/messages/raygun_client_message.g.dart | 4 +++- lib/src/services/settings.dart | 3 +++ pubspec.lock | 2 +- pubspec.yaml | 1 + test/raygun4flutter_test.dart | 13 +++++++++++++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/src/messages/raygun_client_message.dart b/lib/src/messages/raygun_client_message.dart index b6ef8a9..54baf58 100644 --- a/lib/src/messages/raygun_client_message.dart +++ b/lib/src/messages/raygun_client_message.dart @@ -1,4 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:raygun4flutter/src/services/settings.dart'; part 'raygun_client_message.g.dart'; @@ -6,6 +7,7 @@ part 'raygun_client_message.g.dart'; class RaygunClientMessage { String? clientUrl = 'https://github.com/MindscapeHQ/raygun4flutter'; String? name = 'Raygun4Flutter'; + String version = Settings.kVersion; RaygunClientMessage(); diff --git a/lib/src/messages/raygun_client_message.g.dart b/lib/src/messages/raygun_client_message.g.dart index 4592af6..0893ba8 100644 --- a/lib/src/messages/raygun_client_message.g.dart +++ b/lib/src/messages/raygun_client_message.g.dart @@ -9,11 +9,13 @@ part of 'raygun_client_message.dart'; RaygunClientMessage _$RaygunClientMessageFromJson(Map json) => RaygunClientMessage() ..clientUrl = json['clientUrl'] as String? - ..name = json['name'] as String?; + ..name = json['name'] as String? + ..version = json['version'] as String; Map _$RaygunClientMessageToJson( RaygunClientMessage instance) => { 'clientUrl': instance.clientUrl, 'name': instance.name, + 'version': instance.version, }; diff --git a/lib/src/services/settings.dart b/lib/src/services/settings.dart index c82fe8a..5348977 100644 --- a/lib/src/services/settings.dart +++ b/lib/src/services/settings.dart @@ -10,6 +10,9 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:uuid/uuid.dart'; class Settings { + /// The current version of the Raygun4Flutter package. + static const kVersion = '3.2.0'; + static const kDefaultCrashReportingEndpoint = 'https://api.raygun.com/entries'; diff --git a/pubspec.lock b/pubspec.lock index 5196c1b..8f16a87 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -838,5 +838,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.5.0-259.0.dev <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index e12fbf6..7abfde1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,6 @@ name: raygun4flutter description: Raygun4flutter package is the official Raygun crash reporting provider for Flutter. +# Also update lib/src/services/settings.dart kVersion version: 3.2.0 homepage: https://raygun.com repository: https://github.com/MindscapeHQ/Raygun4Flutter diff --git a/test/raygun4flutter_test.dart b/test/raygun4flutter_test.dart index 7578e7b..06eb446 100644 --- a/test/raygun4flutter_test.dart +++ b/test/raygun4flutter_test.dart @@ -55,6 +55,19 @@ void main() { expect(capturedBody['details']['userCustomData'], {}); }); + test('should fill client data', () async { + await Raygun.sendException(error: Exception('MESSAGE')); + // Client URL and name never change + expect( + capturedBody['details']['client']['clientUrl'], + 'https://github.com/MindscapeHQ/raygun4flutter', + ); + expect(capturedBody['details']['client']['name'], 'Raygun4Flutter'); + + // Version changes on each release + expect(capturedBody['details']['client']['version'], isNotEmpty); + }); + test('sendException with tags', () async { await Raygun.sendException( error: Exception('MESSAGE'),