private static bool PostData(string type, IDictionary <string, string> extraData) { if (ServerSettings.Instance.GA_OptOutPlzDont) { return(false); } try { using (var client = new HttpClient()) { var data = new Dictionary <string, string>(); data.Add("t", type); data.Add("an", "Shoko Server"); data.Add("tid", AnalyticsId); data.Add("cid", ServerSettings.Instance.GA_Client.ToString()); data.Add("v", "1"); data.Add("av", Utils.GetApplicationVersion()); data.Add("ul", CultureInfo.GetCultureInfo(ServerSettings.Instance.Culture).DisplayName); data.Add("aip", "1"); data.AddRange(extraData); var resp = client.PostAsync($"{Endpoint}/collect", new FormUrlEncodedContent(data)) .ConfigureAwait(false).GetAwaiter().GetResult(); return(true); } } catch (HttpRequestException ex) { Logger.Error("There was an error posting to Google Analytics", ex); return(false); } }
public void CheckForUpdates() { Assembly a = Assembly.GetExecutingAssembly(); ServerState.Instance.ApplicationVersion = Utils.GetApplicationVersion(a); ServerState.Instance.ApplicationVersionExtra = Utils.GetApplicationExtraVersion(a); logger.Info("Checking for updates..."); CheckForUpdatesNew(false); }