From 4ecdcf1d72c6a3f760cb40a4e44060dcd8ca82d3 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Wed, 31 Jul 2024 10:50:48 +0200 Subject: [PATCH] remove repro attempts --- .../java/maestro/cli/analytics/Analytics.kt | 72 ++++++++++--------- .../main/java/maestro/cli/util/IOSEnvUtils.kt | 2 +- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/maestro-cli/src/main/java/maestro/cli/analytics/Analytics.kt b/maestro-cli/src/main/java/maestro/cli/analytics/Analytics.kt index 9a1a177d3f..60ca25b668 100644 --- a/maestro-cli/src/main/java/maestro/cli/analytics/Analytics.kt +++ b/maestro-cli/src/main/java/maestro/cli/analytics/Analytics.kt @@ -113,49 +113,55 @@ object Analytics { * Uploads analytics if there was a version update. */ fun maybeUploadAnalyticsAsync() { - if (!hasRunBefore) { - logger.trace("First run, not uploading") - return - } + try { + if (!hasRunBefore) { + logger.trace("First run, not uploading") + return + } - if (analyticsDisabledWithEnvVar) { - logger.trace("Analytics disabled with env var, not uploading") - } + if (analyticsDisabledWithEnvVar) { + logger.trace("Analytics disabled with env var, not uploading") + } - if (!analyticsState.enabled) { - logger.trace("Analytics disabled with config file, not uploading") - return - } + if (!analyticsState.enabled) { + logger.trace("Analytics disabled with config file, not uploading") + return + } - if (!uploadConditionsMet) { - logger.trace("Upload conditions not met, not uploading") - return - } + if (!uploadConditionsMet) { + logger.trace("Upload conditions not met, not uploading") + return + } - val report = AnalyticsReport( - uuid = analyticsState.uuid, - freshInstall = !hasRunBefore, - cliVersion = EnvUtils.CLI_VERSION?.toString() ?: "Unknown", - os = EnvUtils.OS_NAME, - osArch = EnvUtils.OS_ARCH, - osVersion = EnvUtils.OS_VERSION, - javaVersion = EnvUtils.getJavaVersion().toString(), - xcodeVersion = IOSEnvUtils.xcodeVersion, - flutterVersion = EnvUtils.getFlutterVersionAndChannel().first, - flutterChannel = EnvUtils.getFlutterVersionAndChannel().second, - androidVersions = AndroidEnvUtils.androidEmulatorSdkVersions, - iosVersions = IOSEnvUtils.simulatorRuntimes, - ) + val report = AnalyticsReport( + uuid = analyticsState.uuid, + freshInstall = !hasRunBefore, + cliVersion = EnvUtils.CLI_VERSION?.toString() ?: "Unknown", + os = EnvUtils.OS_NAME, + osArch = EnvUtils.OS_ARCH, + osVersion = EnvUtils.OS_VERSION, + javaVersion = EnvUtils.getJavaVersion().toString(), + xcodeVersion = IOSEnvUtils.xcodeVersion, + flutterVersion = EnvUtils.getFlutterVersionAndChannel().first, + flutterChannel = EnvUtils.getFlutterVersionAndChannel().second, + androidVersions = AndroidEnvUtils.androidEmulatorSdkVersions, + iosVersions = IOSEnvUtils.simulatorRuntimes, + ) - logger.trace("Will upload analytics report") - logger.trace(report.toString()) + logger.trace("Will upload analytics report") + logger.trace(report.toString()) - try { ApiClient(EnvUtils.BASE_API_URL).sendAnalyticsReport(report) updateAnalyticsState() } catch (e: ConnectException) { - // This is fine. We don't care that much about analytics to bug user about it. + // This is fine. The user probably doesn't have internet connection. + // We don't care that much about analytics to bug user about it. return + } catch (e: Exception) { + // This is less fine. Don't crash, but ask the user to report this. + println("Exception ocurred while uploading analytics. Please report this issue.") + println(e.message) + println(e.stackTraceToString()) } } diff --git a/maestro-cli/src/main/java/maestro/cli/util/IOSEnvUtils.kt b/maestro-cli/src/main/java/maestro/cli/util/IOSEnvUtils.kt index 2a03ba5825..644d914b3a 100644 --- a/maestro-cli/src/main/java/maestro/cli/util/IOSEnvUtils.kt +++ b/maestro-cli/src/main/java/maestro/cli/util/IOSEnvUtils.kt @@ -9,7 +9,7 @@ object IOSEnvUtils { get() { // See also: https://stackoverflow.com/a/78755176/7009800 - val topLevelDirs = Path("/Library/Developer/CoreSimulator/VolumesX").toFile() + val topLevelDirs = Path("/Library/Developer/CoreSimulator/Volumes").toFile() .listFiles() ?.filter { it.exists() } ?: emptyList()