Skip to content

Commit 0cf9748

Browse files
keertipCommit Queue
authored andcommitted
Send the workspace stats to analytics
Change-Id: I99cd3e9c2d45c9748b31d226ba565ead6f45bf42 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457780 Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent b50a430 commit 0cf9748

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class AnalyticsManager {
482482
'contextWorkspaceType: ${json.encode(analysisData.contextWorkspaceType.toString())}',
483483
);
484484
li(
485-
'numberOfPackagesPerWorkspace: ${json.encode(analysisData.numberOfPackagesInWorkspace.toString())}',
485+
'numberOfPackagesPerWorkspace: ${json.encode(analysisData.numberOfPackagesInWorkspace.toAnalyticsString())}',
486486
);
487487
li('immediateFileCount: ${json.encode(analysisData.immediateFileCount)}');
488488
li(
@@ -564,6 +564,11 @@ class AnalyticsManager {
564564
.toAnalyticsString(),
565565
libraryCycleLineCounts: contextStructure.libraryCycleLineCounts
566566
.toAnalyticsString(),
567+
contextWorkspaceType: contextStructure.contextWorkspaceType
568+
.toString(),
569+
numberOfPackagesInWorkspace: contextStructure
570+
.numberOfPackagesInWorkspace
571+
.toAnalyticsString(),
567572
),
568573
);
569574
}

pkg/analysis_server/test/src/analytics/analytics_manager_test.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,45 @@ class AnalyticsManagerTest with ResourceProviderMixin {
126126
PluginManager.pluginResponseTimes.clear();
127127
}
128128

129+
Future<void> test_server_contextStructure() async {
130+
_defaultStartup();
131+
132+
// Record a brief working period.
133+
manager.analysisComplete(
134+
immediateFileCount: 1,
135+
immediateFileLineCount: 1,
136+
transitiveFileCount: 3,
137+
transitiveFileLineCount: 20,
138+
transitiveFileUniqueCount: 2,
139+
transitiveFileUniqueLineCount: 15,
140+
libraryCycleLibraryCounts: [],
141+
libraryCycleLineCounts: [],
142+
numberOfContexts: 3,
143+
contextWorkspaceType: [0, 1, 2],
144+
numberOfPackagesInWorkspace: [1, 3, 4],
145+
);
146+
147+
await manager.shutdown();
148+
analytics.assertEvents([
149+
_ExpectedEvent.session(),
150+
_ExpectedEvent.contextStructure(
151+
eventData: {
152+
'immediateFileCount': 1,
153+
'immediateFileLineCount': 1,
154+
'transitiveFileCount': 3,
155+
'transitiveFileLineCount': 20,
156+
'transitiveFileUniqueCount': 2,
157+
'transitiveFileUniqueLineCount': 15,
158+
'libraryCycleLibraryCounts': _IsPercentiles(),
159+
'libraryCycleLineCounts': _IsPercentiles(),
160+
'numberOfContexts': 3,
161+
'contextWorkspaceType': '[0, 1, 2]',
162+
'numberOfPackagesInWorkspace': _IsPercentiles(),
163+
},
164+
),
165+
]);
166+
}
167+
129168
Future<void> test_server_notification() async {
130169
_defaultStartup();
131170
manager.handledNotificationMessage(
@@ -539,6 +578,9 @@ class _ExpectedEvent {
539578
_ExpectedEvent.commandExecuted({Map<String, Object?>? eventData})
540579
: this(DashEvent.commandExecuted, eventData);
541580

581+
_ExpectedEvent.contextStructure({Map<String, Object?>? eventData})
582+
: this(DashEvent.contextStructure, eventData);
583+
542584
_ExpectedEvent.lintUsageCount({Map<String, Object?>? eventData})
543585
: this(DashEvent.lintUsageCount, eventData);
544586

0 commit comments

Comments
 (0)