From 59b60f4ff8bf20c8960fc63173a41b417a5184f6 Mon Sep 17 00:00:00 2001 From: nhannah Date: Wed, 11 Sep 2024 23:01:07 -0600 Subject: [PATCH 1/9] sturdy upde fixes --- .../lib/src/domain/get_visitor_config.dart | 11 ++-- .../lib/src/domain/override_assignments.dart | 8 +-- .../src/domain/report_assignment_event.dart | 9 +-- .../lib/src/domain/test_track_login.dart | 13 ++-- .../interceptors/retry_interceptor.dart | 63 ++++++++++--------- packages/test_track/pubspec.yaml | 8 ++- 6 files changed, 54 insertions(+), 58 deletions(-) diff --git a/packages/test_track/lib/src/domain/get_visitor_config.dart b/packages/test_track/lib/src/domain/get_visitor_config.dart index 15fb435..8231d92 100644 --- a/packages/test_track/lib/src/domain/get_visitor_config.dart +++ b/packages/test_track/lib/src/domain/get_visitor_config.dart @@ -40,17 +40,14 @@ class GetVisitorConfig { '${appVersionBuild.version}/builds/' '${appVersionBuild.buildTimestamp}/visitors/$visitorId/config', ), - onResponse: (r) { - return r.maybeWhen( - ok: (json) => AppVisitorConfig.fromJson(json), - orElse: () => throw Exception(r.toString()), - ); + onResponse: (r) => switch (r) { + Ok(:final response) => AppVisitorConfig.fromJson(response), + _ => throw Exception(r.toString()), }, ); await _dataStorageProvider.storeVisitor(appVisitorConfig.visitor); - await _dataStorageProvider - .storeSplitRegistry(appVisitorConfig.splitRegistry); + await _dataStorageProvider.storeSplitRegistry(appVisitorConfig.splitRegistry); await _analyticsProvider.identify(visitorId: appVisitorConfig.visitor.id); diff --git a/packages/test_track/lib/src/domain/override_assignments.dart b/packages/test_track/lib/src/domain/override_assignments.dart index 58d0d9c..8175cd1 100644 --- a/packages/test_track/lib/src/domain/override_assignments.dart +++ b/packages/test_track/lib/src/domain/override_assignments.dart @@ -30,11 +30,9 @@ class OverrideAssignments { 'assignments': assignmentOverrides.map((a) => a.toJson()).toList(), }), ), - onResponse: (r) { - return r.maybeWhen( - okNoContent: () => null, - orElse: () => throw Exception('Failed to override assignments: $r'), - ); + onResponse: (r) => switch (r) { + NoContent() => null, + _ => throw Exception('Failed to override assignments: $r'), }, ); diff --git a/packages/test_track/lib/src/domain/report_assignment_event.dart b/packages/test_track/lib/src/domain/report_assignment_event.dart index 0b76daf..b66c6ef 100644 --- a/packages/test_track/lib/src/domain/report_assignment_event.dart +++ b/packages/test_track/lib/src/domain/report_assignment_event.dart @@ -35,12 +35,9 @@ class ReportAssignmentEvent { }, ), ), - onResponse: (r) { - return r.maybeWhen( - okNoContent: () => null, - orElse: () => _logger.error( - 'Unable to report assignment event: $assignmentEvent with error: $r'), - ); + onResponse: (r) => switch (r) { + NoContent() => null, + _ => _logger.error('Unable to report assignment event: $assignmentEvent with error: $r'), }, ); } diff --git a/packages/test_track/lib/src/domain/test_track_login.dart b/packages/test_track/lib/src/domain/test_track_login.dart index 9c556a3..a2915ef 100644 --- a/packages/test_track/lib/src/domain/test_track_login.dart +++ b/packages/test_track/lib/src/domain/test_track_login.dart @@ -54,19 +54,14 @@ class Login { }, ), ), - onResponse: (r) { - return r.maybeWhen( - ok: (json) => AppVisitorConfig.fromJson(json), - orElse: () => throw TestTrackLoginFailureException( - message: r.toString(), - ), - ); + onResponse: (r) => switch (r) { + Ok(:final response) => AppVisitorConfig.fromJson(response), + _ => throw TestTrackLoginFailureException(message: r.toString()), }, ); await _dataStorageProvider.storeVisitor(appVisitorConfig.visitor); - await _dataStorageProvider - .storeSplitRegistry(appVisitorConfig.splitRegistry); + await _dataStorageProvider.storeSplitRegistry(appVisitorConfig.splitRegistry); await _dataStorageProvider.storeLoginState(true); await _analyticsProvider.identify(visitorId: appVisitorConfig.visitor.id); diff --git a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart index c689a17..5273be5 100644 --- a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart +++ b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart @@ -29,16 +29,13 @@ class RetryInterceptor extends Interceptor { DioException err, ErrorInterceptorHandler handler, ) async { - var extra = - RetryOptions.fromRequestOptions(err.requestOptions) ?? _retryOptions; - final isIdempotent = - err.requestOptions.extra[isIdempotentOptionsKey] as bool? ?? false; + var extra = RetryOptions.fromRequestOptions(err.requestOptions) ?? _retryOptions; + final isIdempotent = err.requestOptions.extra[isIdempotentOptionsKey] as bool? ?? false; final originalMethod = err.requestOptions.method; final capitalizedMethod = StringBuffer() ..write(originalMethod.substring(0, 1).toUpperCase()) ..write(originalMethod.substring(1).toLowerCase()); - final requestType = - NetworkRequestType.values.byName(capitalizedMethod.toString()); + final requestType = NetworkRequestType.values.byName(capitalizedMethod.toString()); if (extra.shouldRetry(err, isIdempotent: isIdempotent)) { if (extra.retryInterval.inMilliseconds > 0) { @@ -73,28 +70,38 @@ class RetryInterceptor extends Interceptor { // for both success cases, fabricate them. This should be fine for // most cases, and would require a `sturdy_http` change if we want // to gain access to the raw response. - r.when( - ok: (res) => handler.resolve( - Response( - data: res, - requestOptions: err.requestOptions, - ), - ), - okNoContent: () => handler.resolve( - Response( - statusCode: 204, - requestOptions: err.requestOptions, - ), - ), - genericError: (_, __, error) => throw error ?? errorForRequest(), - unprocessableEntity: (error, _) => throw error, - upgradeRequired: (error) => throw error, - unauthorized: (error) => throw error, - forbidden: (error) => throw error, - notFound: (error) => throw error, - serverError: (error) => throw error, - serviceUnavailable: (error) => throw error, - ); + switch (r) { + case Ok(:final response): + handler.resolve( + Response( + data: response, + requestOptions: err.requestOptions, + ), + ); + case NoContent(): + handler.resolve( + Response( + statusCode: 204, + requestOptions: err.requestOptions, + ), + ); + case GenericError(:final error): + throw error ?? errorForRequest(); + case UnprocessableEntity(:final error): + throw error; + case UpgradeRequired(:final error): + throw error; + case Unauthorized(:final error): + throw error; + case Forbidden(:final error): + throw error; + case NotFound(:final error): + throw error; + case ServerError(:final error): + throw error; + case ServiceUnavailable(:final error): + throw error; + } }, ); } on DioException catch (dioError) { diff --git a/packages/test_track/pubspec.yaml b/packages/test_track/pubspec.yaml index 8c43cc1..03fde00 100644 --- a/packages/test_track/pubspec.yaml +++ b/packages/test_track/pubspec.yaml @@ -15,10 +15,12 @@ dependencies: freezed_annotation: ^2.4.1 json_annotation: ^4.8.1 meta: ^1.14.0 - sturdy_http: ^0.4.0 + sturdy_http: + git: + url: https://github.com/Betterment/sturdy_http.git + ref: bt/response-changes uuid: ^4.4.0 - dev_dependencies: build_runner: ^2.4.9 charlatan: ^0.4.0 @@ -29,5 +31,5 @@ dev_dependencies: lints: ^3.0.0 mocktail: ^1.0.3 test: ^1.25.3 - test_track_test_support: + test_track_test_support: path: ../test_track_test_support From 95bd0b76d06f57a03c1dd34366eba0ce83f19944 Mon Sep 17 00:00:00 2001 From: nhannah Date: Thu, 12 Sep 2024 10:41:32 -0600 Subject: [PATCH 2/9] dep --- packages/test_track_test_support/pubspec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/test_track_test_support/pubspec.yaml b/packages/test_track_test_support/pubspec.yaml index efd271e..e2ff628 100644 --- a/packages/test_track_test_support/pubspec.yaml +++ b/packages/test_track_test_support/pubspec.yaml @@ -11,7 +11,8 @@ dependencies: equatable: ^2.0.5 meta: ^1.14.0 random_string: ^2.3.1 - test_track: ^0.1.0 + test_track: + path: ../test_track dev_dependencies: coverage: ^1.7.2 From b8afa26b45c2a0f12af57f5ee579821ab56de2b0 Mon Sep 17 00:00:00 2001 From: nhannah Date: Thu, 12 Sep 2024 11:21:05 -0600 Subject: [PATCH 3/9] update types --- packages/test_track/lib/src/domain/get_visitor_config.dart | 2 +- packages/test_track/lib/src/domain/override_assignments.dart | 2 +- .../test_track/lib/src/domain/report_assignment_event.dart | 2 +- packages/test_track/lib/src/domain/test_track_login.dart | 2 +- .../lib/src/networking/interceptors/retry_interceptor.dart | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/test_track/lib/src/domain/get_visitor_config.dart b/packages/test_track/lib/src/domain/get_visitor_config.dart index 8231d92..4d33a4d 100644 --- a/packages/test_track/lib/src/domain/get_visitor_config.dart +++ b/packages/test_track/lib/src/domain/get_visitor_config.dart @@ -41,7 +41,7 @@ class GetVisitorConfig { '${appVersionBuild.buildTimestamp}/visitors/$visitorId/config', ), onResponse: (r) => switch (r) { - Ok(:final response) => AppVisitorConfig.fromJson(response), + OkResponse(:final response) => AppVisitorConfig.fromJson(response), _ => throw Exception(r.toString()), }, ); diff --git a/packages/test_track/lib/src/domain/override_assignments.dart b/packages/test_track/lib/src/domain/override_assignments.dart index 8175cd1..2b40c8a 100644 --- a/packages/test_track/lib/src/domain/override_assignments.dart +++ b/packages/test_track/lib/src/domain/override_assignments.dart @@ -31,7 +31,7 @@ class OverrideAssignments { }), ), onResponse: (r) => switch (r) { - NoContent() => null, + OkNoContent() => null, _ => throw Exception('Failed to override assignments: $r'), }, ); diff --git a/packages/test_track/lib/src/domain/report_assignment_event.dart b/packages/test_track/lib/src/domain/report_assignment_event.dart index b66c6ef..1ec96cb 100644 --- a/packages/test_track/lib/src/domain/report_assignment_event.dart +++ b/packages/test_track/lib/src/domain/report_assignment_event.dart @@ -36,7 +36,7 @@ class ReportAssignmentEvent { ), ), onResponse: (r) => switch (r) { - NoContent() => null, + OkNoContent() => null, _ => _logger.error('Unable to report assignment event: $assignmentEvent with error: $r'), }, ); diff --git a/packages/test_track/lib/src/domain/test_track_login.dart b/packages/test_track/lib/src/domain/test_track_login.dart index a2915ef..e8978ac 100644 --- a/packages/test_track/lib/src/domain/test_track_login.dart +++ b/packages/test_track/lib/src/domain/test_track_login.dart @@ -55,7 +55,7 @@ class Login { ), ), onResponse: (r) => switch (r) { - Ok(:final response) => AppVisitorConfig.fromJson(response), + OkResponse(:final response) => AppVisitorConfig.fromJson(response), _ => throw TestTrackLoginFailureException(message: r.toString()), }, ); diff --git a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart index 5273be5..4289922 100644 --- a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart +++ b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart @@ -71,14 +71,14 @@ class RetryInterceptor extends Interceptor { // most cases, and would require a `sturdy_http` change if we want // to gain access to the raw response. switch (r) { - case Ok(:final response): + case OkResponse(:final response): handler.resolve( Response( data: response, requestOptions: err.requestOptions, ), ); - case NoContent(): + case OkNoContent(): handler.resolve( Response( statusCode: 204, From c893f1ac9e3403625e5c13079973284bd4488d09 Mon Sep 17 00:00:00 2001 From: nhannah Date: Tue, 17 Sep 2024 18:46:01 -0600 Subject: [PATCH 4/9] bump version --- packages/test_track/pubspec.yaml | 5 +---- packages/test_track_test_support/pubspec.yaml | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/test_track/pubspec.yaml b/packages/test_track/pubspec.yaml index 03fde00..6ae5eca 100644 --- a/packages/test_track/pubspec.yaml +++ b/packages/test_track/pubspec.yaml @@ -15,10 +15,7 @@ dependencies: freezed_annotation: ^2.4.1 json_annotation: ^4.8.1 meta: ^1.14.0 - sturdy_http: - git: - url: https://github.com/Betterment/sturdy_http.git - ref: bt/response-changes + sturdy_http: ^0.5.0 uuid: ^4.4.0 dev_dependencies: diff --git a/packages/test_track_test_support/pubspec.yaml b/packages/test_track_test_support/pubspec.yaml index e2ff628..efd271e 100644 --- a/packages/test_track_test_support/pubspec.yaml +++ b/packages/test_track_test_support/pubspec.yaml @@ -11,8 +11,7 @@ dependencies: equatable: ^2.0.5 meta: ^1.14.0 random_string: ^2.3.1 - test_track: - path: ../test_track + test_track: ^0.1.0 dev_dependencies: coverage: ^1.7.2 From f2f472dfc8e148e282878c998daa5b2da4fc3547 Mon Sep 17 00:00:00 2001 From: nhannah Date: Tue, 17 Sep 2024 22:32:17 -0600 Subject: [PATCH 5/9] update ci --- .github/workflows/ci.yml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa9771d..f6bb304 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,12 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] + +env: + DART_VERSION: 3.5.0 jobs: build: @@ -14,10 +17,10 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.2 - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 #v1.6.3 with: - sdk: 3.0.7 + sdk: ${{ env.DART_VERSION }} - name: Install dependencies run: dart pub global activate melos 2.3.1 && melos bs - + - name: Run build_runner run: melos exec --depends-on="build_runner" --fail-fast -- "dart run build_runner build --delete-conflicting-outputs" @@ -39,7 +42,7 @@ jobs: - name: Run tests and generate coverage report run: melos exec --fail-fast -- "../../tool/generate_code_coverage.sh" - + - name: Upload test_track code coverage uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed #v4.3.0 with: @@ -53,16 +56,16 @@ jobs: working-directory: packages/test_track_test_support pana: - runs-on: ubuntu-latest + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.2 - - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 #v1.6.3 - with: - sdk: 3.0.7 - - name: Install dependencies - run: | - dart pub global activate melos 2.3.1 && melos bs - dart pub global activate pana - - name: Verify pub score - run: melos exec -- "../../tool/verify_pub_score.sh 110" + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.2 + - uses: dart-lang/setup-dart@65c82982aa686933bf10d50aced7a27b2b63f2a6 #v1.6.3 + with: + sdk: ${{ env.DART_VERSION }} + - name: Install dependencies + run: | + dart pub global activate melos 2.3.1 && melos bs + dart pub global activate pana + - name: Verify pub score + run: melos exec -- "../../tool/verify_pub_score.sh 110" From 485c4ea4b77b48a4124a183494859a97dc4f90fd Mon Sep 17 00:00:00 2001 From: nhannah Date: Tue, 17 Sep 2024 23:22:00 -0600 Subject: [PATCH 6/9] update freezed files --- .../src/models/app_version_build.freezed.dart | 21 +++++++++++++---- .../models/app_visitor_config.freezed.dart | 23 +++++++++++++++---- .../lib/src/models/assignment.freezed.dart | 21 +++++++++++++---- .../src/models/assignment_event.freezed.dart | 21 +++++++++++++---- .../lib/src/models/identifier.freezed.dart | 21 +++++++++++++---- .../lib/src/models/split.freezed.dart | 21 +++++++++++++---- .../src/models/split_registry.freezed.dart | 21 +++++++++++++---- .../lib/src/models/variant.freezed.dart | 21 +++++++++++++---- .../lib/src/models/visitor.freezed.dart | 21 +++++++++++++---- 9 files changed, 155 insertions(+), 36 deletions(-) diff --git a/packages/test_track/lib/src/models/app_version_build.freezed.dart b/packages/test_track/lib/src/models/app_version_build.freezed.dart index 794764e..2e71753 100644 --- a/packages/test_track/lib/src/models/app_version_build.freezed.dart +++ b/packages/test_track/lib/src/models/app_version_build.freezed.dart @@ -24,8 +24,12 @@ mixin _$AppVersionBuild { String get version => throw _privateConstructorUsedError; String get buildTimestamp => throw _privateConstructorUsedError; + /// Serializes this AppVersionBuild to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of AppVersionBuild + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $AppVersionBuildCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$AppVersionBuildCopyWithImpl<$Res, $Val extends AppVersionBuild> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of AppVersionBuild + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -92,6 +98,8 @@ class __$$AppVersionBuildImplCopyWithImpl<$Res> _$AppVersionBuildImpl _value, $Res Function(_$AppVersionBuildImpl) _then) : super(_value, _then); + /// Create a copy of AppVersionBuild + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -151,12 +159,14 @@ class _$AppVersionBuildImpl implements _AppVersionBuild { other.buildTimestamp == buildTimestamp)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, appName, version, buildTimestamp); - @JsonKey(ignore: true) + /// Create a copy of AppVersionBuild + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$AppVersionBuildImplCopyWith<_$AppVersionBuildImpl> get copyWith => @@ -186,8 +196,11 @@ abstract class _AppVersionBuild implements AppVersionBuild { String get version; @override String get buildTimestamp; + + /// Create a copy of AppVersionBuild + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$AppVersionBuildImplCopyWith<_$AppVersionBuildImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/app_visitor_config.freezed.dart b/packages/test_track/lib/src/models/app_visitor_config.freezed.dart index 0c48432..474ff91 100644 --- a/packages/test_track/lib/src/models/app_visitor_config.freezed.dart +++ b/packages/test_track/lib/src/models/app_visitor_config.freezed.dart @@ -23,8 +23,12 @@ mixin _$AppVisitorConfig { List get splits => throw _privateConstructorUsedError; Visitor get visitor => throw _privateConstructorUsedError; + /// Serializes this AppVisitorConfig to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $AppVisitorConfigCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,6 +54,8 @@ class _$AppVisitorConfigCopyWithImpl<$Res, $Val extends AppVisitorConfig> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -68,6 +74,8 @@ class _$AppVisitorConfigCopyWithImpl<$Res, $Val extends AppVisitorConfig> ) as $Val); } + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $VisitorCopyWith<$Res> get visitor { @@ -99,6 +107,8 @@ class __$$AppVisitorConfigImplCopyWithImpl<$Res> $Res Function(_$AppVisitorConfigImpl) _then) : super(_value, _then); + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -153,12 +163,14 @@ class _$AppVisitorConfigImpl implements _AppVisitorConfig { (identical(other.visitor, visitor) || other.visitor == visitor)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_splits), visitor); - @JsonKey(ignore: true) + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$AppVisitorConfigImplCopyWith<_$AppVisitorConfigImpl> get copyWith => @@ -185,8 +197,11 @@ abstract class _AppVisitorConfig implements AppVisitorConfig { List get splits; @override Visitor get visitor; + + /// Create a copy of AppVisitorConfig + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$AppVisitorConfigImplCopyWith<_$AppVisitorConfigImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/assignment.freezed.dart b/packages/test_track/lib/src/models/assignment.freezed.dart index 09a0dbb..b796062 100644 --- a/packages/test_track/lib/src/models/assignment.freezed.dart +++ b/packages/test_track/lib/src/models/assignment.freezed.dart @@ -24,8 +24,12 @@ mixin _$Assignment { String get variant => throw _privateConstructorUsedError; String get context => throw _privateConstructorUsedError; + /// Serializes this Assignment to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Assignment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $AssignmentCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$AssignmentCopyWithImpl<$Res, $Val extends Assignment> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Assignment + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -92,6 +98,8 @@ class __$$AssignmentImplCopyWithImpl<$Res> _$AssignmentImpl _value, $Res Function(_$AssignmentImpl) _then) : super(_value, _then); + /// Create a copy of Assignment + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -149,11 +157,13 @@ class _$AssignmentImpl implements _Assignment { (identical(other.context, context) || other.context == context)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, splitName, variant, context); - @JsonKey(ignore: true) + /// Create a copy of Assignment + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$AssignmentImplCopyWith<_$AssignmentImpl> get copyWith => @@ -182,8 +192,11 @@ abstract class _Assignment implements Assignment { String get variant; @override String get context; + + /// Create a copy of Assignment + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$AssignmentImplCopyWith<_$AssignmentImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/assignment_event.freezed.dart b/packages/test_track/lib/src/models/assignment_event.freezed.dart index 2ed788c..3c2b0c7 100644 --- a/packages/test_track/lib/src/models/assignment_event.freezed.dart +++ b/packages/test_track/lib/src/models/assignment_event.freezed.dart @@ -24,8 +24,12 @@ mixin _$AssignmentEvent { String get splitName => throw _privateConstructorUsedError; String get context => throw _privateConstructorUsedError; + /// Serializes this AssignmentEvent to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of AssignmentEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $AssignmentEventCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$AssignmentEventCopyWithImpl<$Res, $Val extends AssignmentEvent> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of AssignmentEvent + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -92,6 +98,8 @@ class __$$AssignmentEventImplCopyWithImpl<$Res> _$AssignmentEventImpl _value, $Res Function(_$AssignmentEventImpl) _then) : super(_value, _then); + /// Create a copy of AssignmentEvent + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -151,11 +159,13 @@ class _$AssignmentEventImpl implements _AssignmentEvent { (identical(other.context, context) || other.context == context)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, visitorId, splitName, context); - @JsonKey(ignore: true) + /// Create a copy of AssignmentEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$AssignmentEventImplCopyWith<_$AssignmentEventImpl> get copyWith => @@ -185,8 +195,11 @@ abstract class _AssignmentEvent implements AssignmentEvent { String get splitName; @override String get context; + + /// Create a copy of AssignmentEvent + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$AssignmentEventImplCopyWith<_$AssignmentEventImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/identifier.freezed.dart b/packages/test_track/lib/src/models/identifier.freezed.dart index 9defffe..71676b0 100644 --- a/packages/test_track/lib/src/models/identifier.freezed.dart +++ b/packages/test_track/lib/src/models/identifier.freezed.dart @@ -23,8 +23,12 @@ mixin _$Identifier { String get identifierType => throw _privateConstructorUsedError; String get value => throw _privateConstructorUsedError; + /// Serializes this Identifier to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Identifier + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $IdentifierCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ class _$IdentifierCopyWithImpl<$Res, $Val extends Identifier> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Identifier + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -86,6 +92,8 @@ class __$$IdentifierImplCopyWithImpl<$Res> _$IdentifierImpl _value, $Res Function(_$IdentifierImpl) _then) : super(_value, _then); + /// Create a copy of Identifier + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -133,11 +141,13 @@ class _$IdentifierImpl implements _Identifier { (identical(other.value, value) || other.value == value)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, identifierType, value); - @JsonKey(ignore: true) + /// Create a copy of Identifier + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$IdentifierImplCopyWith<_$IdentifierImpl> get copyWith => @@ -163,8 +173,11 @@ abstract class _Identifier implements Identifier { String get identifierType; @override String get value; + + /// Create a copy of Identifier + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$IdentifierImplCopyWith<_$IdentifierImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/split.freezed.dart b/packages/test_track/lib/src/models/split.freezed.dart index 0d9798c..dd4e880 100644 --- a/packages/test_track/lib/src/models/split.freezed.dart +++ b/packages/test_track/lib/src/models/split.freezed.dart @@ -25,8 +25,12 @@ mixin _$Split { @JsonKey(name: 'feature_gate') bool get isFeatureGate => throw _privateConstructorUsedError; + /// Serializes this Split to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Split + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $SplitCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -51,6 +55,8 @@ class _$SplitCopyWithImpl<$Res, $Val extends Split> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Split + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -96,6 +102,8 @@ class __$$SplitImplCopyWithImpl<$Res> _$SplitImpl _value, $Res Function(_$SplitImpl) _then) : super(_value, _then); + /// Create a copy of Split + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -162,12 +170,14 @@ class _$SplitImpl implements _Split { other.isFeatureGate == isFeatureGate)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, const DeepCollectionEquality().hash(_variants), isFeatureGate); - @JsonKey(ignore: true) + /// Create a copy of Split + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SplitImplCopyWith<_$SplitImpl> get copyWith => @@ -197,8 +207,11 @@ abstract class _Split implements Split { @override @JsonKey(name: 'feature_gate') bool get isFeatureGate; + + /// Create a copy of Split + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$SplitImplCopyWith<_$SplitImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/split_registry.freezed.dart b/packages/test_track/lib/src/models/split_registry.freezed.dart index af80d52..fd6b301 100644 --- a/packages/test_track/lib/src/models/split_registry.freezed.dart +++ b/packages/test_track/lib/src/models/split_registry.freezed.dart @@ -22,8 +22,12 @@ SplitRegistry _$SplitRegistryFromJson(Map json) { mixin _$SplitRegistry { List get splits => throw _privateConstructorUsedError; + /// Serializes this SplitRegistry to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of SplitRegistry + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $SplitRegistryCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -47,6 +51,8 @@ class _$SplitRegistryCopyWithImpl<$Res, $Val extends SplitRegistry> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of SplitRegistry + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -80,6 +86,8 @@ class __$$SplitRegistryImplCopyWithImpl<$Res> _$SplitRegistryImpl _value, $Res Function(_$SplitRegistryImpl) _then) : super(_value, _then); + /// Create a copy of SplitRegistry + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -123,12 +131,14 @@ class _$SplitRegistryImpl implements _SplitRegistry { const DeepCollectionEquality().equals(other._splits, _splits)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_splits)); - @JsonKey(ignore: true) + /// Create a copy of SplitRegistry + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SplitRegistryImplCopyWith<_$SplitRegistryImpl> get copyWith => @@ -151,8 +161,11 @@ abstract class _SplitRegistry implements SplitRegistry { @override List get splits; + + /// Create a copy of SplitRegistry + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$SplitRegistryImplCopyWith<_$SplitRegistryImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/variant.freezed.dart b/packages/test_track/lib/src/models/variant.freezed.dart index b04acb3..1b613e9 100644 --- a/packages/test_track/lib/src/models/variant.freezed.dart +++ b/packages/test_track/lib/src/models/variant.freezed.dart @@ -23,8 +23,12 @@ mixin _$Variant { String get name => throw _privateConstructorUsedError; int get weight => throw _privateConstructorUsedError; + /// Serializes this Variant to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Variant + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $VariantCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ class _$VariantCopyWithImpl<$Res, $Val extends Variant> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Variant + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -83,6 +89,8 @@ class __$$VariantImplCopyWithImpl<$Res> _$VariantImpl _value, $Res Function(_$VariantImpl) _then) : super(_value, _then); + /// Create a copy of Variant + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -129,11 +137,13 @@ class _$VariantImpl implements _Variant { (identical(other.weight, weight) || other.weight == weight)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, name, weight); - @JsonKey(ignore: true) + /// Create a copy of Variant + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$VariantImplCopyWith<_$VariantImpl> get copyWith => @@ -157,8 +167,11 @@ abstract class _Variant implements Variant { String get name; @override int get weight; + + /// Create a copy of Variant + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$VariantImplCopyWith<_$VariantImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/test_track/lib/src/models/visitor.freezed.dart b/packages/test_track/lib/src/models/visitor.freezed.dart index bf94de5..43b38ab 100644 --- a/packages/test_track/lib/src/models/visitor.freezed.dart +++ b/packages/test_track/lib/src/models/visitor.freezed.dart @@ -23,8 +23,12 @@ mixin _$Visitor { List get assignments => throw _privateConstructorUsedError; String get id => throw _privateConstructorUsedError; + /// Serializes this Visitor to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Visitor + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $VisitorCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ class _$VisitorCopyWithImpl<$Res, $Val extends Visitor> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Visitor + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -83,6 +89,8 @@ class __$$VisitorImplCopyWithImpl<$Res> _$VisitorImpl _value, $Res Function(_$VisitorImpl) _then) : super(_value, _then); + /// Create a copy of Visitor + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -138,12 +146,14 @@ class _$VisitorImpl implements _Visitor { (identical(other.id, id) || other.id == id)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_assignments), id); - @JsonKey(ignore: true) + /// Create a copy of Visitor + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$VisitorImplCopyWith<_$VisitorImpl> get copyWith => @@ -168,8 +178,11 @@ abstract class _Visitor implements Visitor { List get assignments; @override String get id; + + /// Create a copy of Visitor + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$VisitorImplCopyWith<_$VisitorImpl> get copyWith => throw _privateConstructorUsedError; } From 5e849db7960f9275bc784ad50122fd605b101538 Mon Sep 17 00:00:00 2001 From: nhannah Date: Tue, 17 Sep 2024 23:25:06 -0600 Subject: [PATCH 7/9] update formatting --- .../test_track/lib/src/domain/get_visitor_config.dart | 3 ++- .../lib/src/domain/report_assignment_event.dart | 3 ++- packages/test_track/lib/src/domain/test_track_login.dart | 3 ++- .../src/networking/interceptors/retry_interceptor.dart | 9 ++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/test_track/lib/src/domain/get_visitor_config.dart b/packages/test_track/lib/src/domain/get_visitor_config.dart index 4d33a4d..a877d46 100644 --- a/packages/test_track/lib/src/domain/get_visitor_config.dart +++ b/packages/test_track/lib/src/domain/get_visitor_config.dart @@ -47,7 +47,8 @@ class GetVisitorConfig { ); await _dataStorageProvider.storeVisitor(appVisitorConfig.visitor); - await _dataStorageProvider.storeSplitRegistry(appVisitorConfig.splitRegistry); + await _dataStorageProvider + .storeSplitRegistry(appVisitorConfig.splitRegistry); await _analyticsProvider.identify(visitorId: appVisitorConfig.visitor.id); diff --git a/packages/test_track/lib/src/domain/report_assignment_event.dart b/packages/test_track/lib/src/domain/report_assignment_event.dart index 1ec96cb..6b42999 100644 --- a/packages/test_track/lib/src/domain/report_assignment_event.dart +++ b/packages/test_track/lib/src/domain/report_assignment_event.dart @@ -37,7 +37,8 @@ class ReportAssignmentEvent { ), onResponse: (r) => switch (r) { OkNoContent() => null, - _ => _logger.error('Unable to report assignment event: $assignmentEvent with error: $r'), + _ => _logger.error( + 'Unable to report assignment event: $assignmentEvent with error: $r'), }, ); } diff --git a/packages/test_track/lib/src/domain/test_track_login.dart b/packages/test_track/lib/src/domain/test_track_login.dart index e8978ac..ce7328e 100644 --- a/packages/test_track/lib/src/domain/test_track_login.dart +++ b/packages/test_track/lib/src/domain/test_track_login.dart @@ -61,7 +61,8 @@ class Login { ); await _dataStorageProvider.storeVisitor(appVisitorConfig.visitor); - await _dataStorageProvider.storeSplitRegistry(appVisitorConfig.splitRegistry); + await _dataStorageProvider + .storeSplitRegistry(appVisitorConfig.splitRegistry); await _dataStorageProvider.storeLoginState(true); await _analyticsProvider.identify(visitorId: appVisitorConfig.visitor.id); diff --git a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart index 4289922..f151aeb 100644 --- a/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart +++ b/packages/test_track/lib/src/networking/interceptors/retry_interceptor.dart @@ -29,13 +29,16 @@ class RetryInterceptor extends Interceptor { DioException err, ErrorInterceptorHandler handler, ) async { - var extra = RetryOptions.fromRequestOptions(err.requestOptions) ?? _retryOptions; - final isIdempotent = err.requestOptions.extra[isIdempotentOptionsKey] as bool? ?? false; + var extra = + RetryOptions.fromRequestOptions(err.requestOptions) ?? _retryOptions; + final isIdempotent = + err.requestOptions.extra[isIdempotentOptionsKey] as bool? ?? false; final originalMethod = err.requestOptions.method; final capitalizedMethod = StringBuffer() ..write(originalMethod.substring(0, 1).toUpperCase()) ..write(originalMethod.substring(1).toLowerCase()); - final requestType = NetworkRequestType.values.byName(capitalizedMethod.toString()); + final requestType = + NetworkRequestType.values.byName(capitalizedMethod.toString()); if (extra.shouldRetry(err, isIdempotent: isIdempotent)) { if (extra.retryInterval.inMilliseconds > 0) { From e54ff174b33adc1ad0eef4cee200a3dc3f88b728 Mon Sep 17 00:00:00 2001 From: nhannah Date: Tue, 17 Sep 2024 23:35:48 -0600 Subject: [PATCH 8/9] change test to look for ServerError not 500 --- packages/test_track/test/test_track_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/test_track/test/test_track_test.dart b/packages/test_track/test/test_track_test.dart index 0bea022..a7166e9 100644 --- a/packages/test_track/test/test_track_test.dart +++ b/packages/test_track/test/test_track_test.dart @@ -94,7 +94,7 @@ void main() { expect( logger.infoLogs.single.error.toString(), - contains('status code of 500'), + contains('ServerError'), ); }); @@ -297,7 +297,7 @@ void main() { expect( logger.infoLogs.single.error.toString(), - contains('status code of 500'), + contains('ServerError'), ); }); }); From 9013fb5be8c327244701f9dfecbbcc455ec007ea Mon Sep 17 00:00:00 2001 From: Brandon Trautmann Date: Wed, 18 Sep 2024 09:23:08 -0400 Subject: [PATCH 9/9] enforce perfect pana score --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6bb304..533f241 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,4 +68,4 @@ jobs: dart pub global activate melos 2.3.1 && melos bs dart pub global activate pana - name: Verify pub score - run: melos exec -- "../../tool/verify_pub_score.sh 110" + run: melos exec -- "../../tool/verify_pub_score.sh"