@@ -11,6 +11,7 @@ use uuid::Uuid;
11
11
use api:: Dsn ;
12
12
use backtrace_support:: { function_starts_with, is_sys_function} ;
13
13
use constants:: { SDK_INFO , USER_AGENT } ;
14
+ use protocol:: map:: Entry ;
14
15
use protocol:: { Context , DebugMeta , Event } ;
15
16
use scope:: { bind_client, Scope } ;
16
17
use transport:: Transport ;
@@ -283,6 +284,10 @@ impl Client {
283
284
} ;
284
285
}
285
286
287
+ let mut add_os = true ;
288
+ let mut add_rust = true ;
289
+ let mut add_device = true ;
290
+
286
291
if let Some ( scope) = scope {
287
292
if !scope. breadcrumbs . is_empty ( ) {
288
293
event
@@ -311,10 +316,6 @@ impl Client {
311
316
. extend ( scope. tags . iter ( ) . map ( |( k, v) | ( ( * k) . clone ( ) , ( * v) . clone ( ) ) ) ) ;
312
317
}
313
318
314
- let mut add_os = true ;
315
- let mut add_rust = true ;
316
- let mut add_device = true ;
317
-
318
319
for ( key, value) in scope. contexts . iter ( ) {
319
320
match * value {
320
321
None => match key. as_str ( ) {
@@ -332,33 +333,6 @@ impl Client {
332
333
}
333
334
}
334
335
335
- if add_os {
336
- if let Some ( ref os) = CONTEXT_DEFAULTS . os {
337
- event
338
- . contexts
339
- . entry ( "os" . to_string ( ) )
340
- . or_insert_with ( || os. clone ( ) ) ;
341
- }
342
- }
343
-
344
- if add_rust {
345
- if let Some ( ref rust) = CONTEXT_DEFAULTS . rust {
346
- event
347
- . contexts
348
- . entry ( "rust" . to_string ( ) )
349
- . or_insert_with ( || rust. clone ( ) ) ;
350
- }
351
- }
352
-
353
- if add_device {
354
- if let Some ( ref device) = CONTEXT_DEFAULTS . device {
355
- event
356
- . contexts
357
- . entry ( "device" . to_string ( ) )
358
- . or_insert_with ( || device. clone ( ) ) ;
359
- }
360
- }
361
-
362
336
if event. transaction . is_none ( ) {
363
337
if let Some ( ref txn) = scope. transaction {
364
338
event. transaction = Some ( ( * * txn) . clone ( ) ) ;
@@ -375,6 +349,30 @@ impl Client {
375
349
}
376
350
}
377
351
352
+ if add_os {
353
+ if let Entry :: Vacant ( entry) = event. contexts . entry ( "os" . to_string ( ) ) {
354
+ if let Some ( ref os) = CONTEXT_DEFAULTS . os {
355
+ entry. insert ( os. clone ( ) ) ;
356
+ }
357
+ }
358
+ }
359
+
360
+ if add_rust {
361
+ if let Entry :: Vacant ( entry) = event. contexts . entry ( "rust" . to_string ( ) ) {
362
+ if let Some ( ref rust) = CONTEXT_DEFAULTS . rust {
363
+ entry. insert ( rust. clone ( ) ) ;
364
+ }
365
+ }
366
+ }
367
+
368
+ if add_device {
369
+ if let Entry :: Vacant ( entry) = event. contexts . entry ( "device" . to_string ( ) ) {
370
+ if let Some ( ref device) = CONTEXT_DEFAULTS . device {
371
+ entry. insert ( device. clone ( ) ) ;
372
+ }
373
+ }
374
+ }
375
+
378
376
if event. release . is_none ( ) {
379
377
event. release = self . options . release . clone ( ) ;
380
378
}
0 commit comments