diff --git a/cli/dcoscli/analytics.py b/cli/dcoscli/analytics.py index 9ca1420..fe49a43 100644 --- a/cli/dcoscli/analytics.py +++ b/cli/dcoscli/analytics.py @@ -4,6 +4,7 @@ import sys import uuid import dcoscli +import docopt import requests import rollbar from concurrent.futures import ThreadPoolExecutor @@ -216,6 +217,22 @@ def _rollbar_track_err(conf, err, exit_code): logger.exception(e) +def _command(): + """ Return the subcommand used in this dcos process. + + :returns: subcommand used in this dcos process + :rtype: str + """ + + # avoid circular import + import dcoscli.main + + args = docopt.docopt(dcoscli.main.__doc__, + help=False, + options_first=True) + return args[''] + + def _base_properties(conf=None): """ These properties are sent with every analytics event. @@ -229,7 +246,7 @@ def _base_properties(conf=None): conf = util.get_config() if len(sys.argv) > 1: - cmd = 'dcos ' + sys.argv[1] + cmd = 'dcos ' + _command() full_cmd = 'dcos ' + ' '.join(sys.argv[1:]) else: cmd = 'dcos' diff --git a/cli/tests/data/dcos.toml b/cli/tests/data/dcos.toml index 0e69ae9..cba742f 100644 --- a/cli/tests/data/dcos.toml +++ b/cli/tests/data/dcos.toml @@ -1,7 +1,7 @@ +[package] +cache = "tmp/cache" +sources = [ "https://github.com/mesosphere/universe/archive/version-1.x.zip",] [core] +reporting = false dcos_url = "http://172.17.8.101" email = "test@mail.com" -reporting = false -[package] -sources = [ "https://github.com/mesosphere/universe/archive/version-1.x.zip",] -cache = "tmp/cache" diff --git a/cli/tests/data/missing_params_dcos.toml b/cli/tests/data/missing_params_dcos.toml index b59e72a..228ee08 100644 --- a/cli/tests/data/missing_params_dcos.toml +++ b/cli/tests/data/missing_params_dcos.toml @@ -1,6 +1,6 @@ [core] -email = "test@mail.com" reporting = false +email = "test@mail.com" [package] -sources = [ "git://github.com/mesosphere/universe.git", "https://github.com/mesosphere/universe/archive/master.zip",] cache = "true" +sources = [ "git://github.com/mesosphere/universe.git", "https://github.com/mesosphere/universe/archive/master.zip",]