This repository was archived by the owner on Jul 16, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
66import 'package:analyzer/dart/analysis/results.dart' ;
77import 'package:analyzer_plugin/plugin/plugin.dart' ;
88import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
9+ import 'package:http/http.dart' ;
10+ import 'package:uuid/uuid.dart' ;
911
1012import '../analyzers/lint_analyzer/lint_analysis_config.dart' ;
1113import '../analyzers/lint_analyzer/lint_analysis_options_validator.dart' ;
@@ -39,7 +41,29 @@ class AnalyzerPlugin extends ServerPlugin {
3941
4042 AnalyzerPlugin ({
4143 required super .resourceProvider,
42- });
44+ }) {
45+ final location =
46+ resourceProvider.getStateLocation ('.dart-code-metrics-uuid' );
47+ if (location == null ) {
48+ return ;
49+ }
50+
51+ var uuid = '' ;
52+
53+ final file = location.getChildAssumingFile ('uuid' );
54+ if (! file.exists) {
55+ uuid = const Uuid ().v4 ();
56+ file
57+ ..createSource (file.toUri ())
58+ ..writeAsStringSync (uuid);
59+ } else {
60+ uuid = file.readAsStringSync ();
61+ }
62+
63+ final uri = Uri .parse ('https://dcm.dev/analytics/usage' );
64+
65+ post (uri, body: {'uuid' : uuid, 'version' : packageVersion}).ignore ();
66+ }
4367
4468 @override
4569 Future <void > afterNewContextCollection ({
Original file line number Diff line number Diff line change @@ -25,11 +25,13 @@ dependencies:
2525 file : ^6.0.0
2626 glob : ^2.0.1
2727 html : " >=0.15.0 <1.0.0"
28+ http : ^0.13.5
2829 meta : ^1.7.0
2930 path : ^1.8.0
3031 platform : ^3.1.0 # overridden for lowest versions compatibility
3132 pub_updater : ^0.2.2
3233 source_span : ^1.8.0
34+ uuid : ^3.0.7
3335 xml : " >=5.3.0 <7.0.0"
3436 yaml : ^3.1.0
3537
You can’t perform that action at this time.
0 commit comments