From 814cd9aadf5798baac5549a16bce644473375941 Mon Sep 17 00:00:00 2001 From: edge-marge <141053702+edge-marge@users.noreply.github.com> Date: Tue, 13 Jan 2026 16:01:21 -0500 Subject: [PATCH 1/2] add analytics --- Editor/Api/AnalyticsApi.cs | 79 ++++++++++++ Editor/Api/AnalyticsApi.cs.meta | 2 + Editor/EdgegapWindowV2.cs | 218 ++++++++++++++++++++++++++++++-- 3 files changed, 289 insertions(+), 10 deletions(-) create mode 100644 Editor/Api/AnalyticsApi.cs create mode 100644 Editor/Api/AnalyticsApi.cs.meta diff --git a/Editor/Api/AnalyticsApi.cs b/Editor/Api/AnalyticsApi.cs new file mode 100644 index 0000000..318cc0c --- /dev/null +++ b/Editor/Api/AnalyticsApi.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using UnityEngine; + +namespace Edgegap.Editor.Api +{ + public class AnalyticsApi + { + private readonly HttpClient _httpClient = new HttpClient(); + private string _url = "https://us.i.posthog.com/i/v0/e/"; + private string _Key = "phc_sjDOXB5OakYZu0h70u4GLcFR7hZ55XfnnDef5xaeDws"; + private string _Event = "Plugin Button Click"; + private string _DistinctId; + + private class AnalyticsPayload + { + [JsonProperty("api_key")] + public string ApiKey { get; set; } + + [JsonProperty("event")] + public string Event { get; set; } + + [JsonProperty("distinct_id")] + public string DistinctId { get; set; } + + [JsonProperty("properties")] + public Dictionary Properties { get; set; } + + public AnalyticsPayload( + string apiKey, + string ev, + string disctinctId, + Dictionary properties + ) + { + this.ApiKey = apiKey; + this.Event = ev; + this.DistinctId = disctinctId; + this.Properties = properties; + } + + public override string ToString() => JsonConvert.SerializeObject(this); + } + + public AnalyticsApi(string distinctId) + { + this._httpClient.BaseAddress = new Uri(_url); + this._httpClient.DefaultRequestHeaders.Accept.Add( + new MediaTypeWithQualityHeaderValue("application/json") + ); + this._DistinctId = distinctId; + } + + public async Task PostAsync(Dictionary properties) + { + AnalyticsPayload payload = new AnalyticsPayload(_Key, _Event, _DistinctId, properties); + StringContent stringContent = new StringContent( + payload.ToString(), + Encoding.UTF8, + "application/json" + ); + + try + { + return await _httpClient.PostAsync(_httpClient.BaseAddress, stringContent); + } + catch (Exception e) + { + Debug.LogError($"Error: {e}"); + throw; + } + } + } +} diff --git a/Editor/Api/AnalyticsApi.cs.meta b/Editor/Api/AnalyticsApi.cs.meta new file mode 100644 index 0000000..c45facf --- /dev/null +++ b/Editor/Api/AnalyticsApi.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f145b77191ba04842a4e0f94261d1c35 \ No newline at end of file diff --git a/Editor/EdgegapWindowV2.cs b/Editor/EdgegapWindowV2.cs index d5b9a2e..90b24cd 100644 --- a/Editor/EdgegapWindowV2.cs +++ b/Editor/EdgegapWindowV2.cs @@ -900,12 +900,21 @@ private async Task checkForUpdates() /// /// "Sign out" btn click /// - private void OnSignOutBtnClickAsync() + private async void OnSignOutBtnClickAsync() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "1. Connect Edgegap Account > Sign out" }, + { "utm_source", "plugin_unity" }, + }; + string distinctId = getDistinctId(); + EditorPrefs.DeleteKey(EdgegapWindowMetadata.API_TOKEN_KEY_STR); EditorPrefs.DeleteKey(EdgegapWindowMetadata.SELECTED_NETCODE_KEY_STR); _apiTokenInput.SetValueWithoutNotify(""); ResetState(); + await analyticsApi.PostAsync(properties); } /// @@ -967,8 +976,16 @@ private async void OnInstallLinuxBtnClick() /// /// Open Unity build settings btn click /// - private void OnOpenBuildParamsBtnClick() + private async void OnOpenBuildParamsBtnClick() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "2. Build Game Server > Edit Settings" }, + { "utm_source", "plugin_unity" }, + }; + await analyticsApi.PostAsync(properties); + #if UNITY_2021_3_OR_NEWER EditorWindow.GetWindow( System.Type.GetType("UnityEditor.BuildPlayerWindow,UnityEditor") @@ -992,6 +1009,23 @@ private void OnFolderNameInputFocusOut(FocusOutEvent evt) /// private void OnBuildServerBtnClick() { + _ = BuildServer(); + } + + private async Task BuildServer(string buttonName = "2. Build Game Server > Build") + { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + }; + + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Build"); + } + try { _serverBuildBtn.SetEnabled(false); @@ -1026,6 +1060,8 @@ private void OnBuildServerBtnClick() else { OnBuildContainerizeUploadSuccess(_serverBuildResultLabel, "Build succeeded."); + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); } _containerizeFoldout.SetValueWithoutNotify(true); @@ -1033,6 +1069,11 @@ private void OnBuildServerBtnClick() } catch (Exception e) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); + Debug.LogError($"OnBuildServerBtnClick Error: {e}"); ShowErrorDialog(e.Message, _serverBuildResultLabel, "Build failed (see logs)."); } @@ -1053,11 +1094,18 @@ private void OnDockerInfoClick() => /// private void OnValidateDockerBtnClick() { - _ = ValidateDockerRequirement(); + _ = ValidateDockerRequirement(true); } - private async Task ValidateDockerRequirement() + private async Task ValidateDockerRequirement(bool runAnalytics) { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "3. Containerize Server > Validate Docker" }, + { "utm_source", "plugin_unity" }, + }; + _validateDockerRequirementsBtn.SetEnabled(false); hideResultLabels(); string error; @@ -1070,6 +1118,14 @@ private async Task ValidateDockerRequirement() catch (Exception e) { error = e.Message; + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + + if (runAnalytics) + { + await analyticsApi.PostAsync(properties); + } } _validateDockerRequirementsBtn.SetEnabled(true); @@ -1097,6 +1153,7 @@ private async Task ValidateDockerRequirement() _dockerRequirementsResultLabel, "There was a problem." ); + return error; } else @@ -1105,6 +1162,12 @@ private async Task ValidateDockerRequirement() _dockerRequirementsResultLabel, "Docker is running." ); + properties.Add("succeeded", true.ToString()); + + if (runAnalytics) + { + await analyticsApi.PostAsync(properties); + } } return null; } @@ -1225,10 +1288,29 @@ private void OnContainerizeBtnClick() _ = ContainerizeServerAsync(); } - private async Task ContainerizeServerAsync() + private async Task ContainerizeServerAsync( + string buttonName = "3. Containerize Server > Containerize" + ) { - if (!string.IsNullOrEmpty(await ValidateDockerRequirement())) + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + { "docker_params", _optionalDockerParamsInput.value }, + }; + + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Containerize"); + } + + if (!string.IsNullOrEmpty(await ValidateDockerRequirement(false))) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", "Docker validation failed"); + await analyticsApi.PostAsync(properties); + return; } try @@ -1270,6 +1352,8 @@ private async Task ContainerizeServerAsync() _containerizeImageTagInput.value == _containerizeImageTagInputDefault ? nowUTC : _containerizeImageTagInput.value; + properties.Add("image_name", imageName); + properties.Add("image_tag", tag); await EdgegapBuildUtils.RunCommand_DockerBuild( dockerfilePath, @@ -1300,9 +1384,17 @@ await EdgegapBuildUtils.RunCommand_DockerBuild( { _localTestImageShowDropdownBtn.SetEnabled(true); } + + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); } catch (Exception e) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); + Debug.LogError($"Containerization Error: {e}"); ShowErrorDialog( e.Message, @@ -1392,6 +1484,15 @@ private bool CheckFilledLocalTestInputs() private async void OnLocalTestDeployClick() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "4. Test Locally > Deploy" }, + { "utm_source", "plugin_unity" }, + { "server_image", _localTestImageInput.value }, + { "docker_params", _localTestDockerRunInput.value }, + }; + try { hideResultLabels(); @@ -1429,6 +1530,8 @@ private async void OnLocalTestDeployClick() true ); _createAppFoldout.SetValueWithoutNotify(true); + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); } catch (Exception e) { @@ -1444,6 +1547,10 @@ private async void OnLocalTestDeployClick() labelMsg = "There was an issue while deploying. See more in Docker Desktop or Docker CLI."; Debug.LogError($"OnLocalTestDeploy Error: {e}"); + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); } OnLocalDeploymentResult(labelMsg, false); @@ -1452,6 +1559,15 @@ private async void OnLocalTestDeployClick() private async void OnLocalTestTerminateCLick() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "4. Test Locally > Terminate" }, + { "utm_source", "plugin_unity" }, + { "server_image", _localTestImageInput.value }, + { "docker_params", _localTestDockerRunInput.value }, + }; + try { hideResultLabels(); @@ -1463,6 +1579,8 @@ private async void OnLocalTestTerminateCLick() OnLocalDeploymentResult("Container terminated successfully.", true); _createAppFoldout.SetValueWithoutNotify(true); + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); } catch (Exception e) { @@ -1477,6 +1595,10 @@ private async void OnLocalTestTerminateCLick() "There was an issue while terminating. See more in Docker Desktop or Docker CLI.", false ); + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); } } } @@ -1593,8 +1715,25 @@ private void OnUploadImageCreateAppBtnClick() _ = UploadImageCreateAppAsync(); } - private async Task UploadImageCreateAppAsync() + private async Task UploadImageCreateAppAsync( + string buttonName = "5. Upload to Edgegap > Upload and Create App" + ) { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + { "app_name", _createAppNameInput.value }, + { "image_name", _serverImageNameInput.value }, + { "image_tag", _serverImageTagInput.value }, + }; + + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Upload and Create App"); + } + try { _uploadImageCreateAppBtn.SetEnabled(false); @@ -1634,6 +1773,9 @@ private async Task UploadImageCreateAppAsync() throw new Exception("Unable to push docker image to registry (see logs)."); } + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); + ShowWorkInProgress("Create Application", "Updating server info on Edgegap"); if (IsLogLevelDebug) @@ -1693,6 +1835,11 @@ private async Task UploadImageCreateAppAsync() } catch (Exception e) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); + if ( e.Message.Contains("Docker authorization failed") || e.Message.Contains("Unable to push docker image") @@ -1740,7 +1887,7 @@ private async void OnRebuildFromSrcBtnClickAsync() hideResultLabels(); //Build - OnBuildServerBtnClick(); + await BuildServer("5. Upload to Edgegap > Rebuild from Source"); if (_serverBuildResultLabel.text.Contains(EdgegapWindowMetadata.FAIL_COLOR_HEX)) { @@ -1754,7 +1901,7 @@ private async void OnRebuildFromSrcBtnClickAsync() _containerizeImageTagInput.SetValueWithoutNotify(_containerizeImageTagInputDefault); } - await ContainerizeServerAsync(); + await ContainerizeServerAsync("5. Upload to Edgegap > Rebuild from Source"); if ( _containerizeServerResultLabel.text.Contains(EdgegapWindowMetadata.FAIL_COLOR_HEX) @@ -1768,7 +1915,7 @@ private async void OnRebuildFromSrcBtnClickAsync() } //Upload - await UploadImageCreateAppAsync(); + await UploadImageCreateAppAsync("5. Upload to Edgegap > Rebuild from Source"); } #endregion @@ -1930,6 +2077,15 @@ private async void OnDeploymentCreateBtnClick() /// private async Task CreateDeploymentStartServer() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "6. Deploy > Start" }, + { "utm_source", "plugin_unity" }, + { "app_name", _deployAppNameInput.value }, + { "app_version", _deployAppVersionInput.value }, + }; + if (IsLogLevelDebug) Debug.Log("createDeploymentStartServerAsync"); @@ -1972,6 +2128,10 @@ private async Task CreateDeploymentStartServer() await deployApi.CreateDeploymentAsync(createDeploymentReq); if (!createDeploymentResponse.IsResultCode202) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", createDeploymentResponse.Error.ErrorMessage); + await analyticsApi.PostAsync(properties); + OnCreateDeploymentStartServerFail(createDeploymentResponse.Error.ErrorMessage); return; } @@ -2002,9 +2162,15 @@ await deployApi.AwaitReadyStatusAsync( EdgegapWindowMetadata.StatusColors.Success ); _deployResultLabel.style.display = DisplayStyle.Flex; + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); } else { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", getDeploymentStatusResponse.Error.ErrorMessage); + await analyticsApi.PostAsync(properties); + OnCreateDeploymentStartServerFail(getDeploymentStatusResponse.Error.ErrorMessage); } } @@ -2032,6 +2198,15 @@ private void OnCreateDeploymentStartServerFail(string message = null) /// private async void OnStopLastDeployClick() { + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "6. Deploy > Stop" }, + { "utm_source", "plugin_unity" }, + { "app_name", _deployAppNameInput.value }, + { "app_version", _deployAppVersionInput.value }, + }; + try { hideResultLabels(); @@ -2069,6 +2244,10 @@ private async void OnStopLastDeployClick() if (!stopDeploymentResponse.IsResultCode200) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", stopDeploymentResponse.Error.ErrorMessage); + await analyticsApi.PostAsync(properties); + OnGetStopLastDeploymentResult(stopDeploymentResponse.Error.ErrorMessage, false); return; } @@ -2085,10 +2264,17 @@ private async void OnStopLastDeployClick() //Process response if (!stopDeploymentResponse.IsResultCode410) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", stopDeploymentResponse.Error.ErrorMessage); + await analyticsApi.PostAsync(properties); + OnGetStopLastDeploymentResult(stopDeploymentResponse.Error.ErrorMessage, false); } else { + properties.Add("succeeded", true.ToString()); + await analyticsApi.PostAsync(properties); + OnGetStopLastDeploymentResult("Deployment stopped successfully", true); } @@ -2096,6 +2282,11 @@ private async void OnStopLastDeployClick() } catch (Exception e) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); + await analyticsApi.PostAsync(properties); + OnGetStopLastDeploymentResult(e.Message, false); OpenEdgegapURL(EdgegapWindowMetadata.EDGEGAP_DEPLOY_APP_URL); } @@ -2559,6 +2750,13 @@ public static string Base64Decode(string base64EncodedText) return Encoding.UTF8.GetString(base64Bytes); } #endregion + + #region Utility / Analytics + private AnalyticsApi getAnalyticsApi() => new AnalyticsApi(getDistinctId()); + + //TODO - replace with hash + private string getDistinctId() => "marjorie.dudemaine@edgegap.com"; + #endregion } } From 65d89fc4f5c922779d21bfdfe126d781e276b4ca Mon Sep 17 00:00:00 2001 From: edge-marge <141053702+edge-marge@users.noreply.github.com> Date: Mon, 19 Jan 2026 11:43:40 -0500 Subject: [PATCH 2/2] refactor analytics code --- Editor/EdgegapWindowV2.cs | 111 ++++++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 39 deletions(-) diff --git a/Editor/EdgegapWindowV2.cs b/Editor/EdgegapWindowV2.cs index 90b24cd..3d8bada 100644 --- a/Editor/EdgegapWindowV2.cs +++ b/Editor/EdgegapWindowV2.cs @@ -908,13 +908,12 @@ private async void OnSignOutBtnClickAsync() { "button_name", "1. Connect Edgegap Account > Sign out" }, { "utm_source", "plugin_unity" }, }; - string distinctId = getDistinctId(); + await analyticsApi.PostAsync(properties); EditorPrefs.DeleteKey(EdgegapWindowMetadata.API_TOKEN_KEY_STR); EditorPrefs.DeleteKey(EdgegapWindowMetadata.SELECTED_NETCODE_KEY_STR); _apiTokenInput.SetValueWithoutNotify(""); ResetState(); - await analyticsApi.PostAsync(properties); } /// @@ -1020,7 +1019,6 @@ private async Task BuildServer(string buttonName = "2. Build Game Server > Build { "button_name", buttonName }, { "utm_source", "plugin_unity" }, }; - if (buttonName.Contains("Rebuild from Source")) { properties.Add("rebuild_step", "Build"); @@ -1056,10 +1054,15 @@ private async Task BuildServer(string buttonName = "2. Build Game Server > Build if (buildResult.summary.result != BuildResult.Succeeded) { Debug.LogWarning(buildResult.summary.result.ToString()); + + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", buildResult.summary.result.ToString()); + await analyticsApi.PostAsync(properties); } else { OnBuildContainerizeUploadSuccess(_serverBuildResultLabel, "Build succeeded."); + properties.Add("succeeded", true.ToString()); await analyticsApi.PostAsync(properties); } @@ -1118,12 +1121,12 @@ private async Task ValidateDockerRequirement(bool runAnalytics) catch (Exception e) { error = e.Message; - properties.Add("succeeded", false.ToString()); - properties.Add("error_message", e.Message); - properties.Add("stack_trace", e.StackTrace); - + if (runAnalytics) { + properties.Add("succeeded", false.ToString()); + properties.Add("error_message", e.Message); + properties.Add("stack_trace", e.StackTrace); await analyticsApi.PostAsync(properties); } } @@ -1162,10 +1165,10 @@ private async Task ValidateDockerRequirement(bool runAnalytics) _dockerRequirementsResultLabel, "Docker is running." ); - properties.Add("succeeded", true.ToString()); if (runAnalytics) { + properties.Add("succeeded", true.ToString()); await analyticsApi.PostAsync(properties); } } @@ -1293,22 +1296,20 @@ private async Task ContainerizeServerAsync( ) { AnalyticsApi analyticsApi = getAnalyticsApi(); - Dictionary properties = new Dictionary() - { - { "button_name", buttonName }, - { "utm_source", "plugin_unity" }, - { "docker_params", _optionalDockerParamsInput.value }, - }; - - if (buttonName.Contains("Rebuild from Source")) - { - properties.Add("rebuild_step", "Containerize"); - } - + if (!string.IsNullOrEmpty(await ValidateDockerRequirement(false))) { - properties.Add("succeeded", false.ToString()); - properties.Add("error_message", "Docker validation failed"); + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + { "succeeded", false.ToString() }, + { "error_message", "Docker validation failed"} + }; + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Containerize"); + } await analyticsApi.PostAsync(properties); return; @@ -1352,8 +1353,6 @@ private async Task ContainerizeServerAsync( _containerizeImageTagInput.value == _containerizeImageTagInputDefault ? nowUTC : _containerizeImageTagInput.value; - properties.Add("image_name", imageName); - properties.Add("image_tag", tag); await EdgegapBuildUtils.RunCommand_DockerBuild( dockerfilePath, @@ -1385,14 +1384,44 @@ await EdgegapBuildUtils.RunCommand_DockerBuild( _localTestImageShowDropdownBtn.SetEnabled(true); } - properties.Add("succeeded", true.ToString()); + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + { "docker_params", _optionalDockerParamsInput.value }, + { "image_name", imageName }, + { "image_tag", tag }, + { "succeeded", true.ToString() } + }; + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Containerize"); + } await analyticsApi.PostAsync(properties); } catch (Exception e) { - properties.Add("succeeded", false.ToString()); - properties.Add("error_message", e.Message); - properties.Add("stack_trace", e.StackTrace); + string imageName = Tokenize(_containerizeImageNameInput.value); + string tag = + _containerizeImageTagInput.value == _containerizeImageTagInputDefault + ? nowUTC + : _containerizeImageTagInput.value; + + Dictionary properties = new Dictionary() + { + { "button_name", buttonName }, + { "utm_source", "plugin_unity" }, + { "docker_params", _optionalDockerParamsInput.value }, + { "image_name", imageName }, + { "image_tag", tag }, + { "succeeded", false.ToString() }, + { "error_message", e.Message }, + { "stack_trace", e.StackTrace } + }; + if (buttonName.Contains("Rebuild from Source")) + { + properties.Add("rebuild_step", "Containerize"); + } await analyticsApi.PostAsync(properties); Debug.LogError($"Containerization Error: {e}"); @@ -1530,6 +1559,7 @@ private async void OnLocalTestDeployClick() true ); _createAppFoldout.SetValueWithoutNotify(true); + properties.Add("succeeded", true.ToString()); await analyticsApi.PostAsync(properties); } @@ -1547,6 +1577,7 @@ private async void OnLocalTestDeployClick() labelMsg = "There was an issue while deploying. See more in Docker Desktop or Docker CLI."; Debug.LogError($"OnLocalTestDeploy Error: {e}"); + properties.Add("succeeded", false.ToString()); properties.Add("error_message", e.Message); properties.Add("stack_trace", e.StackTrace); @@ -1577,8 +1608,8 @@ private async void OnLocalTestTerminateCLick() await EdgegapBuildUtils.RunCommand_DockerStop(); OnLocalDeploymentResult("Container terminated successfully.", true); - _createAppFoldout.SetValueWithoutNotify(true); + properties.Add("succeeded", true.ToString()); await analyticsApi.PostAsync(properties); } @@ -1595,6 +1626,7 @@ private async void OnLocalTestTerminateCLick() "There was an issue while terminating. See more in Docker Desktop or Docker CLI.", false ); + properties.Add("succeeded", false.ToString()); properties.Add("error_message", e.Message); properties.Add("stack_trace", e.StackTrace); @@ -1728,7 +1760,6 @@ private async Task UploadImageCreateAppAsync( { "image_name", _serverImageNameInput.value }, { "image_tag", _serverImageTagInput.value }, }; - if (buttonName.Contains("Rebuild from Source")) { properties.Add("rebuild_step", "Upload and Create App"); @@ -2077,15 +2108,6 @@ private async void OnDeploymentCreateBtnClick() /// private async Task CreateDeploymentStartServer() { - AnalyticsApi analyticsApi = getAnalyticsApi(); - Dictionary properties = new Dictionary() - { - { "button_name", "6. Deploy > Start" }, - { "utm_source", "plugin_unity" }, - { "app_name", _deployAppNameInput.value }, - { "app_version", _deployAppVersionInput.value }, - }; - if (IsLogLevelDebug) Debug.Log("createDeploymentStartServerAsync"); @@ -2126,6 +2148,16 @@ private async Task CreateDeploymentStartServer() // Request to deploy (it won't be active, yet) => EdgegapHttpResult createDeploymentResponse = await deployApi.CreateDeploymentAsync(createDeploymentReq); + + AnalyticsApi analyticsApi = getAnalyticsApi(); + Dictionary properties = new Dictionary() + { + { "button_name", "6. Deploy > Start" }, + { "utm_source", "plugin_unity" }, + { "app_name", _deployAppNameInput.value }, + { "app_version", _deployAppVersionInput.value }, + }; + if (!createDeploymentResponse.IsResultCode202) { properties.Add("succeeded", false.ToString()); @@ -2162,6 +2194,7 @@ await deployApi.AwaitReadyStatusAsync( EdgegapWindowMetadata.StatusColors.Success ); _deployResultLabel.style.display = DisplayStyle.Flex; + properties.Add("succeeded", true.ToString()); await analyticsApi.PostAsync(properties); }