diff --git a/Plugins/Wox.Plugin.Calculator/plugin.json b/Plugins/Wox.Plugin.Calculator/plugin.json index 925099548..68fc32dd3 100644 --- a/Plugins/Wox.Plugin.Calculator/plugin.json +++ b/Plugins/Wox.Plugin.Calculator/plugin.json @@ -6,7 +6,7 @@ "Author":"cxfksword", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Caculator.dll", "IcoPath":"Images\\calculator.png" } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Color/plugin.json b/Plugins/Wox.Plugin.Color/plugin.json index cd8a285d9..117ac793f 100644 --- a/Plugins/Wox.Plugin.Color/plugin.json +++ b/Plugins/Wox.Plugin.Color/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Color.dll", "IcoPath":"Images\\color.png" } diff --git a/Plugins/Wox.Plugin.ControlPanel/plugin.json b/Plugins/Wox.Plugin.ControlPanel/plugin.json index 7dc455209..260379b81 100644 --- a/Plugins/Wox.Plugin.ControlPanel/plugin.json +++ b/Plugins/Wox.Plugin.ControlPanel/plugin.json @@ -6,7 +6,7 @@ "Author":"CoenraadS", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.ControlPanel.dll", "IcoPath":"Images\\ControlPanel.png" } diff --git a/Plugins/Wox.Plugin.Folder/plugin.json b/Plugins/Wox.Plugin.Folder/plugin.json index 1d9ac7482..80b258633 100644 --- a/Plugins/Wox.Plugin.Folder/plugin.json +++ b/Plugins/Wox.Plugin.Folder/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Folder.dll", "IcoPath":"Images\\folder.png" } diff --git a/Plugins/Wox.Plugin.PluginIndicator/plugin.json b/Plugins/Wox.Plugin.PluginIndicator/plugin.json index a817248e2..92ce9c321 100644 --- a/Plugins/Wox.Plugin.PluginIndicator/plugin.json +++ b/Plugins/Wox.Plugin.PluginIndicator/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.PluginIndicator.dll", "IcoPath":"Images\\work.png" } diff --git a/Plugins/Wox.Plugin.PluginManagement/plugin.json b/Plugins/Wox.Plugin.PluginManagement/plugin.json index d2d219fc4..c19c3f012 100644 --- a/Plugins/Wox.Plugin.PluginManagement/plugin.json +++ b/Plugins/Wox.Plugin.PluginManagement/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.PluginManagement.dll", "IcoPath":"Images\\plugin.png" } diff --git a/Plugins/Wox.Plugin.Program/Main.cs b/Plugins/Wox.Plugin.Program/Main.cs index 0134b3aa6..c01cd8dbe 100644 --- a/Plugins/Wox.Plugin.Program/Main.cs +++ b/Plugins/Wox.Plugin.Program/Main.cs @@ -56,6 +56,7 @@ public void Save() public List Query(Query query) { + if (_updateSource != null && !_updateSource.IsCancellationRequested) { _updateSource.Cancel(); @@ -99,7 +100,8 @@ public List Query(Query query) if (token.IsCancellationRequested) { return new List(); } OrderedParallelQuery sorted = resultRaw.AsParallel().OrderByDescending(r => r.Score); List results = new List(); - foreach (Result r in sorted) { + foreach (Result r in sorted) + { if (token.IsCancellationRequested) { return new List(); } var ignored = _settings.IgnoredSequence.Any(entry => { @@ -137,6 +139,13 @@ public void Init(PluginInitContext context) }); } + public void InitSync(PluginInitContext context) + { + _context = context; + loadSettings(); + IndexPrograms(); + } + public void loadSettings() { _settingsStorage = new PluginJsonStorage(); diff --git a/Plugins/Wox.Plugin.Program/plugin.json b/Plugins/Wox.Plugin.Program/plugin.json index 09389080c..07c21b07c 100644 --- a/Plugins/Wox.Plugin.Program/plugin.json +++ b/Plugins/Wox.Plugin.Program/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Program.dll", "IcoPath":"Images\\program.png" } diff --git a/Plugins/Wox.Plugin.Shell/plugin.json b/Plugins/Wox.Plugin.Shell/plugin.json index 4599bdcd0..9d4a10a5d 100644 --- a/Plugins/Wox.Plugin.Shell/plugin.json +++ b/Plugins/Wox.Plugin.Shell/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Shell.dll", "IcoPath":"Images\\shell.png" } diff --git a/Plugins/Wox.Plugin.Sys/plugin.json b/Plugins/Wox.Plugin.Sys/plugin.json index 372294cdd..4135c686d 100644 --- a/Plugins/Wox.Plugin.Sys/plugin.json +++ b/Plugins/Wox.Plugin.Sys/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Sys.dll", "IcoPath":"Images\\lock.png" } diff --git a/Plugins/Wox.Plugin.Url/plugin.json b/Plugins/Wox.Plugin.Url/plugin.json index f0048014c..7da5e2e56 100644 --- a/Plugins/Wox.Plugin.Url/plugin.json +++ b/Plugins/Wox.Plugin.Url/plugin.json @@ -6,7 +6,7 @@ "Author":"Wox", "Version":"1.0.0", "Language":"csharp", - "Website":"http://www.wox.one/plugin", + "Website":"https://github.com/Wox-launcher/Wox", "ExecuteFileName":"Wox.Plugin.Url.dll", "IcoPath":"Images\\url.png" } diff --git a/Plugins/Wox.Plugin.WebSearch/plugin.json b/Plugins/Wox.Plugin.WebSearch/plugin.json index b8b5e51b3..6e9dd5de4 100644 --- a/Plugins/Wox.Plugin.WebSearch/plugin.json +++ b/Plugins/Wox.Plugin.WebSearch/plugin.json @@ -28,7 +28,7 @@ "Author": "Wox", "Version": "1.0.0", "Language": "csharp", - "Website": "http://www.wox.one/plugin", + "Website": "https://github.com/Wox-launcher/Wox", "ExecuteFileName": "Wox.Plugin.WebSearch.dll", "IcoPath": "Images\\web_search.png" } diff --git a/Wox.Core/Plugin/PluginConfig.cs b/Wox.Core/Plugin/PluginConfig.cs index eb75b8e7a..0fab990ed 100644 --- a/Wox.Core/Plugin/PluginConfig.cs +++ b/Wox.Core/Plugin/PluginConfig.cs @@ -79,6 +79,8 @@ private static PluginMetadata GetPluginMetadata(string pluginDirectory) } catch (Exception e) { + e.Data.Add(nameof(configPath), configPath); + e.Data.Add(nameof(pluginDirectory), pluginDirectory); Logger.WoxError($"invalid json for config <{configPath}>", e); return null; } diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index d790d1109..ce40d1e70 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -123,6 +123,9 @@ public static void InitializePlugins(IPublicAPI api) } catch (Exception e) { + e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); + e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); + e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); Logger.WoxError($"Fail to Init plugin: {pair.Metadata.Name}", e); pair.Metadata.Disabled = true; failedPlugins.Enqueue(pair); @@ -186,6 +189,9 @@ public static List QueryForPlugin(PluginPair pair, Query query) } catch (Exception e) { + e.Data.Add(nameof(pair.Metadata.ID), pair.Metadata.ID); + e.Data.Add(nameof(pair.Metadata.Name), pair.Metadata.Name); + e.Data.Add(nameof(pair.Metadata.Website), pair.Metadata.Website); Logger.WoxError($"Exception for plugin <{pair.Metadata.Name}> when query <{query}>", e); return new List(); } diff --git a/Wox.Core/Plugin/PluginsLoader.cs b/Wox.Core/Plugin/PluginsLoader.cs index 694a8c42c..5f1233a95 100644 --- a/Wox.Core/Plugin/PluginsLoader.cs +++ b/Wox.Core/Plugin/PluginsLoader.cs @@ -52,6 +52,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (Exception e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Couldn't load assembly for {metadata.Name}", e); return; } @@ -63,6 +66,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (InvalidOperationException e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Can't find class implement IPlugin for <{metadata.Name}>", e); return; } @@ -73,6 +79,9 @@ public static IEnumerable CSharpPlugins(List source) } catch (Exception e) { + e.Data.Add(nameof(metadata.ID), metadata.ID); + e.Data.Add(nameof(metadata.Name), metadata.Name); + e.Data.Add(nameof(metadata.Website), metadata.Website); Logger.WoxError($"Can't create instance for <{metadata.Name}>", e); return; } diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index 3545629d3..582e5a3dd 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -43,7 +43,7 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Check your connection and proxy settings to api.github.com.", e); + Logger.WoxError($"Check your connection and proxy settings to api.github.com. {e.Message}"); updateManager.Dispose(); return; } @@ -67,7 +67,7 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com.", e); + Logger.WoxError($"Check your connection and proxy settings to github-cloud.s3.amazonaws.com. {e.Message}"); updateManager.Dispose(); return; } @@ -86,11 +86,11 @@ public async Task UpdateApp(bool silentIfLatestVersion = true, bool updateToPrer } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) { - Logger.WoxError($"Please check your connection and proxy settings to api.github.com.", e); + Logger.WoxError($"Please check your connection and proxy settings {e.Message}"); } catch (Exception e) { - Logger.WoxError($"cannot check update", e); + Logger.WoxError($"cannot check update {e.Message}"); } } diff --git a/Wox.Infrastructure/Exception/ExceptionFormatter.cs b/Wox.Infrastructure/Exception/ExceptionFormatter.cs index 189f053d1..904be0770 100644 --- a/Wox.Infrastructure/Exception/ExceptionFormatter.cs +++ b/Wox.Infrastructure/Exception/ExceptionFormatter.cs @@ -3,6 +3,8 @@ using System.Globalization; using System.Linq; using System.Text; +using System.Threading; +using System.Windows; using System.Xml; using Microsoft.Win32; @@ -10,6 +12,13 @@ namespace Wox.Infrastructure.Exception { public class ExceptionFormatter { + private static string _systemLanguage; + private static string _woxLanguage; + public static void Initialize(string systemLanguage, string woxLanguage) + { + _systemLanguage = systemLanguage; + _woxLanguage = woxLanguage; + } public static string FormattedException(System.Exception ex) { return FormattedAllExceptions(ex).ToString(); @@ -135,7 +144,10 @@ public static string RuntimeInfo() sb.AppendLine($"* Timestamp: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); sb.AppendLine($"* Wox version: {Constant.Version}"); sb.AppendLine($"* OS Version: {Environment.OSVersion.VersionString}"); - sb.AppendLine($"* x64: {Environment.Is64BitOperatingSystem}"); + sb.AppendLine($"* x64 OS: {Environment.Is64BitOperatingSystem}"); + sb.AppendLine($"* x64 Process: {Environment.Is64BitProcess}"); + sb.AppendLine($"* System Language: {_systemLanguage}"); + sb.AppendLine($"* Wox Language: {_woxLanguage}"); sb.AppendLine($"* CLR Version: {Environment.Version}"); sb.AppendLine($"* Installed .NET Framework: "); foreach (var result in GetFrameworkVersionFromRegistry()) @@ -156,9 +168,11 @@ public static string SDKInfo() return sb.ToString(); } - public static string ExceptionWithRuntimeInfo(System.Exception ex) + public static string ExceptionWithRuntimeInfo(System.Exception ex, string id) { StringBuilder sb = new StringBuilder(); + sb.Append("Error id: "); + sb.AppendLine(id); var formatted = FormattedAllExceptions(ex); sb.Append(formatted); var info = RuntimeInfoFull(); diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index 90f6406f4..7c3fcf0c3 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -2,10 +2,10 @@ using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; -using Mindscape.Raygun4Net; using NLog; using NLog.Config; using NLog.Targets; +using Sentry; using Wox.Infrastructure.Exception; using Wox.Infrastructure.UserSettings; @@ -14,9 +14,10 @@ namespace Wox.Infrastructure.Logger public static class Log { public const string DirectoryName = "Logs"; - private static RaygunClient _raygunClient = new RaygunClient("LG5MX0YYMCpCN2AtD0fdZw"); public static string CurrentLogDirectory { get; } + private static string _woxLanguage = "not set"; + static Log() { CurrentLogDirectory = Path.Combine(DataLocation.DataDirectory(), DirectoryName, Constant.Version); @@ -74,10 +75,25 @@ public static void WoxError(this NLog.Logger logger, string message, System.Exce { Debug.WriteLine($"ERROR|{logger.Name}|{methodName}|{message}"); logger.Error($"{methodName}|{message}|{ExceptionFormatter.FormattedException(exception)}"); - _raygunClient.Send(exception); + SendException(exception); #if DEBUG throw exception; #endif } + + public static void updateSettingsInfo(string woxLanguage) + { + _woxLanguage = woxLanguage; + + SentrySdk.ConfigureScope(scope => + { + scope.SetTag("woxLanguage", _woxLanguage); + }); + } + + public static void SendException(System.Exception exception) + { + SentrySdk.CaptureException(exception); + } } } \ No newline at end of file diff --git a/Wox.Infrastructure/UserSettings/Settings.cs b/Wox.Infrastructure/UserSettings/Settings.cs index 68b27a412..6423e65aa 100644 --- a/Wox.Infrastructure/UserSettings/Settings.cs +++ b/Wox.Infrastructure/UserSettings/Settings.cs @@ -20,10 +20,14 @@ public static void Save() } private static WoxJsonStorage _storage = new WoxJsonStorage(); - private static Settings _instance = _storage.Load(); - public static Settings Instance => _instance; + public static Settings Instance; - #endregion + public static void Initialize() + { + Instance = _storage.Load(); + } + + #endregion public string Hotkey { get; set; } = "Alt + Space"; public string Language { get; set; } = "en"; diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 705cbac78..eb53f8999 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -91,9 +91,6 @@ 1.1.4 - - 5.10.2 - 9.0.1 @@ -103,6 +100,9 @@ 4.7.0 + + 2.1.1 + 4.0.0 diff --git a/Wox.Plugin/Feature.cs b/Wox.Plugin/Feature.cs index 6d1aa37fd..54f493634 100644 --- a/Wox.Plugin/Feature.cs +++ b/Wox.Plugin/Feature.cs @@ -11,10 +11,10 @@ public interface IContextMenu : IFeatures List LoadContextMenus(Result selectedResult); } - [Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.3.0")] + [Obsolete("If a plugin has a action keyword, then it is exclusive. This interface will be remove in v1.4.0")] public interface IExclusiveQuery : IFeatures { - [Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.3.0")] + [Obsolete("If a plugin has a action keyword, then it is exclusive. This method will be remove in v1.4.0")] bool IsExclusiveQuery(Query query); } diff --git a/Wox.Plugin/Features/IContextMenu.cs b/Wox.Plugin/Features/IContextMenu.cs index f30b66abf..8c827fe1a 100644 --- a/Wox.Plugin/Features/IContextMenu.cs +++ b/Wox.Plugin/Features/IContextMenu.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IContextMenu instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IContextMenu { } } \ No newline at end of file diff --git a/Wox.Plugin/Features/IExclusiveQuery.cs b/Wox.Plugin/Features/IExclusiveQuery.cs index a43303350..2e0af6584 100644 --- a/Wox.Plugin/Features/IExclusiveQuery.cs +++ b/Wox.Plugin/Features/IExclusiveQuery.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IInstantQuery instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IExclusiveQuery { } } diff --git a/Wox.Plugin/Features/IInstantQuery.cs b/Wox.Plugin/Features/IInstantQuery.cs index 2fe81fad7..11004c404 100644 --- a/Wox.Plugin/Features/IInstantQuery.cs +++ b/Wox.Plugin/Features/IInstantQuery.cs @@ -4,6 +4,6 @@ namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + "and use Wox.Plugin.Feature.IInstantQuery instead, " + - "this method will be removed in v1.3.0")] + "this method will be removed in v1.4.0")] public interface IInstantQuery { } } \ No newline at end of file diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 3c5b34277..732e3fb17 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -14,7 +14,7 @@ public interface IPublicAPI /// /// /// - [Obsolete("This method will be removed in Wox 1.3")] + [Obsolete("This method will be removed in Wox 1.4")] void PushResults(Query query, PluginMetadata plugin, List results); /// diff --git a/Wox.Plugin/Query.cs b/Wox.Plugin/Query.cs index 07b640ab8..79ed20464 100644 --- a/Wox.Plugin/Query.cs +++ b/Wox.Plugin/Query.cs @@ -95,13 +95,13 @@ private string SplitSearch(int index) public override string ToString() => RawQuery; - [Obsolete("Use ActionKeyword, this property will be removed in v1.3.0")] + [Obsolete("Use ActionKeyword, this property will be removed in v1.4.0")] public string ActionName { get; internal set; } - [Obsolete("Use Search instead, this property will be removed in v1.3.0")] + [Obsolete("Use Search instead, this property will be removed in v1.4.0")] public List ActionParameters { get; internal set; } - [Obsolete("Use Search instead, this method will be removed in v1.3.0")] + [Obsolete("Use Search instead, this method will be removed in v1.4.0")] public string GetAllRemainingParameter() => Search; } } diff --git a/Wox.Test/FuzzyMatcherTest.cs b/Wox.Test/FuzzyMatcherTest.cs index 6a033db79..cd6f08cce 100644 --- a/Wox.Test/FuzzyMatcherTest.cs +++ b/Wox.Test/FuzzyMatcherTest.cs @@ -20,6 +20,12 @@ public class FuzzyMatcherTest private const string OneOneOneOne = "1111"; private const string MicrosoftSqlServerManagementStudio = "Microsoft SQL Server Management Studio"; + [OneTimeSetUp] + public void setUp() + { + Settings.Initialize(); + } + public List GetSearchStrings() => new List { diff --git a/Wox.Test/PluginManagerTest.cs b/Wox.Test/PluginManagerTest.cs index 4907f6a37..2b548b27a 100644 --- a/Wox.Test/PluginManagerTest.cs +++ b/Wox.Test/PluginManagerTest.cs @@ -21,6 +21,7 @@ public void setUp() { // todo remove i18n from application / ui, so it can be tested in a modular way new App(); + Settings.Initialize(); ImageLoader.Initialize(); Portable portable = new Portable(); diff --git a/Wox.Test/PluginProgramTest.cs b/Wox.Test/PluginProgramTest.cs index b5d064fbe..6c12619c6 100644 --- a/Wox.Test/PluginProgramTest.cs +++ b/Wox.Test/PluginProgramTest.cs @@ -2,8 +2,13 @@ using System.Linq; using NUnit.Framework; +using Wox.Core.Configuration; using Wox.Core.Plugin; +using Wox.Image; +using Wox.Infrastructure; +using Wox.Infrastructure.UserSettings; using Wox.Plugin; +using Wox.ViewModel; namespace Wox.Test { @@ -16,9 +21,21 @@ class PluginProgramTest [OneTimeSetUp] public void Setup() { + Settings.Initialize(); + Portable portable = new Portable(); + SettingWindowViewModel settingsVm = new SettingWindowViewModel(portable); + StringMatcher stringMatcher = new StringMatcher(); + StringMatcher.Instance = stringMatcher; + stringMatcher.UserSettingSearchPrecision = Settings.Instance.QuerySearchPrecision; + PluginManager.LoadPlugins(Settings.Instance.PluginSettings); + MainViewModel mainVm = new MainViewModel(false); + PublicAPIInstance api = new PublicAPIInstance(settingsVm, mainVm); + plugin = new Plugin.Program.Main(); - plugin.loadSettings(); - Plugin.Program.Main.IndexPrograms(); + plugin.InitSync(new PluginInitContext() + { + API = api, + }); } [TestCase("powershell", "PowerShell")] diff --git a/Wox/App.config b/Wox/App.config index 5f570a630..540eaaabe 100644 --- a/Wox/App.config +++ b/Wox/App.config @@ -8,6 +8,13 @@ + + + + + + + @@ -16,4 +23,7 @@ - + + + + diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index df0d61d43..e53508696 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -22,6 +22,7 @@ using Wox.ViewModel; using Stopwatch = Wox.Infrastructure.Stopwatch; using Wox.Infrastructure.Exception; +using Sentry; namespace Wox { @@ -34,6 +35,7 @@ public partial class App : IDisposable, ISingleInstanceApp private SettingWindowViewModel _settingsVM; private readonly Portable _portable = new Portable(); private StringMatcher _stringMatcher; + private static string _systemLanguage; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -59,14 +61,19 @@ private void ParseCommandLineArgs(IList args) [STAThread] public static void Main() { + _systemLanguage = CultureInfo.CurrentUICulture.Name; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; - if (SingleInstance.InitializeAsFirstInstance(Unique)) + + using (ErrorReporting.InitializedSentry(_systemLanguage)) { - using (var application = new App()) + if (SingleInstance.InitializeAsFirstInstance(Unique)) { - application.InitializeComponent(); - application.Run(); + using (var application = new App()) + { + application.InitializeComponent(); + application.Run(); + } } } } @@ -75,17 +82,17 @@ private void OnStartup(object sender, StartupEventArgs e) { Logger.StopWatchNormal("Startup cost", () => { - Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); - Logger.WoxInfo($"Runtime info:{ExceptionFormatter.RuntimeInfo()}"); - Settings.Instance.ToString(); - RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); - //throw new Exception("sentry wox exception"); + Logger.WoxInfo("Begin Wox startup----------------------------------------------------"); + Settings.Initialize(); + ExceptionFormatter.Initialize(_systemLanguage, Settings.Instance.Language); + InsertWoxLanguageIntoLog(); - _portable.PreStartCleanUpAfterPortabilityUpdate(); + Logger.WoxInfo(ExceptionFormatter.RuntimeInfo()); + _portable.PreStartCleanUpAfterPortabilityUpdate(); ImageLoader.Initialize(); @@ -125,6 +132,17 @@ private void OnStartup(object sender, StartupEventArgs e) }); } + private static void InsertWoxLanguageIntoLog() + { + Log.updateSettingsInfo(Settings.Instance.Language); + Settings.Instance.PropertyChanged += (s, ev) => + { + if (ev.PropertyName == nameof(Settings.Instance.Language)) + { + Log.updateSettingsInfo(Settings.Instance.Language); + } + }; + } private void AutoStartup() { @@ -147,7 +165,7 @@ private void RegisterExitEvents() /// /// let exception throw as normal is better for Debug /// - [Conditional("RELEASE")] + //[Conditional("RELEASE")] private void RegisterDispatcherUnhandledException() { DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; @@ -157,7 +175,7 @@ private void RegisterDispatcherUnhandledException() /// /// let exception throw as normal is better for Debug /// - [Conditional("RELEASE")] + //[Conditional("RELEASE")] private static void RegisterAppDomainExceptions() { AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandleMain; @@ -169,7 +187,7 @@ public void Dispose() // but if sessionending is not called, exit won't be called when log off / shutdown if (!_disposed) { - API.SaveAppAllSettings(); + API?.SaveAppAllSettings(); _disposed = true; } } diff --git a/Wox/Helper/ErrorReporting.cs b/Wox/Helper/ErrorReporting.cs index b3c41ddaa..efd7e2791 100644 --- a/Wox/Helper/ErrorReporting.cs +++ b/Wox/Helper/ErrorReporting.cs @@ -1,55 +1,72 @@ using System; +using System.Net; +using System.Net.Sockets; using System.Runtime.CompilerServices; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; -using Mindscape.Raygun4Net; using NLog; +using Sentry; +using Sentry.Protocol; +using Wox.Infrastructure; using Wox.Infrastructure.Exception; namespace Wox.Helper { public static class ErrorReporting { - private static RaygunClient _raygunClient = new RaygunClient("LG5MX0YYMCpCN2AtD0fdZw"); - - private static void Report(Exception e, [CallerMemberName] string method = "") + private static void Report(Exception e, string id, [CallerMemberName] string method = "") { var logger = LogManager.GetLogger(method); - logger.Fatal(ExceptionFormatter.ExceptionWithRuntimeInfo(e)); + logger.Fatal(ExceptionFormatter.ExceptionWithRuntimeInfo(e, id)); - var reportWindow = new ReportWindow(e); + var reportWindow = new ReportWindow(e, id); reportWindow.Show(); - } public static void UnhandledExceptionHandleTask(Task t) { - _raygunClient.Send(t.Exception); + SentryId id = SentrySdk.CaptureException(t.Exception); Application.Current.Dispatcher.Invoke(() => { - Report(t.Exception); + Report(t.Exception, id.ToString()); }); - } public static void UnhandledExceptionHandleMain(object sender, UnhandledExceptionEventArgs e) { - _raygunClient.Send(e.ExceptionObject as Exception); + SentryId id = SentrySdk.CaptureException(e.ExceptionObject as Exception); //handle non-ui main thread exceptions Application.Current.Dispatcher.Invoke(() => { - Report((Exception)e.ExceptionObject); + Report((Exception)e.ExceptionObject, id.ToString()); }); } public static void DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - _raygunClient.Send(e.Exception); - Report(e.Exception); + SentryId id = SentrySdk.CaptureException(e.Exception); + Report(e.Exception, id.ToString()); //prevent application exist, so the user can copy prompted error info e.Handled = true; } + public static IDisposable InitializedSentry(string systemLanguage) + { + var s = SentrySdk.Init(o => + { + o.Dsn = new Dsn("https://b87bf28a6fab49bf9cb1b53e9648152f@o385966.ingest.sentry.io/5219588"); + o.Debug = true; // todo + o.Release = Constant.Version; + o.SendDefaultPii = true; + o.DisableAppDomainUnhandledExceptionCapture(); + }); + SentrySdk.ConfigureScope(scope => + { + scope.SetTag("systemLanguage", systemLanguage); + scope.SetTag("timezone", TimeZoneInfo.Local.DisplayName); + }); + return s; + } } } diff --git a/Wox/PublicAPIInstance.cs b/Wox/PublicAPIInstance.cs index c58533320..2a94b173e 100644 --- a/Wox/PublicAPIInstance.cs +++ b/Wox/PublicAPIInstance.cs @@ -143,7 +143,7 @@ public List GetAllPlugins() public event WoxGlobalKeyboardEventHandler GlobalKeyboardEvent; - [Obsolete("This will be removed in Wox 1.3")] + [Obsolete("This will be removed in Wox 1.4")] public void PushResults(Query query, PluginMetadata plugin, List results) { results.ForEach(o => diff --git a/Wox/ReportWindow.xaml.cs b/Wox/ReportWindow.xaml.cs index bcb24daf6..5866d2d67 100644 --- a/Wox/ReportWindow.xaml.cs +++ b/Wox/ReportWindow.xaml.cs @@ -15,25 +15,44 @@ namespace Wox { internal partial class ReportWindow { - public ReportWindow(Exception exception) + public ReportWindow(Exception exception, string id) { InitializeComponent(); ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); - SetException(exception); + SetException(exception, id); } - private void SetException(Exception exception) + private void SetException(Exception exception, string id) { string path = Log.CurrentLogDirectory; var directory = new DirectoryInfo(path); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); - var paragraph = Hyperlink("Please open new issue in: ", Constant.Issue); + Paragraph paragraph; + string websiteKey = nameof(Plugin.PluginPair.Metadata.Website); + if (exception.Data.Contains(websiteKey)) + { + paragraph = Hyperlink("You can help plugin author to fix this issue by opening issue in: ", exception.Data[websiteKey].ToString()); + string nameKey = nameof(Plugin.PluginPair.Metadata.Name); + if (exception.Data.Contains(nameKey)) + { + paragraph.Inlines.Add($"Plugin Name {exception.Data[nameKey]}"); + } + string idKey = nameof(Plugin.PluginPair.Metadata.ID); + if (exception.Data.Contains(idKey)) + { + paragraph.Inlines.Add($"Plugin ID {exception.Data[idKey]}"); + } + } + else + { + paragraph = Hyperlink("You can help us to fix this issue by opening issue in: ", Constant.Issue); + } paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add($"2. copy below exception message"); ErrorTextbox.Document.Blocks.Add(paragraph); - var content = ExceptionFormatter.ExceptionWithRuntimeInfo(exception); + var content = ExceptionFormatter.ExceptionWithRuntimeInfo(exception, id); paragraph = new Paragraph(); paragraph.Inlines.Add(content); ErrorTextbox.Document.Blocks.Add(paragraph); diff --git a/Wox/ViewModel/MainViewModel.cs b/Wox/ViewModel/MainViewModel.cs index fc2a9dc9f..221cd6325 100644 --- a/Wox/ViewModel/MainViewModel.cs +++ b/Wox/ViewModel/MainViewModel.cs @@ -74,9 +74,9 @@ public MainViewModel(bool useUI = true) History = new ResultsViewModel(_settings); _selectedResults = Results; - _translator = InternationalizationManager.Instance; if (useUI) { + _translator = InternationalizationManager.Instance; InitializeKeyCommands(); RegisterResultsUpdatedEvent(); diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 4c1ff6c59..aa1426dcc 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -2,6 +2,8 @@ + + true Debug AnyCPU {DB90F671-D861-46BB-93A3-F1304F5BA1C5} @@ -495,9 +497,6 @@ 10.3.0 - - 5.10.2 - 9.0.1 @@ -520,6 +519,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + + 2.1.1 + 1.9.1 diff --git a/appveyor.yml b/appveyor.yml index cd566c57e..c91070025 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 1.3.{build} +version: 1.4.{build} image: Visual Studio 2019 configuration: Release assembly_info: