Skip to content

Commit

Permalink
fix: #29 Package version in client payload (#203)
Browse files Browse the repository at this point in the history
* client version

* add client config tests
  • Loading branch information
miquelbeltran authored Oct 23, 2024
1 parent ae19d1b commit 3be9292
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/src/messages/raygun_client_message.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:raygun4flutter/src/services/settings.dart';

part 'raygun_client_message.g.dart';

@JsonSerializable()
class RaygunClientMessage {
String? clientUrl = 'https://github.com/MindscapeHQ/raygun4flutter';
String? name = 'Raygun4Flutter';
String version = Settings.kVersion;

RaygunClientMessage();

Expand Down
4 changes: 3 additions & 1 deletion lib/src/messages/raygun_client_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/src/services/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/raygun4flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 3be9292

Please sign in to comment.