Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
## 8.0.8
## 9.0.0
- Added `Event.idePluginEvent` for events reported by IDE plugins.
- More data for `Event.analysisStatistics` for events from Dart Analysis Server.

## 8.0.7
- Added optional fields `contextWorkspaceType` and `numberOfPackagesInWorkspace`
to `Event.contextStructure` for workspace and packages distribution from the
Dart Analysis Server.
- Removed `Event.contextStructure` optional fields `contextsFromBothFiles`,
`contextsFromOptionsFiles`,`contextsFromPackagesFiles`,`contextsWithoutFiles`.

## 8.0.6
- Added `Event.analysisStatistics` for events from Dart Analysis Server, about analysis.

## 8.0.5
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const int kMaxLogFileSize = 25 * (1 << 20);
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '8.0.8';
const String kPackageVersion = '9.0.0';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
24 changes: 24 additions & 0 deletions pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ enum DashEvent {
toolOwner: DashTool.devtools,
),

// Events for IDE plugins

intellijPluginEvent(
label: 'intellij_event',
description: 'Information for IntelliJ Plugin events',
toolOwner: DashTool.intellijPlugins,
),

vsCodePluginEvent(
label: 'vscode_event',
description: 'Information for VSCode Plugin events',
toolOwner: DashTool.vscodePlugins,
),

// Events for the Flutter CLI

appleUsageEvent(
Expand Down Expand Up @@ -251,3 +265,13 @@ enum DevicePlatform {
final String label;
const DevicePlatform(this.label);
}

/// Supported IDEs.
enum IDE {
intellij(DashEvent.intellijPluginEvent),
vscode(DashEvent.vsCodePluginEvent),
;

final DashEvent event;
const IDE(this.event);
}
16 changes: 16 additions & 0 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,22 @@ final class Event {
},
);

/// Event that is sent from an IDE plugin.
///
/// [name] - the name of the event.
///
/// [ide] - the reporting [IDE].
///
/// [additionalData] - any additional data.
Event.idePluginEvent({
required String name,
required IDE ide,
CustomMetrics? additionalData,
}) : this._(eventName: ide.event, eventData: {
'name': name,
if (additionalData != null) ...additionalData.toMap(),
});

/// Event that is emitted periodically to report the number of times each lint
/// has been enabled.
///
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
# LINT.IfChange
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 8.0.8
version: 9.0.0
# LINT.ThenChange(lib/src/constants.dart)
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics
Expand Down
25 changes: 24 additions & 1 deletion pkgs/unified_analytics/test/event_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,29 @@ void main() {
expect(constructedEvent.eventData.length, 1);
});

test('Event.idePluginEvent constructed', () {
Event generateEvent() => Event.idePluginEvent(
name: 'ide.command',
ide: IDE.intellij,
additionalData: _TestMetrics(
stringField: 'test',
intField: 100,
boolField: false,
),
);

final constructedEvent = generateEvent();

expect(generateEvent, returnsNormally);
expect(constructedEvent.eventName, DashEvent.intellijPluginEvent);

expect(constructedEvent.eventData['stringField'], 'test');
expect(constructedEvent.eventData['intField'], 100);
expect(constructedEvent.eventData['boolField'], false);
expect(constructedEvent.eventData.containsKey('nullableField'), false);
expect(constructedEvent.eventData.length, 4);
});

test('Event.lintUsageCount constructed', () {
Event generateEvent() => Event.lintUsageCount(
count: 5,
Expand Down Expand Up @@ -779,7 +802,7 @@ void main() {

// Change this integer below if your PR either adds or removes
// an Event constructor
final eventsAccountedForInTests = 31;
final eventsAccountedForInTests = 32;
expect(eventsAccountedForInTests, constructorCount,
reason: 'If you added or removed an event constructor, '
'ensure you have updated '
Expand Down