Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/azure-cli-core/azure/cli/core/intercept_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import json
from datetime import datetime, timedelta
from urllib.parse import quote
from azure.cli.core._config import GLOBAL_CONFIG_DIR
from azure.cli.core._profile import Profile
from azure.cli.core.style import print_styled_text
Expand All @@ -30,10 +31,16 @@
ERASE_IN_LINE = '\x1b[0K'


_SURVEY_URL = "https://go.microsoft.com/fwlink/?linkid=2201856&ID={installation_id}&v={version}&d={day}"
_SURVEY_BASE_URL = "https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR9387UQwLnRLnWswOo2Ri-1UNFRJVEJNMjc1Q0M5WTdXMVVESlI4S1hBMSQlQCN0PWcu"
_SURVEY_LEARN_MORE_URL = "https://go.microsoft.com/fwlink/?linkid=2203309"


def build_survey_url(installation_id, version, day):
"""Build survey URL with hidden context metadata via Customer Voice ctx parameter."""
ctx = json.dumps({"installationId": installation_id, "version": version, "day": str(day)})
return f"{_SURVEY_BASE_URL}&ctx={quote(ctx)}"


def should_prompt(cli):
# should not prompt for automation
if not sys.stderr.isatty():
Expand Down
8 changes: 4 additions & 4 deletions src/azure-cli/azure/cli/command_modules/feedback/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from azure.cli.core.azlogging import _UNKNOWN_COMMAND, _CMD_LOG_LINE_PREFIX
from azure.cli.core.extension._resolve import resolve_project_url_from_index, NoExtensionCandidatesError
from azure.cli.core.intercept_survey import _SURVEY_URL
from azure.cli.core.intercept_survey import build_survey_url
from azure.cli.core.util import get_az_version_string, open_page_in_browser, can_launch_browser, in_cloud_console
from knack.log import get_logger
from knack.prompting import prompt, NoTTYException
Expand Down Expand Up @@ -608,9 +608,9 @@ def handle_survey(cmd):
last_prompt_time = datetime.datetime.strptime(survey_note['last_prompt_time'], '%Y-%m-%dT%H:%M:%S')
use_duration = datetime.datetime.utcnow() - last_prompt_time

url = _SURVEY_URL.format(installation_id=Profile(cli_ctx=cmd.cli_ctx).get_installation_id(),
version=core_version,
day=use_duration.days if use_duration else -1)
url = build_survey_url(installation_id=Profile(cli_ctx=cmd.cli_ctx).get_installation_id(),
version=core_version,
day=use_duration.days if use_duration else -1)
if can_launch_browser() and not in_cloud_console():
open_page_in_browser(url)
print("A new tab of {} has been launched in your browser, thanks for taking the survey!".format(url))
Expand Down
Loading