-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSentryInit.cs
More file actions
45 lines (38 loc) · 1.53 KB
/
SentryInit.cs
File metadata and controls
45 lines (38 loc) · 1.53 KB
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
using System.Collections.Generic;
using Cycode.VisualStudio.Extension.Shared.Options;
using Sentry;
namespace Cycode.VisualStudio.Extension.Shared.Sentry;
public static class SentryInit {
private static string GetSentryRelease() {
return $"{Constants.AppName}@{Vsix.Version}";
}
private static bool IsSentryDisabled() {
return General.Instance.IsOnPremiseInstallation();
}
public static void Init() {
SentrySdk.Init(options => {
options.Dsn = Constants.SentryDsn;
options.Debug = Constants.SentryDebug;
options.Release = GetSentryRelease();
options.AutoSessionTracking = Constants.SentryAutoSessionTracking;
options.SampleRate = Constants.SentrySampleRate;
options.SendDefaultPii = Constants.SentrySendDefaultPii;
options.ServerName = "";
options.SetBeforeSend((sentryEvent, _) => IsSentryDisabled() ? null : sentryEvent);
options.DisableUnobservedTaskExceptionCapture();
options.DisableAppDomainUnhandledExceptionCapture();
options.DisableNetFxInstallationsIntegration();
});
}
public static void SetupScope(string userId, string tenantId) {
SentrySdk.ConfigureScope(scope => {
scope.SetTag("tenant_id", tenantId);
scope.User = new SentryUser {
Id = userId,
Other = new Dictionary<string, string> {
{ "tenant_id", tenantId }
}
};
});
}
}