diff --git a/pkgs/dash_analytics/lib/src/config_handler.dart b/pkgs/dash_analytics/lib/src/config_handler.dart index 83ecd7d8c2..08033d85c0 100644 --- a/pkgs/dash_analytics/lib/src/config_handler.dart +++ b/pkgs/dash_analytics/lib/src/config_handler.dart @@ -19,9 +19,9 @@ const String telemetryFlagPattern = r'^reporting=([0|1]) *$'; /// from the configuration file /// /// Example: -/// flutter-tools=2022-10-26,1 +/// flutter_tools=2022-10-26,1 const String toolPattern = - r'^([A-Za-z0-9]+-*[A-Za-z0-9]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$'; + r'^([A-Za-z0-9]+[A-Za-z0-9_]*)=([0-9]{4}-[0-9]{2}-[0-9]{2}),([0-9]+)$'; class ConfigHandler { /// Regex pattern implementation for matching a line in the config file diff --git a/pkgs/dash_analytics/test/dash_analytics_test.dart b/pkgs/dash_analytics/test/dash_analytics_test.dart index f409b975c9..c1e222ac75 100644 --- a/pkgs/dash_analytics/test/dash_analytics_test.dart +++ b/pkgs/dash_analytics/test/dash_analytics_test.dart @@ -30,7 +30,7 @@ void main() { late UserProperty userProperty; const String homeDirName = 'home'; - const String initialToolName = 'initialTool'; + const String initialToolName = 'initial_tool'; const String secondTool = 'newTool'; const String measurementId = 'measurementId'; const String apiSecret = 'apiSecret'; @@ -104,6 +104,10 @@ void main() { 'There should only be 4 files in the $kDartToolDirectoryName directory'); expect(analytics.shouldShowMessage, true, reason: 'For the first run, analytics should default to being enabled'); + expect(configFile.readAsLinesSync().length, + kConfigString.split('\n').length + 1, + reason: 'The number of lines should equal lines in constant value + 1 ' + 'for the initialized tool'); }); test('New tool is successfully added to config file', () {