14
14
#if USE_SENTRY_NATIVE
15
15
16
16
FGenericPlatformSentryScope::FGenericPlatformSentryScope ()
17
- : Level(ESentryLevel::Debug)
18
17
{
18
+ Scope = sentry_local_scope_new ();
19
19
}
20
20
21
- FGenericPlatformSentryScope::FGenericPlatformSentryScope (const FGenericPlatformSentryScope& Scope)
21
+ FGenericPlatformSentryScope::FGenericPlatformSentryScope (sentry_scope_t * scope)
22
+ : Scope(scope)
22
23
{
23
- Dist = Scope.Dist ;
24
- Environment = Scope.Environment ;
25
- Fingerprint = Scope.Fingerprint ;
26
- Tags = Scope.Tags ;
27
- Extra = Scope.Extra ;
28
- Contexts = Scope.Contexts ;
29
- Breadcrumbs = TRingBuffer<TSharedPtr<FGenericPlatformSentryBreadcrumb>>(Scope.Breadcrumbs );
30
- Level = Scope.Level ;
31
24
}
32
25
33
26
FGenericPlatformSentryScope::~FGenericPlatformSentryScope ()
@@ -36,21 +29,11 @@ FGenericPlatformSentryScope::~FGenericPlatformSentryScope()
36
29
37
30
void FGenericPlatformSentryScope::AddBreadcrumb (TSharedPtr<ISentryBreadcrumb> breadcrumb)
38
31
{
39
- FScopeLock Lock (&CriticalSection);
40
-
41
- if (Breadcrumbs.Num () >= FSentryModule::Get ().GetSettings ()->MaxBreadcrumbs )
42
- {
43
- Breadcrumbs.PopFront ();
44
- }
45
-
46
- Breadcrumbs.Add (StaticCastSharedPtr<FGenericPlatformSentryBreadcrumb>(breadcrumb));
32
+ sentry_scope_add_breadcrumb (Scope, StaticCastSharedPtr<FGenericPlatformSentryBreadcrumb>(breadcrumb)->GetNativeObject ());
47
33
}
48
34
49
35
void FGenericPlatformSentryScope::ClearBreadcrumbs ()
50
36
{
51
- FScopeLock Lock (&CriticalSection);
52
-
53
- Breadcrumbs.Empty ();
54
37
}
55
38
56
39
void FGenericPlatformSentryScope::AddAttachment (TSharedPtr<ISentryAttachment> attachment)
@@ -65,237 +48,109 @@ void FGenericPlatformSentryScope::ClearAttachments()
65
48
66
49
void FGenericPlatformSentryScope::SetTagValue (const FString& key, const FString& value)
67
50
{
68
- Tags. Add ( key, value);
51
+ sentry_scope_set_tag (Scope, TCHAR_TO_UTF8 (* key), TCHAR_TO_UTF8 (* value) );
69
52
}
70
53
71
54
FString FGenericPlatformSentryScope::GetTagValue (const FString& key) const
72
55
{
73
- if (!Tags.Contains (key))
74
- return FString ();
75
-
76
- return Tags[key];
56
+ return FString ();
77
57
}
78
58
79
59
void FGenericPlatformSentryScope::RemoveTag (const FString& key)
80
60
{
81
- Tags.Remove (key);
82
61
}
83
62
84
63
void FGenericPlatformSentryScope::SetTags (const TMap<FString, FString>& tags)
85
64
{
86
- Tags.Append (tags);
65
+ for (const auto & tagItem : tags)
66
+ {
67
+ SetTagValue (tagItem.Key , tagItem.Value );
68
+ }
87
69
}
88
70
89
71
TMap<FString, FString> FGenericPlatformSentryScope::GetTags () const
90
72
{
91
- return Tags ;
73
+ return TMap<FString, FString>() ;
92
74
}
93
75
94
76
void FGenericPlatformSentryScope::SetDist (const FString& dist)
95
77
{
96
- Dist = dist;
78
+ // Set via options during initialization
97
79
}
98
80
99
81
FString FGenericPlatformSentryScope::GetDist () const
100
82
{
101
- return Dist ;
83
+ return FString () ;
102
84
}
103
85
104
86
void FGenericPlatformSentryScope::SetEnvironment (const FString& environment)
105
87
{
106
- Environment = environment;
88
+ // Set via options during initialization
107
89
}
108
90
109
91
FString FGenericPlatformSentryScope::GetEnvironment () const
110
92
{
111
- return Environment ;
93
+ return FString () ;
112
94
}
113
95
114
96
void FGenericPlatformSentryScope::SetFingerprint (const TArray<FString>& fingerprint)
115
97
{
116
- Fingerprint = fingerprint;
98
+ sentry_scope_set_fingerprints (Scope, FGenericPlatformSentryConverters::StringArrayToNative ( fingerprint)) ;
117
99
}
118
100
119
101
TArray<FString> FGenericPlatformSentryScope::GetFingerprint () const
120
102
{
121
- return Fingerprint ;
103
+ return TArray<FString>() ;
122
104
}
123
105
124
106
void FGenericPlatformSentryScope::SetLevel (ESentryLevel level)
125
107
{
126
- Level = level;
108
+ sentry_scope_set_level (Scope, FGenericPlatformSentryConverters::SentryLevelToNative ( level)) ;
127
109
}
128
110
129
111
ESentryLevel FGenericPlatformSentryScope::GetLevel () const
130
112
{
131
-
132
- return Level;
113
+ return ESentryLevel::Debug;
133
114
}
134
115
135
116
void FGenericPlatformSentryScope::SetContext (const FString& key, const TMap<FString, FString>& values)
136
117
{
137
- Contexts. Add ( key, values);
118
+ sentry_scope_set_context (Scope, TCHAR_TO_UTF8 (* key), FGenericPlatformSentryConverters::StringMapToNative ( values) );
138
119
}
139
120
140
121
void FGenericPlatformSentryScope::RemoveContext (const FString& key)
141
122
{
142
- if (!Contexts.Contains (key))
143
- return ;
144
-
145
- Contexts.Remove (key);
146
123
}
147
124
148
125
void FGenericPlatformSentryScope::SetExtraValue (const FString& key, const FString& value)
149
126
{
150
- Extra. Add ( key, value);
127
+ sentry_scope_set_extra (Scope, TCHAR_TO_UTF8 (* key), sentry_value_new_string ( TCHAR_TO_UTF8 (* value)) );
151
128
}
152
129
153
130
FString FGenericPlatformSentryScope::GetExtraValue (const FString& key) const
154
131
{
155
- if (!Extra.Contains (key))
156
- return FString ();
157
-
158
- return Extra[key];
132
+ return FString ();
159
133
}
160
134
161
135
void FGenericPlatformSentryScope::RemoveExtra (const FString& key)
162
136
{
163
- if (!Extra.Contains (key))
164
- return ;
165
-
166
- Extra.Remove (key);
167
137
}
168
138
169
139
void FGenericPlatformSentryScope::SetExtras (const TMap<FString, FString>& extras)
170
140
{
171
- Extra.Append (extras);
141
+ for (const auto & extraItem : extras)
142
+ {
143
+ SetExtraValue (extraItem.Key , extraItem.Value );
144
+ }
172
145
}
173
146
174
147
TMap<FString, FString> FGenericPlatformSentryScope::GetExtras () const
175
148
{
176
- return Extra ;
149
+ return TMap<FString, FString>() ;
177
150
}
178
151
179
152
void FGenericPlatformSentryScope::Clear ()
180
153
{
181
- Dist = FString ();
182
- Environment = FString ();
183
- Fingerprint.Empty ();
184
- Tags.Empty ();
185
- Extra.Empty ();
186
- Contexts.Empty ();
187
- Breadcrumbs.Empty ();
188
- Level = ESentryLevel::Debug;
189
- }
190
-
191
- void FGenericPlatformSentryScope::Apply (TSharedPtr<FGenericPlatformSentryEvent> event)
192
- {
193
- sentry_value_t nativeEvent = event->GetNativeObject ();
194
-
195
- sentry_value_t eventLevel = sentry_value_get_by_key (nativeEvent, " level" );
196
-
197
- FString scopeLevelStr = FGenericPlatformSentryConverters::SentryLevelToString (Level).ToLower ();
198
- if (!scopeLevelStr.IsEmpty () && sentry_value_is_null (eventLevel))
199
- {
200
- sentry_value_set_by_key (nativeEvent, " level" , sentry_value_new_string (TCHAR_TO_ANSI (*scopeLevelStr)));
201
- }
202
-
203
- if (!Dist.IsEmpty ())
204
- {
205
- sentry_value_set_by_key (nativeEvent, " dist" , sentry_value_new_string (TCHAR_TO_ANSI (*Dist)));
206
- }
207
-
208
- if (!Environment.IsEmpty ())
209
- {
210
- sentry_value_set_by_key (nativeEvent, " environment" , sentry_value_new_string (TCHAR_TO_ANSI (*Environment)));
211
- }
212
-
213
- if (Fingerprint.Num () > 0 )
214
- {
215
- sentry_value_set_by_key (nativeEvent, " fingerprint" , FGenericPlatformSentryConverters::StringArrayToNative (Fingerprint));
216
- }
217
-
218
- if (Tags.Num () > 0 )
219
- {
220
- sentry_value_t tagsExtra = sentry_value_get_by_key (nativeEvent, " tags" );
221
- if (sentry_value_is_null (tagsExtra))
222
- {
223
- sentry_value_set_by_key (nativeEvent, " tags" , FGenericPlatformSentryConverters::StringMapToNative (Tags));
224
- }
225
- else
226
- {
227
- for (const auto & TagItem : Tags)
228
- {
229
- sentry_value_set_by_key (tagsExtra, TCHAR_TO_ANSI (*TagItem.Key ), sentry_value_new_string (TCHAR_TO_ANSI (*TagItem.Value )));
230
- }
231
- }
232
- }
233
-
234
- if (Extra.Num () > 0 )
235
- {
236
- sentry_value_t eventExtra = sentry_value_get_by_key (nativeEvent, " extra" );
237
- if (sentry_value_is_null (eventExtra))
238
- {
239
- sentry_value_set_by_key (nativeEvent, " extra" , FGenericPlatformSentryConverters::StringMapToNative (Extra));
240
- }
241
- else
242
- {
243
- for (const auto & ExtraItem : Extra)
244
- {
245
- sentry_value_set_by_key (eventExtra, TCHAR_TO_ANSI (*ExtraItem.Key ), sentry_value_new_string (TCHAR_TO_ANSI (*ExtraItem.Value )));
246
- }
247
- }
248
- }
249
-
250
- if (Contexts.Num () > 0 )
251
- {
252
- sentry_value_t eventContexts = sentry_value_get_by_key (nativeEvent, " contexts" );
253
- if (sentry_value_is_null (eventContexts))
254
- {
255
- eventContexts = sentry_value_new_object ();
256
-
257
- for (const auto & ContextsItem : Contexts)
258
- {
259
- sentry_value_set_by_key (eventContexts, TCHAR_TO_ANSI (*ContextsItem.Key ), FGenericPlatformSentryConverters::StringMapToNative (ContextsItem.Value ));
260
- }
261
-
262
- sentry_value_set_by_key (nativeEvent, " contexts" , eventContexts);
263
- }
264
- else
265
- {
266
- for (const auto & ContextsItem : Contexts)
267
- {
268
- sentry_value_set_by_key (eventContexts, TCHAR_TO_ANSI (*ContextsItem.Key ), FGenericPlatformSentryConverters::StringMapToNative (ContextsItem.Value ));
269
- }
270
- }
271
- }
272
-
273
- if (!Breadcrumbs.IsEmpty ())
274
- {
275
- sentry_value_t eventBreadcrumbs = sentry_value_get_by_key (nativeEvent, " breadcrumbs" );
276
- if (sentry_value_is_null (eventBreadcrumbs))
277
- {
278
- eventBreadcrumbs = sentry_value_new_list ();
279
-
280
- for (const auto & Breadcrumb : Breadcrumbs)
281
- {
282
- sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject ();
283
- sentry_value_incref (nativeBreadcrumb);
284
- sentry_value_append (eventBreadcrumbs, nativeBreadcrumb);
285
- }
286
-
287
- sentry_value_set_by_key (nativeEvent, " breadcrumbs" , eventBreadcrumbs);
288
- }
289
- else
290
- {
291
- for (const auto & Breadcrumb : Breadcrumbs)
292
- {
293
- sentry_value_t nativeBreadcrumb = Breadcrumb->GetNativeObject ();
294
- sentry_value_incref (nativeBreadcrumb);
295
- sentry_value_append (eventBreadcrumbs, nativeBreadcrumb);
296
- }
297
- }
298
- }
299
154
}
300
155
301
156
#endif
0 commit comments