Skip to content

Commit

Permalink
Merge pull request Azure#10 from daniv-msft/snehapar/telemetry
Browse files Browse the repository at this point in the history
Fix for telemetry
  • Loading branch information
daniv-msft authored May 12, 2023
2 parents dddbc48 + b33eaae commit 3a90ea5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4407,8 +4407,6 @@ def patch_run_interactive(cmd, resource_group_name=None, managed_env=None, show_
if without_unpatchable_results == []:
return
user_input = input("Do you want to apply all the patch or specify by id? (y/n/id)\n")
if user_input != "n":
telemetry_core.add_extension_event('containerapp', {'Context.Default.AzureCLI.PatchRun': "Ran patch run command"})
return patch_apply(cmd, patchable_check_results, user_input, pack_exec_path)


Expand All @@ -4434,6 +4432,8 @@ def patch_run(cmd, resource_group_name=None, managed_env=None, show_all=False):
def patch_apply(cmd, patch_check_list, method, pack_exec_path):
results = []
m = method.strip().lower()
# Track number of times patches were applied successfully.
patch_run_count = 0
if m == "y":
for patch_check in patch_check_list:
if patch_check["id"]:
Expand All @@ -4445,6 +4445,8 @@ def patch_apply(cmd, patch_check_list, method, pack_exec_path):
patch_check["targetImageName"],
patch_check["newRunImage"],
pack_exec_path))
# Increment patch_run_count with every successful patch.
patch_run_count+=1
elif m == "n":
print("No patch applied.")
return
Expand All @@ -4459,9 +4461,19 @@ def patch_apply(cmd, patch_check_list, method, pack_exec_path):
patch_check["targetImageName"],
patch_check["newRunImage"],
pack_exec_path))
patch_run_properties = {
'Context.Default.AzureCLI.PatchRunUserResponse':method,
'Context.Default.AzureCLI.PatchRunCount':1
}
telemetry_core.add_extension_event('containerapp', patch_run_properties)
return
print("Invalid patch method or id.")
return
patch_run_properties = {
'Context.Default.AzureCLI.UserResponse':"yes",
'Context.Default.AzureCLI.PatchRunCount':patch_run_count
}
telemetry_core.add_extension_event('containerapp', patch_run_properties)
return results


Expand Down

0 comments on commit 3a90ea5

Please sign in to comment.