Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 8.0.8
- Added `Event.idePluginEvent` for events reported by IDE plugins.
- More data for `Event.analysisStatistics` for events from Dart Analysis Server.

## 8.0.7
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
23 changes: 23 additions & 0 deletions 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
Loading