File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -360,7 +360,11 @@ class Sentry {
360
360
/// Gets the current active transaction or span bound to the scope.
361
361
static ISentrySpan ? getSpan () => _hub.getSpan ();
362
362
363
- static Future <void > addFeatureFlag (String name, bool value) async {
363
+ static Future <void > addFeatureFlag (String name, dynamic value) async {
364
+ if (value is ! bool ) {
365
+ return ;
366
+ }
367
+
364
368
final featureFlagsIntegration = currentHub.options.integrations
365
369
.whereType <FeatureFlagsIntegration >()
366
370
.firstOrNull;
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ void main() {
301
301
);
302
302
}, onPlatform: {'vm' : Skip ()});
303
303
304
- test ('should add feature flagg FeatureFlagsIntegration' , () async {
304
+ test ('should add feature flag FeatureFlagsIntegration' , () async {
305
305
await Sentry .init (
306
306
options: defaultTestOptions (),
307
307
(options) => options.dsn = fakeDsn,
@@ -321,6 +321,21 @@ void main() {
321
321
);
322
322
});
323
323
324
+ test ('addFeatureFlag should ignore non-boolean values' , () async {
325
+ await Sentry .init (
326
+ options: defaultTestOptions (),
327
+ (options) => options.dsn = fakeDsn,
328
+ );
329
+
330
+ await Sentry .addFeatureFlag ('foo1' , 'some string' );
331
+ await Sentry .addFeatureFlag ('foo2' , 123 );
332
+ await Sentry .addFeatureFlag ('foo3' , 1.23 );
333
+
334
+ final featureFlagsContext =
335
+ Sentry .currentHub.scope.contexts[SentryFeatureFlags .type];
336
+ expect (featureFlagsContext, isNull);
337
+ });
338
+
324
339
test ('should close integrations' , () async {
325
340
final integration = MockIntegration ();
326
341
You can’t perform that action at this time.
0 commit comments