Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dartCliCommandExecuted and pubGet events #123

Merged
merged 11 commits into from
Aug 16, 2023
12 changes: 12 additions & 0 deletions pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ enum DashEvent {
description: 'Survey shown to the user',
),

// Events for the Dart CLI
dartCliCommandExecuted(
label: 'dart_cli_command_executed',
description: 'Information about the execution of a Dart CLI command',
toolOwner: DashTool.dartTool,
),
pubGet(
label: 'pub_get',
description: 'Pub package resolution details',
toolOwner: DashTool.dartTool,
),

// Events for flutter_tools
hotReloadTime(
label: 'hot_reload_time',
Expand Down
46 changes: 42 additions & 4 deletions pkgs/unified_analytics/lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ final class Event {
: eventName = DashEvent.analyticsCollectionEnabled,
eventData = {'status': status};

/// Event that is emitted when a Dart CLI command has been executed.
///
/// [name] - the name of the command that was executed
///
/// [enabledExperiments] - a set of Dart language experiments enabled when
/// running the command.
///
/// [exitCode] - the process exit code set as a result of running the command.
Event.dartCliCommandExecuted({
required String name,
required String enabledExperiments,
int? exitCode,
}) : eventName = DashEvent.dartCliCommandExecuted,
eventData = {
'name': name,
'enabledExperiments': enabledExperiments,
if (exitCode != null) 'exitCode': exitCode,
};

/// Event that is emitted when `pub get` is run.
///
/// [packageName] - the name of the package that was resolved
///
/// [version] - the resolved, canonicalized package version
///
/// [dependencyKind] - the kind of dependency that resulted in this package
/// being resolved (e.g., direct, transitive, or dev dependencies).
Event.pubGet({
required String packageName,
required String version,
required String dependencyType,
}) : eventName = DashEvent.pubGet,
eventData = {
'packageName': packageName,
'version': version,
'dependencyType': dependencyType,
};
Comment on lines +40 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my awareness here as well, when pub get is run, there are potentially several packages that get resolved, does this mean that each package will have its own event fired off?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, so that could result in hundreds of events. I think we could question the wisdom of this :D

I think it might be worth while updating the USAGE_GUIDE.md with some guidelines about how many events (and how big events) that can reasonably be sent, and what the performance characteristics look like.


Event.hotReloadTime({required int timeMs})
: eventName = DashEvent.hotReloadTime,
eventData = {'timeMs': timeMs};

/// Event that is emitted periodically to report the performance of the
/// analysis server's handling of a specific kind of notification from the
/// client.
Expand Down Expand Up @@ -186,10 +228,6 @@ final class Event {
'transitiveFileUniqueLineCount': transitiveFileUniqueLineCount,
};

Event.hotReloadTime({required int timeMs})
: eventName = DashEvent.hotReloadTime,
eventData = {'timeMs': timeMs};

/// Event that is emitted periodically to report the number of times each lint
/// has been enabled.
///
Expand Down