14
14
#if USE_SENTRY_NATIVE
15
15
16
16
FGenericPlatformSentryScope::FGenericPlatformSentryScope ()
17
- {
18
- Scope = sentry_local_scope_new ();
19
- }
20
-
21
- FGenericPlatformSentryScope::FGenericPlatformSentryScope (sentry_scope_t * scope)
22
- : Scope(scope)
17
+ : Level(ESentryLevel::Debug)
23
18
{
24
19
}
25
20
@@ -29,11 +24,17 @@ FGenericPlatformSentryScope::~FGenericPlatformSentryScope()
29
24
30
25
void FGenericPlatformSentryScope::AddBreadcrumb (TSharedPtr<ISentryBreadcrumb> breadcrumb)
31
26
{
32
- sentry_scope_add_breadcrumb (Scope, StaticCastSharedPtr<FGenericPlatformSentryBreadcrumb>(breadcrumb)->GetNativeObject ());
27
+ if (Breadcrumbs.Num () >= FSentryModule::Get ().GetSettings ()->MaxBreadcrumbs )
28
+ {
29
+ Breadcrumbs.PopFront ();
30
+ }
31
+
32
+ Breadcrumbs.Add (StaticCastSharedPtr<FGenericPlatformSentryBreadcrumb>(breadcrumb));
33
33
}
34
34
35
35
void FGenericPlatformSentryScope::ClearBreadcrumbs ()
36
36
{
37
+ Breadcrumbs.Empty ();
37
38
}
38
39
39
40
void FGenericPlatformSentryScope::AddAttachment (TSharedPtr<ISentryAttachment> attachment)
@@ -48,29 +49,31 @@ void FGenericPlatformSentryScope::ClearAttachments()
48
49
49
50
void FGenericPlatformSentryScope::SetTagValue (const FString& key, const FString& value)
50
51
{
51
- sentry_scope_set_tag (Scope, TCHAR_TO_UTF8 (*key), TCHAR_TO_UTF8 (*value));
52
+ Tags.Add (key, value);
53
+
52
54
}
53
55
54
56
FString FGenericPlatformSentryScope::GetTagValue (const FString& key) const
55
57
{
56
- return FString ();
58
+ if (!Tags.Contains (key))
59
+ return FString ();
60
+
61
+ return Tags[key];
57
62
}
58
63
59
64
void FGenericPlatformSentryScope::RemoveTag (const FString& key)
60
65
{
66
+ Tags.Remove (key);
61
67
}
62
68
63
69
void FGenericPlatformSentryScope::SetTags (const TMap<FString, FString>& tags)
64
70
{
65
- for (const auto & tagItem : tags)
66
- {
67
- SetTagValue (tagItem.Key , tagItem.Value );
68
- }
71
+ Tags.Append (tags);
69
72
}
70
73
71
74
TMap<FString, FString> FGenericPlatformSentryScope::GetTags () const
72
75
{
73
- return TMap<FString, FString>() ;
76
+ return Tags ;
74
77
}
75
78
76
79
void FGenericPlatformSentryScope::SetDist (const FString& dist)
@@ -95,62 +98,120 @@ FString FGenericPlatformSentryScope::GetEnvironment() const
95
98
96
99
void FGenericPlatformSentryScope::SetFingerprint (const TArray<FString>& fingerprint)
97
100
{
98
- sentry_scope_set_fingerprints (Scope, FGenericPlatformSentryConverters::StringArrayToNative ( fingerprint)) ;
101
+ Fingerprint = fingerprint;
99
102
}
100
103
101
104
TArray<FString> FGenericPlatformSentryScope::GetFingerprint () const
102
105
{
103
- return TArray<FString>() ;
106
+ return Fingerprint ;
104
107
}
105
108
106
109
void FGenericPlatformSentryScope::SetLevel (ESentryLevel level)
107
110
{
108
- sentry_scope_set_level (Scope, FGenericPlatformSentryConverters::SentryLevelToNative ( level)) ;
111
+ Level = level;
109
112
}
110
113
111
114
ESentryLevel FGenericPlatformSentryScope::GetLevel () const
112
115
{
113
- return ESentryLevel::Debug ;
116
+ return Level ;
114
117
}
115
118
116
119
void FGenericPlatformSentryScope::SetContext (const FString& key, const TMap<FString, FString>& values)
117
120
{
118
- sentry_scope_set_context (Scope, TCHAR_TO_UTF8 (* key), FGenericPlatformSentryConverters::StringMapToNative ( values) );
121
+ Contexts. Add ( key, values);
119
122
}
120
123
121
124
void FGenericPlatformSentryScope::RemoveContext (const FString& key)
122
125
{
126
+ if (!Contexts.Contains (key))
127
+ return ;
128
+
129
+ Contexts.Remove (key);
123
130
}
124
131
125
132
void FGenericPlatformSentryScope::SetExtraValue (const FString& key, const FString& value)
126
133
{
127
- sentry_scope_set_extra (Scope, TCHAR_TO_UTF8 (* key), sentry_value_new_string ( TCHAR_TO_UTF8 (* value)) );
134
+ Extra. Add ( key, value);
128
135
}
129
136
130
137
FString FGenericPlatformSentryScope::GetExtraValue (const FString& key) const
131
138
{
132
- return FString ();
139
+ if (!Extra.Contains (key))
140
+ return FString ();
141
+
142
+ return Extra[key];
133
143
}
134
144
135
145
void FGenericPlatformSentryScope::RemoveExtra (const FString& key)
136
146
{
147
+ if (!Extra.Contains (key))
148
+ return ;
149
+
150
+ Extra.Remove (key);
137
151
}
138
152
139
153
void FGenericPlatformSentryScope::SetExtras (const TMap<FString, FString>& extras)
140
154
{
141
- for (const auto & extraItem : extras)
142
- {
143
- SetExtraValue (extraItem.Key , extraItem.Value );
144
- }
155
+ Extra.Append (extras);
145
156
}
146
157
147
158
TMap<FString, FString> FGenericPlatformSentryScope::GetExtras () const
148
159
{
149
- return TMap<FString, FString>() ;
160
+ return Extra ;
150
161
}
151
162
152
163
void FGenericPlatformSentryScope::Clear ()
153
164
{
165
+ Dist = FString ();
166
+ Environment = FString ();
167
+ Fingerprint.Empty ();
168
+ Tags.Empty ();
169
+ Extra.Empty ();
170
+ Contexts.Empty ();
171
+ Breadcrumbs.Empty ();
172
+ Level = ESentryLevel::Debug;}
173
+
174
+ void FGenericPlatformSentryScope::Apply (sentry_scope_t * scope)
175
+ {
176
+ if (!Breadcrumbs.IsEmpty ())
177
+ {
178
+ for (const auto & Breadcrumb : Breadcrumbs)
179
+ {
180
+ sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject ();
181
+ sentry_scope_add_breadcrumb (scope, nativeBreadcrumb);
182
+ }
183
+ }
184
+
185
+ if (Fingerprint.Num () > 0 )
186
+ {
187
+ sentry_scope_set_fingerprints (scope, FGenericPlatformSentryConverters::StringArrayToNative (Fingerprint));
188
+ }
189
+
190
+ if (Tags.Num () > 0 )
191
+ {
192
+ for (const auto & TagItem : Tags)
193
+ {
194
+ sentry_scope_set_tag (scope, TCHAR_TO_UTF8 (*TagItem.Key ), TCHAR_TO_UTF8 (*TagItem.Value ));
195
+ }
196
+ }
197
+
198
+ if (Extra.Num () > 0 )
199
+ {
200
+ for (const auto & ExtraItem : Extra)
201
+ {
202
+ sentry_scope_set_extra (scope, TCHAR_TO_UTF8 (*ExtraItem.Key ), sentry_value_new_string (TCHAR_TO_UTF8 (*ExtraItem.Value )));
203
+ }
204
+ }
205
+
206
+ if (Contexts.Num () > 0 )
207
+ {
208
+ for (const auto & ContextsItem : Contexts)
209
+ {
210
+ sentry_scope_set_context (scope, TCHAR_TO_UTF8 (*ContextsItem.Key ), FGenericPlatformSentryConverters::StringMapToNative (ContextsItem.Value ));
211
+ }
212
+ }
213
+
214
+ sentry_scope_set_level (scope, FGenericPlatformSentryConverters::SentryLevelToNative (Level));
154
215
}
155
216
156
217
#endif
0 commit comments