-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathBugsenseWrapper.cs
executable file
·83 lines (73 loc) · 2.56 KB
/
BugsenseWrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// This is the source code of Telegram for Windows Phone v. 3.x.x.
// It is licensed under GNU GPL v. 2 or later.
// You should have received a copy of the license in this archive (see LICENSE).
//
// Copyright Evgeny Nadymov, 2013-present.
//
using System;
using System.Collections.Generic;
using System.Windows;
using BugSense;
using Telegram.Api.TL;
namespace TelegramClient
{
class BugSenseWrapper
{
private static readonly List<Tuple<Exception, string, NotificationOptions>> _delayedErrors = new List<Tuple<Exception, string, NotificationOptions>>();
private static readonly object _bugSenseSyncRoot = new object();
private static bool _isInitialized;
private BugSenseWrapper()
{
}
public static void LogError(Exception ex, string comment = null, NotificationOptions options = null)
{
lock (_bugSenseSyncRoot)
{
if (!_isInitialized)
{
_delayedErrors.Add(new Tuple<Exception, string, NotificationOptions>(ex, comment, options));
return;
}
}
try
{
BugSenseHandler.Instance.LogError(ex, comment, options);
}
catch (Exception e)
{
Telegram.Logs.Log.Write("BugSenseWrapper\n" + e);
}
}
public static void Init()
{
#if PRIVATE_BETA
const string apiKey = "b6f57378";
#else
const string apiKey = "e715f5e8";
#endif
BugSenseHandler.Instance.Init(Application.Current, apiKey, new NotificationOptions { Type = enNotificationType.None });
BugSenseHandler.Instance.UnhandledException += (sender, args) =>
{
TLUtils.WriteLine(args.ExceptionObject.ToString(), LogSeverity.Error);
args.Handled = true;
};
lock (_bugSenseSyncRoot)
{
_isInitialized = true;
foreach (var error in _delayedErrors)
{
try
{
BugSenseHandler.Instance.LogError(error.Item1, error.Item2, error.Item3);
}
catch (Exception ex)
{
Telegram.Logs.Log.Write("BugSenseWrapper delayed\n" + ex);
}
}
_delayedErrors.Clear();
}
}
}
}