Skip to content

[pkgs/dash_analytics] Adding event for analyzer startup - #7

Merged
eliasyishak merged 5 commits into
dart-lang:mainfrom
eliasyishak:adding-analyzer-event-for-startup
Feb 15, 2023
Merged

eliasyishak merged 5 commits into
dart-lang:mainfrom
eliasyishak:adding-analyzer-event-for-startup

Conversation

@eliasyishak

Copy link
Copy Markdown
Contributor

Using this event to test that we are saving to the locally persisted log file

@devoncarew devoncarew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Future<Response>? sendEvent({
required DashEvent eventName,
required Map<String, Object?> eventData,
Map<String, Object?> eventData,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we're removing required here, wouldn't that change the signature to Map<String, Object?>?? And / or need to assign a const default to eventData? I'm not sure why the analyzer isn't complaining here (or what I'm missing).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps no default value is necessary if the method is abstract.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It isn't actually going to be nullable, it will just default to an empty map in the implementation.

What would be best practice here, should I also include the default value in the abstract?

  // OLD
  /// API to send events to Google Analytics to track usage
  Future<Response>? sendEvent({
    required DashEvent eventName,
    Map<String, Object?> eventData,
  });

  // NEW
  /// API to send events to Google Analytics to track usage
  Future<Response>? sendEvent({
    required DashEvent eventName,
    Map<String, Object?> eventData = const <String, Object?>{},
  });

Both approaches work in the example file

@devoncarew devoncarew Feb 15, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know that I have a strong opinion here; perhaps including it in the abstract method would help serve as documentation.

Also - I missed this in the initial review - but we should remove the always_specify_types types line from the analysis_options file (that lint generally goes counter to the dart style guide).

With that change, the above method sig can change to: Map<String, Object?> eventData = const {},.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah makes sense, i'll remove that lint rule and update the abstract method to include the default value as well

/// Officially-supported clients of this package.
///
/// All [label] values should use a hyphen as a delimiter
/// All [label] values should use an underscore as a delimiter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 - I see there's a test to enforce this convention

Future<Response>? sendEvent({
required DashEvent eventName,
required Map<String, Object?> eventData,
Map<String, Object?> eventData,

@devoncarew devoncarew Feb 15, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know that I have a strong opinion here; perhaps including it in the abstract method would help serve as documentation.

Also - I missed this in the initial review - but we should remove the always_specify_types types line from the analysis_options file (that lint generally goes counter to the dart style guide).

With that change, the above method sig can change to: Map<String, Object?> eventData = const {},.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants