Skip to content

Commit 423deed

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: Tidy up the plugin analytics data
Change-Id: Id7e3b158f148525c69cc90c1f3c8a98ec53fd336 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446280 Commit-Queue: Brian Wilkerson <[email protected]> Auto-Submit: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 94920ec commit 423deed

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

pkg/analysis_server/lib/src/analytics/plugin_data.dart

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,32 @@ class PluginData {
1717
/// associated with each of the plugins.
1818
Map<String, PercentileCalculator> usageCounts = {};
1919

20-
/// Initialize a newly created holder of plugin data.
21-
PluginData();
22-
2320
String get usageCountData {
2421
return json.encode({
2522
'recordCount': recordCount,
2623
'rootCounts': _encodeUsageCounts(),
2724
});
2825
}
2926

30-
/// Use the [pluginManager] to record data about the plugins that are
31-
/// currently running.
27+
/// Records data about the plugins that are currently running, via info from
28+
/// [pluginManager].
3229
void recordPlugins(PluginManager pluginManager) {
3330
recordCount++;
34-
var plugins = pluginManager.plugins;
35-
for (var i = 0; i < plugins.length; i++) {
36-
var info = plugins[i];
31+
for (var info in pluginManager.plugins) {
3732
usageCounts
3833
.putIfAbsent(info.safePluginId, () => PercentileCalculator())
3934
.addValue(info.contextRoots.length);
4035
}
4136
}
4237

43-
/// Return an encoding of the [usageCounts].
44-
Map<String, Object> _encodeUsageCounts() {
45-
var encoded = <String, Object>{};
46-
for (var entry in usageCounts.entries) {
47-
encoded[entry.key] = entry.value.toJson();
48-
}
49-
return encoded;
50-
}
38+
/// Returns an encoding of the [usageCounts].
39+
Map<String, Object> _encodeUsageCounts() => {
40+
for (var entry in usageCounts.entries) entry.key: entry.value.toJson(),
41+
};
5142
}
5243

5344
extension PluginInfoExtension on PluginInfo {
54-
/// Return an id for this plugin that doesn't contain any PII.
45+
/// An ID for this plugin that doesn't contain any PII.
5546
///
5647
/// If the plugin is installed in the pub cache and hosted on `pub.dev`, then
5748
/// the returned name will be the name and version of the containing package

0 commit comments

Comments
 (0)