From 2a8ee472ce23a642cae1d25dae4746aad70246d8 Mon Sep 17 00:00:00 2001 From: flexagoon Date: Mon, 4 Nov 2024 02:09:06 +0300 Subject: [PATCH 1/2] feat: use XDG directories on Linux --- .../example/serving_surveys.dart | 17 ++-- pkgs/unified_analytics/lib/src/analytics.dart | 63 +++++++++----- pkgs/unified_analytics/lib/src/constants.dart | 2 +- .../lib/src/initializer.dart | 15 ++-- pkgs/unified_analytics/lib/src/utils.dart | 35 ++++++++ .../test/error_handler_test.dart | 16 +++- .../test/events_with_fake_test.dart | 12 ++- .../test/legacy_analytics_test.dart | 22 +++++ .../test/log_handler_test.dart | 11 ++- .../test/suppression_test.dart | 10 +++ .../test/survey_handler_test.dart | 55 ++++++++++-- .../test/unified_analytics_test.dart | 87 ++++++++++++++----- .../unified_analytics/test/workflow_test.dart | 68 ++++++++++----- 13 files changed, 313 insertions(+), 100 deletions(-) diff --git a/pkgs/unified_analytics/example/serving_surveys.dart b/pkgs/unified_analytics/example/serving_surveys.dart index d56339efd..8153d0a33 100644 --- a/pkgs/unified_analytics/example/serving_surveys.dart +++ b/pkgs/unified_analytics/example/serving_surveys.dart @@ -9,6 +9,7 @@ import 'package:file/memory.dart'; import 'package:unified_analytics/src/constants.dart'; import 'package:unified_analytics/src/enums.dart'; import 'package:unified_analytics/src/survey_handler.dart'; +import 'package:unified_analytics/src/utils.dart'; import 'package:unified_analytics/unified_analytics.dart'; /// This example code is intended to only be used as guidance for @@ -22,6 +23,8 @@ void main() async { late final MemoryFileSystem fs; late final Analytics analytics; late final Directory home; + late final Directory dataDirectory; + late final Directory configDirectory; // We need to initialize with a fake clock since the surveys have // a period of time they are valid for await withClock(Clock.fixed(DateTime(2023, 3, 3, 12, 0)), () async { @@ -30,6 +33,7 @@ void main() async { fs = MemoryFileSystem(style: FileSystemStyle.posix); home = fs.directory('home'); home.createSync(); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; // The purpose of `initialAnalytics` is so that the tool is able to // send events after its first run; this instance won't be used below @@ -38,6 +42,8 @@ void main() async { final initialAnalytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -49,13 +55,14 @@ void main() async { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, surveyHandler: FakeSurveyHandler.fromList( - dismissedSurveyFile: home - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName), + dismissedSurveyFile: + dataDirectory.childFile(kDismissedSurveyFileName), initializedSurveys: [ Survey( uniqueId: 'uniqueId', @@ -113,9 +120,7 @@ void main() async { analytics.surveyShown(survey); // Get the file where this is persisted to show it getting updated - final persistedSurveyFile = home - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName); + final persistedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); print('The contents of the json file ' 'after invoking `analytics.surveyShown(survey);`'); print('${persistedSurveyFile.readAsStringSync()}\n'); diff --git a/pkgs/unified_analytics/lib/src/analytics.dart b/pkgs/unified_analytics/lib/src/analytics.dart index cc8b4bc11..cff1a774a 100644 --- a/pkgs/unified_analytics/lib/src/analytics.dart +++ b/pkgs/unified_analytics/lib/src/analytics.dart @@ -60,6 +60,8 @@ abstract class Analytics { return const NoOpAnalytics(); } + final (dataDirectory, configDirectory) = getToolDirectories(fs)!; + // Resolve the OS using dart:io final DevicePlatform platform; if (io.Platform.operatingSystem == 'linux') { @@ -77,11 +79,17 @@ abstract class Analytics { apiSecret: kGoogleAnalyticsApiSecret, ); - final firstRun = runInitialization(homeDirectory: homeDirectory); + final firstRun = runInitialization( + homeDirectory: homeDirectory, + configDirectory: configDirectory, + dataDirectory: dataDirectory, + ); return AnalyticsImpl( tool: tool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, flutterVersion: flutterVersion, dartVersion: dartVersion, @@ -90,9 +98,7 @@ abstract class Analytics { fs: fs, gaClient: gaClient, surveyHandler: SurveyHandler( - dismissedSurveyFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName), + dismissedSurveyFile: dataDirectory.childFile(kDismissedSurveyFileName), ), enableAsserts: enableAsserts, clientIde: clientIde, @@ -133,6 +139,8 @@ abstract class Analytics { throw Exception('Permissions error on the home directory!'); } + final (configDirectory, dataDirectory) = getToolDirectories(fs)!; + // Resolve the OS using dart:io final DevicePlatform platform; if (io.Platform.operatingSystem == 'linux') { @@ -154,11 +162,17 @@ abstract class Analytics { apiSecret: kTestApiSecret, ); - final firstRun = runInitialization(homeDirectory: homeDirectory); + final firstRun = runInitialization( + homeDirectory: homeDirectory, + configDirectory: configDirectory, + dataDirectory: dataDirectory, + ); return AnalyticsImpl( tool: tool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, flutterVersion: flutterVersion, dartVersion: dartVersion, @@ -167,9 +181,7 @@ abstract class Analytics { fs: fs, gaClient: gaClient, surveyHandler: SurveyHandler( - dismissedSurveyFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName), + dismissedSurveyFile: dataDirectory.childFile(kDismissedSurveyFileName), ), enableAsserts: enableAsserts, clientIde: clientIde, @@ -289,6 +301,8 @@ abstract class Analytics { static FakeAnalytics fake({ required DashTool tool, required Directory homeDirectory, + required Directory configDirectory, + required Directory dataDirectory, required String dartVersion, required MemoryFileSystem fs, String? flutterChannel, @@ -302,11 +316,17 @@ abstract class Analytics { String toolsMessage = kToolsMessage, bool enableAsserts = true, }) { - final firstRun = runInitialization(homeDirectory: homeDirectory); + final firstRun = runInitialization( + homeDirectory: homeDirectory, + configDirectory: configDirectory, + dataDirectory: dataDirectory, + ); return FakeAnalytics._( tool: tool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, flutterVersion: flutterVersion, @@ -315,9 +335,8 @@ abstract class Analytics { fs: fs, surveyHandler: surveyHandler ?? FakeSurveyHandler.fromList( - dismissedSurveyFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName), + dismissedSurveyFile: + dataDirectory.childFile(kDismissedSurveyFileName), initializedSurveys: [], ), gaClient: gaClient ?? const FakeGAClient(), @@ -373,6 +392,8 @@ class AnalyticsImpl implements Analytics { AnalyticsImpl({ required this.tool, required Directory homeDirectory, + required Directory dataDirectory, + required Directory configDirectory, required String? flutterChannel, required String? flutterVersion, required String? clientIde, @@ -388,13 +409,9 @@ class AnalyticsImpl implements Analytics { }) : _gaClient = gaClient, _surveyHandler = surveyHandler, _enableAsserts = enableAsserts, - _clientIdFile = homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kClientIdFileName), + _clientIdFile = dataDirectory.childFile(kClientIdFileName), _userProperty = UserProperty( - sessionFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kSessionFileName), + sessionFile: dataDirectory.childFile(kSessionFileName), flutterChannel: flutterChannel, host: platform.label, flutterVersion: flutterVersion, @@ -410,14 +427,10 @@ class AnalyticsImpl implements Analytics { ), _configHandler = ConfigHandler( homeDirectory: homeDirectory, - configFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kConfigFileName), + configFile: configDirectory.childFile(kConfigFileName), ), _logHandler = LogHandler( - logFile: homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kLogFileName), + logFile: dataDirectory.childFile(kLogFileName), ) { // This initializer class will let the instance know // if it was the first run; if it is, nothing will be sent @@ -747,6 +760,8 @@ class FakeAnalytics extends AnalyticsImpl { FakeAnalytics._({ required super.tool, required super.homeDirectory, + required super.dataDirectory, + required super.configDirectory, required super.dartVersion, required super.platform, required super.fs, diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index fde9c21b3..f2d38ea4c 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -57,7 +57,7 @@ const String kContextualSurveyUrl = /// Name of the directory where all of the files necessary for this package /// will be located. -const String kDartToolDirectoryName = '.dart-tool'; +const String kDartToolDirectoryName = 'dart-tool'; /// The default time to wait before closing the http connection to allow for /// pending events to be sent. diff --git a/pkgs/unified_analytics/lib/src/initializer.dart b/pkgs/unified_analytics/lib/src/initializer.dart index 131968b88..e495b9a8a 100644 --- a/pkgs/unified_analytics/lib/src/initializer.dart +++ b/pkgs/unified_analytics/lib/src/initializer.dart @@ -73,14 +73,14 @@ DateTime createSessionFile({required File sessionFile}) { /// - Dismissed survey JSON file bool runInitialization({ required Directory homeDirectory, + required Directory configDirectory, + required Directory dataDirectory, }) { var firstRun = false; - final dartToolDirectory = - homeDirectory.childDirectory(kDartToolDirectoryName); // When the config file doesn't exist, initialize it with the default tools // and the current date. - final configFile = dartToolDirectory.childFile(kConfigFileName); + final configFile = configDirectory.childFile(kConfigFileName); if (!configFile.existsSync()) { firstRun = true; createConfigFile( @@ -90,26 +90,25 @@ bool runInitialization({ } // Begin initialization checks for the client id. - final clientFile = dartToolDirectory.childFile(kClientIdFileName); + final clientFile = dataDirectory.childFile(kClientIdFileName); if (!clientFile.existsSync()) { createClientIdFile(clientIdFile: clientFile); } // Begin initialization checks for the session file. - final sessionFile = dartToolDirectory.childFile(kSessionFileName); + final sessionFile = dataDirectory.childFile(kSessionFileName); if (!sessionFile.existsSync()) { createSessionFile(sessionFile: sessionFile); } // Begin initialization checks for the log file to persist events locally. - final logFile = dartToolDirectory.childFile(kLogFileName); + final logFile = dataDirectory.childFile(kLogFileName); if (!logFile.existsSync()) { createLogFile(logFile: logFile); } // Begin initialization checks for the dismissed survey file. - final dismissedSurveyFile = - dartToolDirectory.childFile(kDismissedSurveyFileName); + final dismissedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); if (!dismissedSurveyFile.existsSync()) { createDismissedSurveyFile(dismissedSurveyFile: dismissedSurveyFile); } diff --git a/pkgs/unified_analytics/lib/src/utils.dart b/pkgs/unified_analytics/lib/src/utils.dart index 41848a204..fc8cb5ec0 100644 --- a/pkgs/unified_analytics/lib/src/utils.dart +++ b/pkgs/unified_analytics/lib/src/utils.dart @@ -10,6 +10,7 @@ import 'package:clock/clock.dart'; import 'package:convert/convert.dart'; import 'package:file/file.dart'; +import 'constants.dart'; import 'enums.dart'; import 'event.dart'; import 'survey_handler.dart'; @@ -108,6 +109,40 @@ Directory? getHomeDirectory(FileSystem fs) { return fs.directory(home); } +/// When using Linux, use the XDG Base Directory Specification to determine +/// the location of the config and data directories. If the tool directory +/// exists at the old location, use it as a fallback. +(Directory data, Directory config)? getToolDirectories(FileSystem fs) { + final home = getHomeDirectory(fs); + if (home == null) return null; + + final oldConfigDirectory = home.childDirectory('.dart-tool'); + + if (!io.Platform.isLinux) { + return (oldConfigDirectory, oldConfigDirectory); + } + + final xdgDataHome = + io.Platform.environment['XDG_DATA_HOME'] ?? '~/.local/share'; + final dataDirectory = + fs.directory(xdgDataHome).childDirectory(kDartToolDirectoryName); + + final xdgConfigHome = + io.Platform.environment['XDG_CONFIG_HOME'] ?? '~/.config'; + final configDirectory = + fs.directory(xdgConfigHome).childDirectory(kDartToolDirectoryName); + + if (dataDirectory.existsSync() && configDirectory.existsSync()) { + return (dataDirectory, configDirectory); + } + + if (oldConfigDirectory.existsSync()) { + return (oldConfigDirectory, oldConfigDirectory); + } + + return (dataDirectory, configDirectory); +} + /// Returns `true` if user has opted out of legacy analytics in /// Dart or Flutter. /// diff --git a/pkgs/unified_analytics/test/error_handler_test.dart b/pkgs/unified_analytics/test/error_handler_test.dart index 39b2df8f5..41c148150 100644 --- a/pkgs/unified_analytics/test/error_handler_test.dart +++ b/pkgs/unified_analytics/test/error_handler_test.dart @@ -10,11 +10,14 @@ import 'package:test/test.dart'; import 'package:unified_analytics/src/constants.dart'; import 'package:unified_analytics/src/enums.dart'; +import 'package:unified_analytics/src/utils.dart'; import 'package:unified_analytics/unified_analytics.dart'; void main() { late MemoryFileSystem fs; late Directory home; + late Directory dataDirectory; + late Directory configDirectory; late FakeAnalytics initializationAnalytics; late FakeAnalytics analytics; late File sessionFile; @@ -38,12 +41,15 @@ void main() { io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; fs = MemoryFileSystem.test(style: fsStyle); home = fs.directory(homeDirName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; // This is the first analytics instance that will be used to demonstrate // that events will not be sent with the first run of analytics initializationAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -64,6 +70,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -76,10 +84,8 @@ void main() { analytics.clientShowedMessage(); // The files that should have been generated that will be used for tests - sessionFile = - home.childDirectory(kDartToolDirectoryName).childFile(kSessionFileName); - logFile = - home.childDirectory(kDartToolDirectoryName).childFile(kLogFileName); + sessionFile = dataDirectory.childFile(kSessionFileName); + logFile = dataDirectory.childFile(kLogFileName); }); group('Session handler:', () { @@ -96,6 +102,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, diff --git a/pkgs/unified_analytics/test/events_with_fake_test.dart b/pkgs/unified_analytics/test/events_with_fake_test.dart index 9794275ac..3e6bc3e5c 100644 --- a/pkgs/unified_analytics/test/events_with_fake_test.dart +++ b/pkgs/unified_analytics/test/events_with_fake_test.dart @@ -10,6 +10,7 @@ import 'package:test/test.dart'; import 'package:unified_analytics/src/constants.dart'; import 'package:unified_analytics/src/enums.dart'; import 'package:unified_analytics/src/survey_handler.dart'; +import 'package:unified_analytics/src/utils.dart'; import 'package:unified_analytics/unified_analytics.dart'; void main() { @@ -19,6 +20,8 @@ void main() { late FakeAnalytics fakeAnalytics; late MemoryFileSystem fs; late Directory homeDirectory; + late Directory dataDirectory; + late Directory configDirectory; late File dismissedSurveyFile; /// Survey to load into the fake instance to fetch @@ -51,13 +54,14 @@ void main() { setUp(() async { fs = MemoryFileSystem.test(style: FileSystemStyle.posix); homeDirectory = fs.directory('home'); - dismissedSurveyFile = homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; + dismissedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); final initialAnalytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', toolsMessageVersion: 1, fs: fs, @@ -72,6 +76,8 @@ void main() { fakeAnalytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', platform: DevicePlatform.macos, fs: fs, diff --git a/pkgs/unified_analytics/test/legacy_analytics_test.dart b/pkgs/unified_analytics/test/legacy_analytics_test.dart index 36acee9b2..1fa76b0cc 100644 --- a/pkgs/unified_analytics/test/legacy_analytics_test.dart +++ b/pkgs/unified_analytics/test/legacy_analytics_test.dart @@ -9,11 +9,14 @@ import 'package:file/memory.dart'; import 'package:test/test.dart'; import 'package:unified_analytics/src/enums.dart'; +import 'package:unified_analytics/src/utils.dart'; import 'package:unified_analytics/unified_analytics.dart'; void main() { late MemoryFileSystem fs; late Directory home; + late Directory dataDirectory; + late Directory configDirectory; late Analytics analytics; const homeDirName = 'home'; @@ -31,6 +34,7 @@ void main() { io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; fs = MemoryFileSystem.test(style: fsStyle); home = fs.directory(homeDirName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; }); test('Honor legacy dart analytics opt out', () { @@ -52,6 +56,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -83,6 +89,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -113,6 +121,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -143,6 +153,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -177,6 +189,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -211,6 +225,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -243,6 +259,8 @@ NOT VALID JSON analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -279,6 +297,8 @@ NOT VALID JSON analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -311,6 +331,8 @@ NOT VALID JSON analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, diff --git a/pkgs/unified_analytics/test/log_handler_test.dart b/pkgs/unified_analytics/test/log_handler_test.dart index db14d96ce..2c25590d5 100644 --- a/pkgs/unified_analytics/test/log_handler_test.dart +++ b/pkgs/unified_analytics/test/log_handler_test.dart @@ -18,6 +18,8 @@ import 'package:unified_analytics/unified_analytics.dart'; void main() { late FakeAnalytics analytics; late Directory homeDirectory; + late Directory dataDirectory; + late Directory configDirectory; late MemoryFileSystem fs; late File logFile; @@ -26,14 +28,15 @@ void main() { setUp(() { fs = MemoryFileSystem.test(style: FileSystemStyle.posix); homeDirectory = fs.directory('home'); - logFile = homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kLogFileName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; + logFile = dataDirectory.childFile(kLogFileName); // Create the initialization analytics instance to onboard the tool final initializationAnalytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -45,6 +48,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, diff --git a/pkgs/unified_analytics/test/suppression_test.dart b/pkgs/unified_analytics/test/suppression_test.dart index 05fab15f1..ea8306df9 100644 --- a/pkgs/unified_analytics/test/suppression_test.dart +++ b/pkgs/unified_analytics/test/suppression_test.dart @@ -8,11 +8,14 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:test/test.dart'; import 'package:unified_analytics/src/enums.dart'; +import 'package:unified_analytics/src/utils.dart'; import 'package:unified_analytics/unified_analytics.dart'; void main() { late MemoryFileSystem fs; late Directory home; + late Directory dataDirectory; + late Directory configDirectory; late Analytics initializationAnalytics; late Analytics analytics; @@ -33,12 +36,15 @@ void main() { io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; fs = MemoryFileSystem.test(style: fsStyle); home = fs.directory(homeDirName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; // This is the first analytics instance that will be used to demonstrate // that events will not be sent with the first run of analytics initializationAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -57,6 +63,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -91,6 +99,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, diff --git a/pkgs/unified_analytics/test/survey_handler_test.dart b/pkgs/unified_analytics/test/survey_handler_test.dart index 3d8c8dd6c..2d0ab0d1b 100644 --- a/pkgs/unified_analytics/test/survey_handler_test.dart +++ b/pkgs/unified_analytics/test/survey_handler_test.dart @@ -262,6 +262,8 @@ void main() { group('Testing with FakeSurveyHandler', () { late Analytics analytics; late Directory homeDirectory; + late Directory dataDirectory; + late Directory configDirectory; late MemoryFileSystem fs; late File clientIdFile; late File dismissedSurveyFile; @@ -269,20 +271,17 @@ void main() { setUp(() { fs = MemoryFileSystem.test(style: FileSystemStyle.posix); homeDirectory = fs.directory('home'); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; // Write the client ID file out so that we don't get // a randomly assigned id for this test generated within // the analytics constructor - clientIdFile = homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kClientIdFileName); + clientIdFile = dataDirectory.childFile(kClientIdFileName); clientIdFile.createSync(recursive: true); clientIdFile.writeAsStringSync('string1'); // Assign the json file that will hold the persisted surveys - dismissedSurveyFile = homeDirectory - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName); + dismissedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); // Setup two tools to be onboarded with this package so // that we can simulate two different tools interacting with @@ -293,6 +292,8 @@ void main() { final initialAnalyticsFlutter = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -300,6 +301,8 @@ void main() { final initialAnalyticsDart = Analytics.fake( tool: DashTool.dartTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -313,6 +316,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -364,6 +369,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -404,6 +411,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -447,6 +456,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -547,6 +558,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -609,6 +622,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -690,6 +705,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -764,6 +781,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -807,6 +826,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -852,6 +873,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -879,6 +902,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -898,6 +923,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -942,6 +969,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -968,6 +997,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1014,6 +1045,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1044,6 +1077,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1090,6 +1125,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1117,6 +1154,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1139,6 +1178,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, @@ -1184,6 +1225,8 @@ void main() { analytics = Analytics.fake( tool: DashTool.flutterTool, homeDirectory: homeDirectory, + dataDirectory: dataDirectory, + configDirectory: configDirectory, dartVersion: 'dartVersion', fs: fs, platform: DevicePlatform.macos, diff --git a/pkgs/unified_analytics/test/unified_analytics_test.dart b/pkgs/unified_analytics/test/unified_analytics_test.dart index 2e78df426..490d88cb4 100644 --- a/pkgs/unified_analytics/test/unified_analytics_test.dart +++ b/pkgs/unified_analytics/test/unified_analytics_test.dart @@ -21,7 +21,8 @@ import 'package:yaml/yaml.dart'; void main() { late MemoryFileSystem fs; late Directory home; - late Directory dartToolDirectory; + late Directory dataDirectory; + late Directory configDirectory; late Analytics initializationAnalytics; late FakeAnalytics analytics; late File clientIdFile; @@ -49,13 +50,15 @@ void main() { io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; fs = MemoryFileSystem.test(style: fsStyle); home = fs.directory(homeDirName); - dartToolDirectory = home.childDirectory(kDartToolDirectoryName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; // This is the first analytics instance that will be used to demonstrate // that events will not be sent with the first run of analytics initializationAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -76,6 +79,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -88,22 +93,17 @@ void main() { analytics.clientShowedMessage(); // The 5 files that should have been generated - clientIdFile = home - .childDirectory(kDartToolDirectoryName) - .childFile(kClientIdFileName); - sessionFile = - home.childDirectory(kDartToolDirectoryName).childFile(kSessionFileName); - configFile = - home.childDirectory(kDartToolDirectoryName).childFile(kConfigFileName); - logFile = - home.childDirectory(kDartToolDirectoryName).childFile(kLogFileName); - dismissedSurveyFile = home - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName); + clientIdFile = dataDirectory.childFile(kClientIdFileName); + sessionFile = dataDirectory.childFile(kSessionFileName); + configFile = configDirectory.childFile(kConfigFileName); + logFile = dataDirectory.childFile(kLogFileName); + dismissedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); }); test('Initializer properly sets up on first run', () { - expect(dartToolDirectory.existsSync(), true, + expect(dataDirectory.existsSync(), true, + reason: 'The directory should have been created'); + expect(configDirectory.existsSync(), true, reason: 'The directory should have been created'); expect(clientIdFile.existsSync(), true, reason: 'The $kClientIdFileName file was not found'); @@ -115,9 +115,16 @@ void main() { reason: 'The $kLogFileName file was not found'); expect(dismissedSurveyFile.existsSync(), true, reason: 'The $dismissedSurveyFile file was not found'); - expect(dartToolDirectory.listSync().length, equals(5), - reason: - 'There should only be 5 files in the $kDartToolDirectoryName directory'); + expect( + dataDirectory.listSync().length, + equals(4), + reason: 'There should only be 4 files in the data directory', + ); + expect( + configDirectory.listSync().length, + equals(1), + reason: 'There should only be 1 file in the config directory', + ); expect(configFile.readAsLinesSync().length, kConfigString.split('\n').length + 1, reason: 'The number of lines should equal lines in constant value + 1 ' @@ -162,6 +169,8 @@ void main() { analytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -224,6 +233,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: 'ey-test-channel', toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -315,6 +326,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -357,6 +370,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: 'ey-test-channel', toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -379,6 +394,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: 'ey-test-channel', toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -431,6 +448,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: 'ey-test-channel', toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -460,6 +479,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, toolsMessage: toolsMessage, @@ -585,6 +606,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, toolsMessage: toolsMessage, @@ -608,6 +631,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final thirdAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, toolsMessage: toolsMessage, @@ -664,10 +689,10 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion 'The session id stays the same when duration' ' is less than the constraint', () { // For this test, we will need control clock time so we will delete - // the [dartToolDirectory] and all of its contents and reconstruct a + // the [dataDirectory] and all of its contents and reconstruct a // new [Analytics] instance at a specific time - dartToolDirectory.deleteSync(recursive: true); - expect(dartToolDirectory.existsSync(), false, + dataDirectory.deleteSync(recursive: true); + expect(dataDirectory.existsSync(), false, reason: 'The directory should have been cleared'); // Define the initial time to start @@ -679,6 +704,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -706,6 +733,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final thirdAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -733,10 +762,10 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion test('The session id is refreshed once event is sent after duration', () { // For this test, we will need control clock time so we will delete - // the [dartToolDirectory] and all of its contents and reconstruct a + // the [dataDirectory] and all of its contents and reconstruct a // new [Analytics] instance at a specific time - dartToolDirectory.deleteSync(recursive: true); - expect(dartToolDirectory.existsSync(), false, + dataDirectory.deleteSync(recursive: true); + expect(dataDirectory.existsSync(), false, reason: 'The directory should have been cleared'); // Define the initial time to start @@ -748,6 +777,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -779,6 +810,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion final thirdAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -928,6 +961,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -1033,6 +1068,8 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, // flutterChannel: flutterChannel, THIS NEEDS TO REMAIN REMOVED toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -1182,6 +1219,8 @@ Privacy Policy (https://policies.google.com/privacy). final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: 'ey-test-channel', toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, diff --git a/pkgs/unified_analytics/test/workflow_test.dart b/pkgs/unified_analytics/test/workflow_test.dart index 3a623a0b8..dfd853c3b 100644 --- a/pkgs/unified_analytics/test/workflow_test.dart +++ b/pkgs/unified_analytics/test/workflow_test.dart @@ -15,7 +15,8 @@ import 'package:unified_analytics/unified_analytics.dart'; void main() { late MemoryFileSystem fs; late Directory home; - late Directory dartToolDirectory; + late Directory dataDirectory; + late Directory configDirectory; late File clientIdFile; late File sessionFile; late File configFile; @@ -40,27 +41,22 @@ void main() { io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; fs = MemoryFileSystem.test(style: fsStyle); home = fs.directory(homeDirName); - dartToolDirectory = home.childDirectory(kDartToolDirectoryName); - - // The 3 files that should have been generated - clientIdFile = home - .childDirectory(kDartToolDirectoryName) - .childFile(kClientIdFileName); - sessionFile = - home.childDirectory(kDartToolDirectoryName).childFile(kSessionFileName); - configFile = - home.childDirectory(kDartToolDirectoryName).childFile(kConfigFileName); - logFile = - home.childDirectory(kDartToolDirectoryName).childFile(kLogFileName); - dismissedSurveyFile = home - .childDirectory(kDartToolDirectoryName) - .childFile(kDismissedSurveyFileName); + (dataDirectory, configDirectory) = getToolDirectories(fs)!; + + // The 5 files that should have been generated + clientIdFile = dataDirectory.childFile(kClientIdFileName); + sessionFile = dataDirectory.childFile(kSessionFileName); + configFile = configDirectory.childFile(kConfigFileName); + logFile = dataDirectory.childFile(kLogFileName); + dismissedSurveyFile = dataDirectory.childFile(kDismissedSurveyFileName); }); test('Confirm workflow for first run', () { final firstAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -96,6 +92,8 @@ void main() { final firstAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -111,6 +109,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version toolsMessage: toolsMessage, @@ -128,6 +128,8 @@ void main() { final thirdAnalytics = Analytics.fake( tool: secondTool, // Different tool homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version toolsMessage: toolsMessage, @@ -146,6 +148,8 @@ void main() { final firstAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -157,7 +161,9 @@ void main() { // Host of assertions to ensure all required artifacts // are created - expect(dartToolDirectory.existsSync(), true, + expect(dataDirectory.existsSync(), true, + reason: 'The directory should have been created'); + expect(configDirectory.existsSync(), true, reason: 'The directory should have been created'); expect(clientIdFile.existsSync(), true, reason: 'The $kClientIdFileName file was not found'); @@ -170,10 +176,14 @@ void main() { expect(dismissedSurveyFile.existsSync(), true, reason: 'The $dismissedSurveyFile file was not found'); expect( - dartToolDirectory.listSync().length, - equals(5), - reason: 'There should only be 5 files in the $kDartToolDirectoryName ' - 'directory', + dataDirectory.listSync().length, + equals(4), + reason: 'There should only be 4 files in the data directory', + ); + expect( + configDirectory.listSync().length, + equals(1), + reason: 'There should only be 1 file in the config directory', ); expect(configFile.readAsStringSync(), kConfigString); @@ -201,6 +211,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -232,6 +244,8 @@ void main() { final thirdAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version toolsMessage: toolsMessage, @@ -261,6 +275,8 @@ void main() { final fourthAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version toolsMessage: toolsMessage, @@ -285,6 +301,8 @@ void main() { final firstAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -299,6 +317,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -315,6 +335,8 @@ void main() { final thirdAnalytics = Analytics.fake( tool: initialTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: toolsMessageVersion, toolsMessage: toolsMessage, @@ -332,6 +354,8 @@ void main() { final secondAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: firstVersion, toolsMessage: toolsMessage, @@ -354,6 +378,8 @@ void main() { final thirdAnalytics = Analytics.fake( tool: secondTool, homeDirectory: home, + dataDirectory: dataDirectory, + configDirectory: configDirectory, flutterChannel: flutterChannel, toolsMessageVersion: secondVersion, toolsMessage: toolsMessage, From b4344a8ab3463556ba239b0bea31ee7925888873 Mon Sep 17 00:00:00 2001 From: flexagoon Date: Mon, 4 Nov 2024 02:15:38 +0300 Subject: [PATCH 2/2] update package version --- pkgs/unified_analytics/CHANGELOG.md | 4 ++++ pkgs/unified_analytics/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 86d0110a4..272493463 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.2.0 + +- Use XDG directories on Linux. + ## 6.1.4 - Fix formatting and remove dependency on `package:intl`. diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index 172f5b289..8eac6633c 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml @@ -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: 6.1.4 +version: 6.2.0 # LINT.ThenChange(lib/src/constants.dart) repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics