-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7099e5d
Showing
15 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
|
||
# Avoid committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"yaml.schemaStore.enable": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
- Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Developed with 💚 by [netglade][netglade_link] | ||
|
||
[![pub package][trackable_pub_badge]][trackable_pub_badge_link] | ||
[![license: MIT][license_badge]][license_badge_link] | ||
[![style: netglade analysis][style_badge]][style_badge_link] | ||
[![Discord][discord_badge]][discord_badge_link] | ||
|
||
|
||
--- | ||
|
||
A set of interfaces used internally in Netglade's packages. | ||
|
||
|
||
[netglade_link]: https://netglade.com/en | ||
[trackable_pub_badge]: https://img.shields.io/pub/v/trackable.svg | ||
[trackable_pub_badge_link]: https://pub.dartlang.org/packages/trackable | ||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license_badge_link]: https://opensource.org/licenses/MIT | ||
[style_badge]: https://img.shields.io/badge/style-netglade_analysis-26D07C.svg | ||
[style_badge_link]: https://pub.dev/packages/netglade_analysis | ||
[discord_badge]: https://img.shields.io/discord/1091460081054400532.svg?logo=discord&color=blue | ||
[discord_badge_link]: https://discord.gg/WfrS8MAd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
include: package:netglade_analysis/lints.yaml | ||
|
||
linter: | ||
rules: | ||
no_literal_bool_comparisons: false | ||
|
||
# dcm check-dependencies . integration_test --ignored-packages=json_serializable,drift_dev,auto_mappr,flutter_launcher_icons,sqlcipher_flutter_libs | ||
dart_code_metrics: | ||
extends: | ||
- package:netglade_analysis/dcm.yaml | ||
rules: | ||
missing-test-assertion: | ||
include-assertions: | ||
- called | ||
- calledOnce | ||
- verifyNoMoreInteractions | ||
- verifyZeroInteractions | ||
- verifyZeroInteractionsWithAnalytics | ||
prefer-named-boolean-parameters: | ||
exclude: | ||
- test/** | ||
prefer-first: | ||
exclude: | ||
- test/** | ||
# Check if we don't use position of values. | ||
enum-constants-ordering: false | ||
format-comment: | ||
ignored-patterns: | ||
- etc. | ||
|
||
# Lints mainly widget callbacks, listeners etc. | ||
avoid-passing-async-when-sync-expected: false | ||
avoid-ignoring-return-values: | ||
exclude: | ||
- test/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// ignore_for_file: avoid_print | ||
|
||
import 'package:trackable/trackable.dart'; | ||
|
||
void main() { | ||
final trackingId = TrackingIdService.createTrackingId(); | ||
|
||
print(trackingId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: example | ||
description: Trackable example | ||
publish_to: "none" | ||
version: 0.1.0 | ||
|
||
environment: | ||
sdk: ">=3.1.0 <4.0.0" | ||
|
||
dependencies: | ||
trackable: | ||
path: ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:trackable/src/trackable_error.dart'; | ||
import 'package:trackable/src/tracking_id.dart'; | ||
import 'package:uuid/uuid.dart'; | ||
|
||
class GeneralTrackableError extends TrackableError<Object> { | ||
const GeneralTrackableError({ | ||
required super.error, | ||
required super.errorId, | ||
required super.trackingId, | ||
}); | ||
|
||
factory GeneralTrackableError.generateId({ | ||
required Object error, | ||
required TrackingId trackingId, | ||
}) => | ||
GeneralTrackableError( | ||
error: error, | ||
errorId: const Uuid().v4(), | ||
trackingId: trackingId, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:trackable/src/general_trackable_error.dart'; | ||
import 'package:trackable/src/tracking_id.dart'; | ||
import 'package:trackable/src/tracking_id_service.dart'; | ||
|
||
extension GeneralTrackableErrorExtensions on Object { | ||
GeneralTrackableError asGeneralTrackableError({ | ||
required TrackingId trackingId, | ||
String? errorId, | ||
}) => | ||
GeneralTrackableError( | ||
error: this, | ||
errorId: errorId ?? TrackingIdService.createTrackingId(), | ||
trackingId: trackingId, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:trackable/src/trackable_interfaces.dart'; | ||
import 'package:trackable/src/tracking_id.dart'; | ||
import 'package:uuid/uuid.dart'; | ||
|
||
class TrackableError<T> implements ITrackableError { | ||
final T error; | ||
|
||
@override | ||
final String errorId; | ||
|
||
@override | ||
final TrackingId trackingId; | ||
|
||
const TrackableError({ | ||
required this.error, | ||
required this.errorId, | ||
required this.trackingId, | ||
}); | ||
|
||
factory TrackableError.generateId({ | ||
required T error, | ||
required TrackingId trackingId, | ||
}) => | ||
TrackableError( | ||
error: error, | ||
errorId: const Uuid().v4(), | ||
trackingId: trackingId, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ignore_for_file: prefer-single-declaration-per-file, prefer-match-file-name | ||
|
||
import 'package:trackable/src/tracking_id.dart'; | ||
|
||
interface class ITrackable { | ||
final String trackingId; | ||
|
||
const ITrackable({required this.trackingId}); | ||
} | ||
|
||
interface class ITrackableError implements ITrackable { | ||
@override | ||
final TrackingId trackingId; | ||
|
||
final String errorId; | ||
|
||
const ITrackableError({required this.trackingId, required this.errorId}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
typedef TrackingId = String; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:meta/meta.dart'; | ||
import 'package:trackable/src/tracking_id.dart'; | ||
import 'package:uuid/uuid.dart'; | ||
|
||
class TrackingIdService { | ||
static const _uuid = Uuid(); | ||
|
||
static TrackingId? _trackingId; | ||
|
||
const TrackingIdService._(); | ||
|
||
@visibleForTesting | ||
// Ignored since the method is for testing purpose and should not be used as setter | ||
// ignore: use_setters_to_change_properties | ||
static void mockTrackingId(TrackingId? arg) => _trackingId = arg; | ||
|
||
/// Creates a unique `trackingId`. | ||
static TrackingId createTrackingId() { | ||
return _trackingId ?? _uuid.v4(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// Support for doing something awesome. | ||
/// | ||
/// More dartdocs go here. | ||
library; | ||
|
||
export 'src/general_trackable_error.dart'; | ||
export 'src/general_trackable_error_extensions.dart'; | ||
export 'src/trackable_error.dart'; | ||
export 'src/trackable_interfaces.dart'; | ||
export 'src/tracking_id.dart'; | ||
export 'src/tracking_id_service.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: trackable | ||
description: Marker interfaces for trackable events and errors. | ||
version: 1.0.0 | ||
# repository: https://github.com/my_org/my_repo | ||
|
||
environment: | ||
sdk: ^3.4.3 | ||
|
||
dependencies: | ||
meta: ^1.12.0 | ||
uuid: ^4.4.2 | ||
|
||
dev_dependencies: | ||
netglade_analysis: ^11.0.0 | ||
test: ^1.24.0 |