Skip to content

Commit

Permalink
feat: Adds Insights Notification
Browse files Browse the repository at this point in the history
Allows users to disable insights notification based on the new Environment Variable
  • Loading branch information
luistak committed Jan 13, 2025
1 parent 183c126 commit da8e844
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions maestro-cli/src/main/java/maestro/cli/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import maestro.cli.command.StartDeviceCommand
import maestro.cli.command.StudioCommand
import maestro.cli.command.TestCommand
import maestro.cli.command.UploadCommand
import maestro.cli.insights.Insights
import maestro.cli.update.Updates
import maestro.cli.util.ChangeLogUtils
import maestro.cli.util.ErrorReporter
Expand Down Expand Up @@ -144,6 +145,8 @@ fun main(args: Array<String>) {

DebugLogStore.finalizeRun()

Insights.maybeNotifyInsights()

val newVersion = Updates.checkForUpdates()
if (newVersion != null) {
Updates.fetchChangelogAsync()
Expand Down
31 changes: 31 additions & 0 deletions maestro-cli/src/main/java/maestro/cli/insights/Insights.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package maestro.cli.insights

import maestro.cli.view.box

/**
* The Insights helper for Maestro CLI.
* - Uses MAESTRO_CLI_INSIGHTS_NOTIFICATION_DISABLED env var to disable insights notifications
*/
object Insights {

private const val DISABLE_INSIGHTS_ENV_VAR = "MAESTRO_CLI_INSIGHTS_NOTIFICATION_DISABLED"
private val disabled: Boolean
get() = System.getenv(DISABLE_INSIGHTS_ENV_VAR) == "true"

fun maybeNotifyInsights() {
if (disabled) return

println()
println(
listOf(
"Tryout our new Analyze with Ai feature.\n",
"See what's new:",
// TODO: Add final link to analyze with Ai Docs
"https://github.com/mobile-dev-inc/maestro/blob/main/CHANGELOG.md#blaaa",
"Analyze command:",
"maestro analyze android-flow.yaml | bash\n",
"To disable this notification, set $DISABLE_INSIGHTS_ENV_VAR environment variable to \"true\" before running Maestro."
).joinToString("\n").box()
)
}
}

0 comments on commit da8e844

Please sign in to comment.