Skip to content

Commit f33d4f9

Browse files
committed
Update
1 parent 9a99d54 commit f33d4f9

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

packages/dart/lib/src/hub.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ class Hub {
365365
}
366366
}
367367

368-
/// Adds a breacrumb to the current Scope
368+
/// Adds a breadcrumb to the current Scope
369369
Future<void> addBreadcrumb(Breadcrumb crumb, {Hint? hint}) async {
370370
if (!_isEnabled) {
371371
_options.log(

packages/dart/test/hub_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,45 @@ void main() {
550550
);
551551
});
552552

553+
test('setAttributes sets attributes on scope', () {
554+
hub.setAttributes({
555+
'attr1': SentryAttribute.string('value'),
556+
'attr2': SentryAttribute.int(42),
557+
'attr3': SentryAttribute.bool(true),
558+
'attr4': SentryAttribute.double(3.14)
559+
});
560+
hub.setAttributes({'merged': SentryAttribute.double(12)});
561+
562+
final attributes = hub.scope.attributes;
563+
expect(attributes, isNotEmpty);
564+
expect(attributes['attr1']?.value, SentryAttribute.string('value').value);
565+
expect(attributes['attr2']?.value, SentryAttribute.int(42).value);
566+
expect(attributes['attr3']?.value, SentryAttribute.bool(true).value);
567+
expect(attributes['attr4']?.value, SentryAttribute.double(3.14).value);
568+
expect(attributes['merged']?.value, SentryAttribute.double(12).value);
569+
});
570+
571+
test('removeAttribute removes attribute on scope', () {
572+
hub.setAttributes({
573+
'attr1': SentryAttribute.string('value'),
574+
'attr2': SentryAttribute.int(42),
575+
'attr3': SentryAttribute.bool(true),
576+
'attr4': SentryAttribute.double(3.14)
577+
});
578+
hub.setAttributes({'merged': SentryAttribute.double(12)});
579+
580+
hub.removeAttribute('attr3');
581+
hub.removeAttribute('merged');
582+
583+
final attributes = hub.scope.attributes;
584+
expect(attributes, isNotEmpty);
585+
expect(attributes['attr1']?.value, SentryAttribute.string('value').value);
586+
expect(attributes['attr2']?.value, SentryAttribute.int(42).value);
587+
expect(attributes['attr4']?.value, SentryAttribute.double(3.14).value);
588+
expect(attributes['attr3']?.value, isNull);
589+
expect(attributes['merged']?.value, isNull);
590+
});
591+
553592
test('should configure scope async', () async {
554593
await hub.configureScope((Scope scope) async {
555594
await Future.delayed(Duration(milliseconds: 10));

0 commit comments

Comments
 (0)