-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: updates some old manager links and paths * feat: check for updates against the new endpoint * feat(revit): adds some safity guards & herror handling
- Loading branch information
Showing
4 changed files
with
179 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,73 +17,92 @@ public static class Log | |
|
||
public static void Initialize() | ||
{ | ||
if (_initialized) | ||
return; | ||
try | ||
{ | ||
if (_initialized) | ||
return; | ||
|
||
var dsn = "https://[email protected]/5396846"; | ||
var dsn = "https://[email protected]/5396846"; | ||
|
||
var env = "production"; | ||
var debug = false; | ||
var env = "production"; | ||
var debug = false; | ||
#if DEBUG | ||
env = "dev"; | ||
dsn = null; | ||
debug = true; | ||
env = "dev"; | ||
dsn = null; | ||
debug = true; | ||
#endif | ||
|
||
SentrySdk.Init(o => | ||
{ | ||
o.Dsn = dsn; | ||
o.Environment = env; | ||
o.Debug = debug; | ||
o.Release = "SpeckleCore@" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); | ||
o.StackTraceMode = StackTraceMode.Enhanced; | ||
o.AttachStacktrace = true; | ||
}); | ||
SentrySdk.Init(o => | ||
{ | ||
o.Dsn = dsn; | ||
o.Environment = env; | ||
o.Debug = debug; | ||
o.Release = "SpeckleCore@" + Assembly.GetExecutingAssembly().GetName().Version.ToString(); | ||
o.StackTraceMode = StackTraceMode.Enhanced; | ||
o.AttachStacktrace = true; | ||
}); | ||
|
||
|
||
var da = AccountManager.GetDefaultAccount(); | ||
var id = da != null ? da.GetHashedEmail() : "unknown"; | ||
var da = AccountManager.GetDefaultAccount(); | ||
var id = da != null ? da.GetHashedEmail() : "unknown"; | ||
|
||
|
||
SentrySdk.ConfigureScope(scope => | ||
{ | ||
scope.User = new User { Id = id, }; | ||
scope.SetTag("hostApplication", Setup.HostApplication); | ||
}); | ||
SentrySdk.ConfigureScope(scope => | ||
{ | ||
scope.User = new User { Id = id, }; | ||
scope.SetTag("hostApplication", Setup.HostApplication); | ||
}); | ||
|
||
_initialized = true; | ||
_initialized = true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
//swallow | ||
} | ||
} | ||
|
||
|
||
//capture and make sure Sentry is initialized | ||
public static void CaptureException( | ||
Exception e, | ||
SentryLevel level = SentryLevel.Info, | ||
List<KeyValuePair<string, object>> extra = null) | ||
public static void CaptureException(Exception e, SentryLevel level = SentryLevel.Info, List<KeyValuePair<string, object>> extra = null) | ||
{ | ||
Initialize(); | ||
|
||
//ignore infos as they're hogging us | ||
if (level == SentryLevel.Info) | ||
return; | ||
|
||
SentrySdk.WithScope(s => | ||
try | ||
{ | ||
Initialize(); | ||
|
||
//ignore infos as they're hogging us | ||
if (level == SentryLevel.Info) | ||
return; | ||
|
||
SentrySdk.WithScope(s => | ||
{ | ||
s.Level = level; | ||
|
||
if (extra != null) | ||
s.SetExtras(extra); | ||
if (e is AggregateException aggregate) | ||
aggregate.InnerExceptions.ToList().ForEach(ex => SentrySdk.CaptureException(e)); | ||
else | ||
SentrySdk.CaptureException(e); | ||
}); | ||
|
||
} | ||
catch (Exception ex) | ||
{ | ||
s.Level = level; | ||
|
||
if (extra != null) | ||
s.SetExtras(extra); | ||
if (e is AggregateException aggregate) | ||
aggregate.InnerExceptions.ToList().ForEach(ex => SentrySdk.CaptureException(e)); | ||
else | ||
SentrySdk.CaptureException(e); | ||
}); | ||
//swallow | ||
} | ||
} | ||
|
||
public static void AddBreadcrumb(string message) | ||
{ | ||
Initialize(); | ||
SentrySdk.AddBreadcrumb(message); | ||
try | ||
{ | ||
Initialize(); | ||
SentrySdk.AddBreadcrumb(message); | ||
} | ||
catch (Exception ex) | ||
{ | ||
//swallow | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.