Skip to content

Commit

Permalink
Merge pull request #8 from Flagsmith/feat/transient-identities-and-tr…
Browse files Browse the repository at this point in the history
…aits

feat!: Support transient identities and traits
  • Loading branch information
khvn26 authored Oct 15, 2024
2 parents d206633 + c863b2e commit fa3e939
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 123 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/dry_run_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Analyze and Test
on: [push]

env:
FLUTTER_VERSION: 3.x

jobs:
analyze:
runs-on: ubuntu-latest
name: Dart Analyze
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.x'
channel: 'any'
flutter-version: ${{ env.FLUTTER_VERSION }}
- run: flutter pub get
- run: flutter analyze

tests:
runs-on: ubuntu-latest
name: Flutter Test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.x'
channel: 'any'

flutter-version: ${{ env.FLUTTER_VERSION }}
- run: flutter pub get
- run: flutter pub test

Expand All @@ -32,7 +32,7 @@ jobs:
name: Dart package score

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: axel-op/dart-package-analyzer@v3
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -42,10 +42,8 @@ jobs:
name: Dart Publish Package Test
needs: tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '2.x'
channel: 'any'

flutter-version: ${{ env.FLUTTER_VERSION }}
- run: flutter pub publish --dry-run
8 changes: 4 additions & 4 deletions .github/workflows/publish_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
name: Dart Analyze

steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
- run: flutter pub get
- run: flutter analyze
score:
runs-on: ubuntu-latest
name: Dart package score

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: axel-op/dart-package-analyzer@v3
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -31,7 +31,7 @@ jobs:
name: Dart Publish Package
needs: analyze
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup credentials
run: |
mkdir -p ~/.pub-cache
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.0.0
* Drop Flutter 2 support
* feat: Support transient identities and traits

## 3.0.0
* trait/value: Add support for int,float, bool and string

Expand Down
2 changes: 0 additions & 2 deletions lib/flagsmith_flutter_core.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library flagsmith_flutter_core;

export 'src/extensions/converters.dart';
export 'src/model/index.dart';
export 'src/storage/in_memory_storage.dart';
Expand Down
22 changes: 10 additions & 12 deletions lib/src/model/feature.g.dart

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

20 changes: 9 additions & 11 deletions lib/src/model/flag.g.dart

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

19 changes: 9 additions & 10 deletions lib/src/model/flags_and_traits.g.dart

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

8 changes: 6 additions & 2 deletions lib/src/model/identity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ part 'identity.g.dart';
/// Personalized user
@JsonSerializable()
class Identity {
@JsonKey(includeIfNull: false)
final bool? transient;
final String identifier;

const Identity({
this.transient,
required this.identifier,
});

Expand All @@ -16,6 +20,6 @@ class Identity {

Map<String, dynamic> toJson() => _$IdentityToJson(this);
String asString() => jsonEncode(toJson());
Identity copyWith({String? identifier}) =>
Identity(identifier: identifier ?? this.identifier);
Identity copyWith({String? identifier, bool? transient}) =>
Identity(identifier: identifier ?? this.identifier, transient: transient ?? this.transient);
}
25 changes: 17 additions & 8 deletions lib/src/model/identity.g.dart

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

2 changes: 2 additions & 0 deletions lib/src/model/index.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library;

export 'feature.dart';
export 'identity.dart';
export 'flag.dart';
Expand Down
3 changes: 3 additions & 0 deletions lib/src/model/trait.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ part 'trait.g.dart';
@JsonSerializable()
class Trait {
final int? id;
@JsonKey(includeIfNull: false)
final bool? transient;
@JsonKey(name: 'trait_key')
final String key;
@JsonKey(name: 'trait_value', fromJson: _fromJson, toJson: _toJson)
final dynamic value;

Trait({
this.id,
this.transient,
required this.key,
required this.value,
});
Expand Down
45 changes: 27 additions & 18 deletions lib/src/model/trait.g.dart

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

4 changes: 2 additions & 2 deletions lib/src/storage_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class StorageProvider with SecureStorage {

Future<bool> saveAll(List<Flag> items) async {
for (var item in items) {
final _current = await read(item.key);
if (_current != null) {
final current = await read(item.key);
if (current != null) {
await update(item.key, item);
} else {
await create(item.key, item);
Expand Down
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ description: >-
Core Package of Flutter Client SDK for https://www.flagsmith.com/, Flagsmith is 100% Open
Source. Host yourself or let us take care of the hosting.
version: 3.0.0
version: 4.0.0
homepage: https://github.com/Flagsmith/flagsmith-flutter-core
repository: https://github.com/Flagsmith/flagsmith-flutter-core
issue_tracker: https://github.com/Flagsmith/flagsmith-flutter-core/issues

environment:
sdk: ">=2.13.0 <3.0.0"
sdk: ^3.0.0

dependencies:
crypto: ^3.0.1
encrypt: ^5.0.1
rxdart: ^0.27.5
rxdart: ^0.28.0
json_annotation: ^4.0.1
collection: ^1.15.0
dev_dependencies:
flutter_lints: ^1.0.0
test: ">=1.16.0 <=1.17.12"
http_mock_adapter: ^0.3.2
flutter_lints: ^5.0.0
test: ^1.25.8
http_mock_adapter: ^0.6.1
mockito: ^5.0.15
json_serializable: ^4.1.3
json_serializable: ^6.8.0
build_runner: ^2.1.2
Loading

0 comments on commit fa3e939

Please sign in to comment.