-
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathNativeScopeObserver.cs
More file actions
63 lines (48 loc) · 2.48 KB
/
NativeScopeObserver.cs
File metadata and controls
63 lines (48 loc) · 2.48 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
namespace Sentry.Unity.iOS;
public class NativeScopeObserver : ScopeObserver
{
public NativeScopeObserver(string name, SentryOptions options) : base(name, options) { }
public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
{
var level = GetBreadcrumbLevel(breadcrumb.Level);
var timestamp = GetTimestamp(breadcrumb.Timestamp);
SentryCocoaBridgeProxy.AddBreadcrumb(timestamp, breadcrumb.Message, breadcrumb.Type, breadcrumb.Category, level);
}
public override void SetExtraImpl(string key, string? value) =>
SentryCocoaBridgeProxy.SetExtra(key, value);
public override void SetTagImpl(string key, string value) => SentryCocoaBridgeProxy.SetTag(key, value);
public override void UnsetTagImpl(string key) => SentryCocoaBridgeProxy.UnsetTag(key);
public override void SetUserImpl(SentryUser user) =>
SentryCocoaBridgeProxy.SetUser(user.Email, user.Id, user.IpAddress, user.Username);
public override void UnsetUserImpl() => SentryCocoaBridgeProxy.UnsetUser();
public override void SetTraceImpl(SentryId traceId, SpanId spanId) =>
SentryCocoaBridgeProxy.SetTrace(traceId.ToString(), spanId.ToString());
public override void AddFileAttachmentImpl(string filePath, string fileName, string? contentType)
{
// iOS/macOS attachment sync to sentry-cocoa is not yet supported.
}
public override void AddByteAttachmentImpl(byte[] data, string fileName, string? contentType)
{
// iOS/macOS attachment sync to sentry-cocoa is not yet supported.
}
public override void ClearAttachmentsImpl()
{
// iOS/macOS attachment sync to sentry-cocoa is not yet supported.
}
internal static string GetTimestamp(DateTimeOffset timestamp) =>
// "o": Using ISO 8601 to make sure the timestamp makes it to the bridge correctly.
// https://docs.microsoft.com/en-gb/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip
timestamp.ToString("o");
internal static int GetBreadcrumbLevel(BreadcrumbLevel breadcrumbLevel) =>
// https://github.com/getsentry/sentry-cocoa/blob/50f955aeb214601dd62b5dae7abdaddc8a1f24d9/Sources/Sentry/Public/SentryDefines.h#L99-L105
breadcrumbLevel switch
{
BreadcrumbLevel.Debug => 1,
BreadcrumbLevel.Info => 2,
BreadcrumbLevel.Warning => 3,
BreadcrumbLevel.Error => 4,
BreadcrumbLevel.Fatal => 5,
_ => 0
};
}