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
81 changes: 5 additions & 76 deletions Morphic.Client/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
// * Consumer Electronics Association Foundation

using AutoUpdaterDotNET;
using CountlySDK;
using CountlySDK.Entities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -48,7 +46,6 @@ namespace Morphic.Client
using Bar;
using Bar.Data;
using Config;
using CountlySDK.CountlyCommon;
using Dialogs;
using Menu;
using Microsoft.Win32;
Expand Down Expand Up @@ -171,7 +168,6 @@ public class EnabledFeature
public string? scope { get; set; }
}
//
public EnabledFeature? atOnDemand { get; set; }
public EnabledFeature? autorunAfterLogin { get; set; }
public EnabledFeature? checkForUpdates { get; set; }
public EnabledFeature? cloudSettingsTransfer { get; set; }
Expand All @@ -191,7 +187,6 @@ public class MorphicBarConfigSection
//
private struct CommonConfigurationContents
{
public bool AtOnDemandIsEnabled;
public ConfigurableFeatures.AutorunConfigOption? AutorunConfig;
public bool CheckForUpdatesIsEnabled;
public bool CloudSettingsTransferIsEnabled;
Expand All @@ -205,9 +200,6 @@ private async Task<CommonConfigurationContents> GetCommonConfigurationAsync()
// set up default configuration
var result = new CommonConfigurationContents();
//
// at on demand
result.AtOnDemandIsEnabled = true;
//
// autorun
result.AutorunConfig = null;
//
Expand Down Expand Up @@ -301,20 +293,6 @@ private async Task<CommonConfigurationContents> GetCommonConfigurationAsync()
}
}

// capture the at on demand "is enabled" setting
if (deserializedJson.features?.atOnDemand?.enabled is not null)
{
result.AtOnDemandIsEnabled = deserializedJson.features.atOnDemand.enabled.Value;
}
else
{
// NOTE: for version 0 of the config.json file, we set AtOnDemandIsEnabled to FALSE by default
if (deserializedJson.version == 0)
{
result.AtOnDemandIsEnabled = false;
}
}

// capture the check for updates "is enabled" setting
if (deserializedJson.features?.checkForUpdates?.enabled is not null)
{
Expand Down Expand Up @@ -574,21 +552,15 @@ private void ConfigureServices(IServiceCollection services)
services.AddSingleton<Solutions>(s => Solutions.FromFile(s, AppPaths.GetAppFile("solutions.json5")));
}

internal async Task Countly_RecordEventAsync(string Key) {
if (ConfigurableFeatures.TelemetryIsEnabled == true)
{
await Countly.RecordEvent(Key);

_telemetryClient?.EnqueueEvent(Key, null);
}
internal void SuppressTaskbarButtonResurfaceChecks(bool suppress)
{
// OBSERVATION: in the current implementation, the taskbar ("tray") button is owned by the menu control
this.morphicMenu?.SuppressTaskbarButtonResurfaceChecks(suppress);
}

internal async Task Countly_RecordEventAsync(string Key, int Count, Segmentation Segmentation)
{
internal async Task Telemetry_RecordEventAsync(string Key) {
if (ConfigurableFeatures.TelemetryIsEnabled == true)
{
await Countly.RecordEvent(Key, Count, Segmentation);

_telemetryClient?.EnqueueEvent(Key, null);
}
}
Expand Down Expand Up @@ -745,27 +717,6 @@ private TelemetryIdComponents GetOrCreateTelemetryIdComponents()
return new TelemetryIdComponents() { CompositeId = telemetryCompositeId, SiteId = telemetrySiteId, DeviceUuid = telemetryDeviceUuid };
}

private async Task ConfigureCountlyAsync()
{
// TODO: Move metrics related things to own class.

// retrieve the telemetry composite ID for this device; if it doesn't exist then create a new one
var telemetryDeviceCompositeId = this.GetOrCreateTelemetryIdComponents().CompositeId;

IConfigurationSection? section = this.Configuration.GetSection("Countly");
CountlyConfig cc = new CountlyConfig
{
serverUrl = section["ServerUrl"],
appKey = section["AppKey"],
appVersion = BuildInfo.Current.InformationalVersion,
developerProvidedDeviceId = telemetryDeviceCompositeId
};

await Countly.Instance.Init(cc);
await Countly.Instance.SessionBegin();
CountlyBase.IsLoggingEnabled = true;
}

private string PrependSiteIdToTelemetryCompositeId(string value, string telemetrySiteId)
{
var telemetryDeviceUuid = value;
Expand Down Expand Up @@ -947,16 +898,6 @@ internal record SessionTelemetryEventData

#endregion Telemetry

private void RecordedException(Task task)
{
if (task.Exception is Exception e)
{
this.Logger.LogError("exception thrown while countly recording exception: {msg}", e.Message);
throw e;
}
this.Logger.LogDebug("successfully recorded countly exception");
}

void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// TODO: Improve error logging/reporting.
Expand All @@ -967,10 +908,6 @@ void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptio
{
this.Logger.LogError("handled uncaught exception: {msg}", ex.Message);
this.Logger.LogError(ex.StackTrace);

Dictionary<String, String> extraData = new Dictionary<string, string>();
CountlyBase.RecordException(ex.Message, ex.StackTrace, extraData, true)
.ContinueWith(this.RecordedException, TaskScheduler.FromCurrentSynchronizationContext());
}
catch (Exception)
{
Expand Down Expand Up @@ -1088,7 +1025,6 @@ protected override async void OnStartup(StartupEventArgs e)
// NOTE: we currently load this AFTER setting up the logger because the GetCommonConfigurationAsync function logs config file errors to the logger
var commonConfiguration = await this.GetCommonConfigurationAsync();
ConfigurableFeatures.SetFeatures(
atOnDemandIsEnabled: commonConfiguration.AtOnDemandIsEnabled,
autorunConfig: commonConfiguration.AutorunConfig,
checkForUpdatesIsEnabled: commonConfiguration.CheckForUpdatesIsEnabled,
cloudSettingsTransferIsEnabled: commonConfiguration.CloudSettingsTransferIsEnabled,
Expand All @@ -1110,7 +1046,6 @@ protected override async void OnStartup(StartupEventArgs e)

if (ConfigurableFeatures.TelemetryIsEnabled == true)
{
await this.ConfigureCountlyAsync();
await this.ConfigureTelemetryAsync();
}

Expand Down Expand Up @@ -1605,12 +1540,6 @@ protected override async void OnExit(ExitEventArgs e)
}
}
catch { }
//
try
{
await Countly.Instance.SessionEnd();
}
catch { }
}

if (ConfigurableFeatures.ResetSettingsIsEnabled == true)
Expand Down
2 changes: 1 addition & 1 deletion Morphic.Client/Bar/Data/Actions/ApplicationAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ protected override Task<MorphicResult<MorphicUnit, MorphicUnit>> InvokeAsyncImpl
// NOTE: ideally we would change this whole function into an async function (instead of using the Task.FromResult pattern)
Task.Run(async () =>
{
await App.Current.Countly_RecordEventAsync(this.TelemetryEventName!);
await App.Current.Telemetry_RecordEventAsync(this.TelemetryEventName!);
});
}
}
Expand Down
Loading