mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-02 11:34:08 +02:00
Make analytics debugging easier & tweak Counter serialization
This commit is contained in:
parent
679e126194
commit
bf45c40365
Core/Other/Analytics
@ -17,7 +17,7 @@ static AnalyticsFile(){
|
|||||||
|
|
||||||
Serializer.RegisterTypeConverter(typeof(Counter), new SingleTypeConverter<Counter>{
|
Serializer.RegisterTypeConverter(typeof(Counter), new SingleTypeConverter<Counter>{
|
||||||
ConvertToString = value => value.Value.ToString(),
|
ConvertToString = value => value.Value.ToString(),
|
||||||
ConvertToObject = value => new Counter(int.Parse(value))
|
ConvertToObject = value => int.Parse(value)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
using System;
|
// Uncomment to debug reports locally
|
||||||
|
// #define ANALYTICS_LOCALHOST
|
||||||
|
// #define ANALYTICS_INSTANT
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
@ -9,7 +13,14 @@
|
|||||||
namespace TweetDuck.Core.Other.Analytics{
|
namespace TweetDuck.Core.Other.Analytics{
|
||||||
sealed class AnalyticsManager : IDisposable{
|
sealed class AnalyticsManager : IDisposable{
|
||||||
private static readonly TimeSpan CollectionInterval = TimeSpan.FromDays(14);
|
private static readonly TimeSpan CollectionInterval = TimeSpan.FromDays(14);
|
||||||
private static readonly Uri CollectionUrl = new Uri("https://tweetduck.chylex.com/breadcrumb/report");
|
|
||||||
|
private static readonly Uri CollectionUrl = new Uri(
|
||||||
|
#if (DEBUG && ANALYTICS_LOCALHOST)
|
||||||
|
"http://localhost/newhome/tweetduck/~breadcrumb/request.php?type=report"
|
||||||
|
#else
|
||||||
|
"https://tweetduck.chylex.com/breadcrumb/report"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
public AnalyticsFile File { get; }
|
public AnalyticsFile File { get; }
|
||||||
|
|
||||||
@ -36,6 +47,10 @@ public AnalyticsManager(FormBrowser browser, PluginManager plugins, string file)
|
|||||||
else{
|
else{
|
||||||
RestartTimer();
|
RestartTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (DEBUG && ANALYTICS_INSTANT)
|
||||||
|
SendReport();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose(){
|
public void Dispose(){
|
||||||
@ -98,7 +113,7 @@ private void SendReport(){
|
|||||||
Task.Factory.StartNew(() => {
|
Task.Factory.StartNew(() => {
|
||||||
AnalyticsReport report = AnalyticsReportGenerator.Create(File, info, plugins);
|
AnalyticsReport report = AnalyticsReportGenerator.Create(File, info, plugins);
|
||||||
|
|
||||||
#if DEBUG
|
#if (DEBUG && !ANALYTICS_INSTANT)
|
||||||
System.Diagnostics.Debugger.Break();
|
System.Diagnostics.Debugger.Break();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -125,6 +140,14 @@ private void SendReport(){
|
|||||||
message = "HTTP Error "+(response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
|
message = "HTTP Error "+(response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
System.IO.Stream responseStream = e.Response.GetResponseStream();
|
||||||
|
|
||||||
|
if (responseStream != null){
|
||||||
|
System.Diagnostics.Debug.WriteLine(new System.IO.StreamReader(responseStream).ReadToEnd());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleReportIn(TimeSpan.FromHours(4), message ?? "Error: "+(task.Exception.InnerException?.Message ?? task.Exception.Message));
|
ScheduleReportIn(TimeSpan.FromHours(4), message ?? "Error: "+(task.Exception.InnerException?.Message ?? task.Exception.Message));
|
||||||
|
Loading…
Reference in New Issue
Block a user