From 4dcf45c34d769199979e6de35b370947abdca255 Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Mon, 27 Oct 2025 13:11:44 +0100 Subject: [PATCH 1/6] Add test to reproduce Issue #393 --- test/issues/issue_393_test.dart | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/issues/issue_393_test.dart diff --git a/test/issues/issue_393_test.dart b/test/issues/issue_393_test.dart new file mode 100644 index 00000000..79cdb759 --- /dev/null +++ b/test/issues/issue_393_test.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:wiredash/wiredash.dart'; + +import '../util/robot.dart'; + +void main() { + group('issue 393', () { + testWidgets('metadata should be encapsulated per opened Wiredash Feedback', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + CustomizableWiredashMetaData? metadata; + await robot.launchApp( + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.modifyMetaData((metaData) { + return metadata = metaData + ..custom[customMetaData.key] = customMetaData.value; + }); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); + await robot.openWiredash(); + expect(metadata!.custom['foo'], 'bar'); + await robot.closeWiredash(); + + customMetaData = const MapEntry('bar', 'foo'); + await robot.openWiredash(); + expect(metadata!.custom.length, 1); + expect(metadata!.custom['bar'], 'foo'); + }); + }); +} From e7bc5d7aff4ab6642c9609578dd4f2afc79dc198 Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Mon, 27 Oct 2025 15:03:43 +0100 Subject: [PATCH 2/6] fix issue --- lib/src/core/wiredash_controller.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/core/wiredash_controller.dart b/lib/src/core/wiredash_controller.dart index ed987d03..a0db62b1 100644 --- a/lib/src/core/wiredash_controller.dart +++ b/lib/src/core/wiredash_controller.dart @@ -173,6 +173,10 @@ class WiredashController { final result = FeedbackResult( hasSubmittedFeedback: hasSubmittedFeedback, ); + + // reset the metadata at the end of the feedback flow to avoid leaking metadata between feedbacks + resetMetaData(); + return result; } From 1e9c7eb7f7c99aec2552bfa7d5062c08f2a29115 Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Mon, 27 Oct 2025 19:26:33 +0100 Subject: [PATCH 3/6] update test cases --- test/issues/issue_393_test.dart | 206 ++++++++++++++++++++++++++++++-- 1 file changed, 197 insertions(+), 9 deletions(-) diff --git a/test/issues/issue_393_test.dart b/test/issues/issue_393_test.dart index 79cdb759..17cd3490 100644 --- a/test/issues/issue_393_test.dart +++ b/test/issues/issue_393_test.dart @@ -1,19 +1,142 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:wiredash/src/feedback/feedback_model.dart'; import 'package:wiredash/wiredash.dart'; +import '../util/invocation_catcher.dart'; import '../util/robot.dart'; void main() { group('issue 393', () { - testWidgets('metadata should be encapsulated per opened Wiredash Feedback', + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with collectMetaData', (tester) async { final robot = WiredashTestRobot(tester); MapEntry customMetaData = const MapEntry('foo', 'bar'); - CustomizableWiredashMetaData? metadata; await robot.launchApp( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.modifyMetaData((metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); + + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); + + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); + + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with feedbackOptions.collectMetaData', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + await robot.launchApp( + feedbackOptions: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + ), + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.modifyMetaData((metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); + + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); + + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(2)); + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); + + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with feedbackOptions.collectMetaData', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + await robot.launchApp( + feedbackOptions: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + ), builder: (context) { return Scaffold( body: Column( @@ -22,7 +145,7 @@ void main() { onTap: () async { final wiredash = Wiredash.of(context); wiredash.modifyMetaData((metaData) { - return metadata = metaData + return metaData ..custom[customMetaData.key] = customMetaData.value; }); wiredash.show(); @@ -34,14 +157,79 @@ void main() { ); }, ); - await robot.openWiredash(); - expect(metadata!.custom['foo'], 'bar'); - await robot.closeWiredash(); + + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); customMetaData = const MapEntry('bar', 'foo'); - await robot.openWiredash(); - expect(metadata!.custom.length, 1); - expect(metadata!.custom['bar'], 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(2)); + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); + + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with setUserData', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + await robot.launchApp( + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.modifyMetaData((metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); + + robot.wiredashController.setUserProperties( + userEmail: "user@mail.com", + userId: "123", + ); + + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); + + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(1)); + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); }); }); } From b8920c93b8d4897d7f1bc90f6b3dd74c603217c2 Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Thu, 30 Oct 2025 10:13:54 +0100 Subject: [PATCH 4/6] make tests more comprehensive to test more cases --- test/issues/issue_393_test.dart | 374 +++++++++++++++++++------------- 1 file changed, 225 insertions(+), 149 deletions(-) diff --git a/test/issues/issue_393_test.dart b/test/issues/issue_393_test.dart index 17cd3490..1cd83609 100644 --- a/test/issues/issue_393_test.dart +++ b/test/issues/issue_393_test.dart @@ -8,175 +8,250 @@ import '../util/robot.dart'; void main() { group('issue 393', () { - testWidgets( - 'metadata should be encapsulated per opened Wiredash Feedback and be merged with collectMetaData', - (tester) async { - final robot = WiredashTestRobot(tester); + group('collectMetaData', () { + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with collectMetaData and modifyMetaData', + (tester) async { + final robot = WiredashTestRobot(tester); - MapEntry customMetaData = const MapEntry('foo', 'bar'); + MapEntry customMetaData = const MapEntry('foo', 'bar'); - await robot.launchApp( - collectMetaData: (metaData) { - return metaData - ..userEmail = "user@mail.com" - ..userId = "123" - ..custom['foz'] = 'baz'; - }, - builder: (context) { - return Scaffold( - body: Column( - children: [ - GestureDetector( - onTap: () async { - final wiredash = Wiredash.of(context); - wiredash.modifyMetaData((metaData) { - return metaData - ..custom[customMetaData.key] = customMetaData.value; - }); - wiredash.show(); - }, - child: const Text('Feedback'), - ), - ], - ), - ); - }, - ); + await robot.launchApp( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); - await robot.submitMinimalFeedback(); - AssertableInvocation latestCall = - robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final firstFeedback = latestCall[0] as FeedbackItem?; - expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); - expect(firstFeedback.metadata.userId, '123'); - expect(firstFeedback.metadata.custom!['foz'], 'baz'); - expect(firstFeedback.metadata.custom!['foo'], 'bar'); + wiredash.modifyMetaData( + (metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }, + ); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); - customMetaData = const MapEntry('bar', 'foo'); + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; - await robot.submitMinimalFeedback(); - latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final secondFeedback = latestCall[0] as FeedbackItem?; - expect(secondFeedback!.metadata.userEmail, 'user@mail.com'); - expect(secondFeedback.metadata.userId, '123'); - expect(secondFeedback.metadata.custom!['foz'], 'baz'); - expect(secondFeedback.metadata.custom!['bar'], 'foo'); - }); + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); - testWidgets( - 'metadata should be encapsulated per opened Wiredash Feedback and be merged with feedbackOptions.collectMetaData', - (tester) async { - final robot = WiredashTestRobot(tester); + customMetaData = const MapEntry('bar', 'foo'); - MapEntry customMetaData = const MapEntry('foo', 'bar'); + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(2)); - await robot.launchApp( - feedbackOptions: WiredashFeedbackOptions( + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); + + testWidgets( + 'metadata should be encapsulated per opened Wiredash Feedback and be merged with collectMetaData', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + await robot.launchApp( collectMetaData: (metaData) { return metaData ..userEmail = "user@mail.com" ..userId = "123" ..custom['foz'] = 'baz'; }, - ), - builder: (context) { - return Scaffold( - body: Column( - children: [ - GestureDetector( - onTap: () async { - final wiredash = Wiredash.of(context); - wiredash.modifyMetaData((metaData) { - return metaData - ..custom[customMetaData.key] = customMetaData.value; - }); - wiredash.show(); - }, - child: const Text('Feedback'), - ), - ], - ), - ); - }, - ); + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.show( + options: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..custom[customMetaData.key] = + customMetaData.value; + }, + ), + ); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); - await robot.submitMinimalFeedback(); - AssertableInvocation latestCall = - robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final firstFeedback = latestCall[0] as FeedbackItem?; - expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); - expect(firstFeedback.metadata.userId, '123'); - expect(firstFeedback.metadata.custom!['foz'], 'baz'); - expect(firstFeedback.metadata.custom!['foo'], 'bar'); + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; - customMetaData = const MapEntry('bar', 'foo'); + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); - await robot.submitMinimalFeedback(); - latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final secondFeedback = latestCall[0] as FeedbackItem?; - expect(secondFeedback!.metadata.custom, hasLength(2)); - expect(secondFeedback.metadata.userEmail, 'user@mail.com'); - expect(secondFeedback.metadata.userId, '123'); - expect(secondFeedback.metadata.custom!['foz'], 'baz'); - expect(secondFeedback.metadata.custom!['bar'], 'foo'); + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + + expect(secondFeedback!.metadata.custom, hasLength(2)); + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); }); + group('WiredashFeedbackOptions.collectMetaData', () { + testWidgets(''' + metadata should be encapsulated per opened Wiredash Feedback + and be merged with WiredashFeedbackOptions.collectMetaData when calling modifyMetaData''', + (tester) async { + final robot = WiredashTestRobot(tester); - testWidgets( - 'metadata should be encapsulated per opened Wiredash Feedback and be merged with feedbackOptions.collectMetaData', - (tester) async { - final robot = WiredashTestRobot(tester); + MapEntry customMetaData = const MapEntry('foo', 'bar'); - MapEntry customMetaData = const MapEntry('foo', 'bar'); + await robot.launchApp( + feedbackOptions: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + ), + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.modifyMetaData( + (metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }, + ); + wiredash.show(); + }, + child: const Text('Feedback'), + ), + ], + ), + ); + }, + ); - await robot.launchApp( - feedbackOptions: WiredashFeedbackOptions( - collectMetaData: (metaData) { - return metaData - ..userEmail = "user@mail.com" - ..userId = "123" - ..custom['foz'] = 'baz'; + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; + + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); + expect(firstFeedback.metadata.userId, '123'); + expect(firstFeedback.metadata.custom!['foz'], 'baz'); + expect(firstFeedback.metadata.custom!['foo'], 'bar'); + + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(2)); + expect(secondFeedback.metadata.userEmail, 'user@mail.com'); + expect(secondFeedback.metadata.userId, '123'); + expect(secondFeedback.metadata.custom!['foz'], 'baz'); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); + + testWidgets(''' + metadata should be encapsulated per opened Wiredash Feedback + and feedbackOptions of show should override WiredashFeedbackOptions.collectMetaData''', + (tester) async { + final robot = WiredashTestRobot(tester); + + MapEntry customMetaData = const MapEntry('foo', 'bar'); + + await robot.launchApp( + feedbackOptions: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..userEmail = "user@mail.com" + ..userId = "123" + ..custom['foz'] = 'baz'; + }, + ), + builder: (context) { + return Scaffold( + body: Column( + children: [ + GestureDetector( + onTap: () async { + final wiredash = Wiredash.of(context); + wiredash.show( + options: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..custom[customMetaData.key] = + customMetaData.value; + }, + ), + ); + }, + child: const Text('Feedback'), + ), + ], + ), + ); }, - ), - builder: (context) { - return Scaffold( - body: Column( - children: [ - GestureDetector( - onTap: () async { - final wiredash = Wiredash.of(context); - wiredash.modifyMetaData((metaData) { - return metaData - ..custom[customMetaData.key] = customMetaData.value; - }); - wiredash.show(); - }, - child: const Text('Feedback'), - ), - ], - ), - ); - }, - ); + ); - await robot.submitMinimalFeedback(); - AssertableInvocation latestCall = - robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final firstFeedback = latestCall[0] as FeedbackItem?; - expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); - expect(firstFeedback.metadata.userId, '123'); - expect(firstFeedback.metadata.custom!['foz'], 'baz'); - expect(firstFeedback.metadata.custom!['foo'], 'bar'); + await robot.submitMinimalFeedback(); + AssertableInvocation latestCall = + robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final firstFeedback = latestCall[0] as FeedbackItem?; - customMetaData = const MapEntry('bar', 'foo'); + expect(firstFeedback!.metadata.custom!['foo'], 'bar'); - await robot.submitMinimalFeedback(); - latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; - final secondFeedback = latestCall[0] as FeedbackItem?; - expect(secondFeedback!.metadata.custom, hasLength(2)); - expect(secondFeedback.metadata.userEmail, 'user@mail.com'); - expect(secondFeedback.metadata.userId, '123'); - expect(secondFeedback.metadata.custom!['foz'], 'baz'); - expect(secondFeedback.metadata.custom!['bar'], 'foo'); + customMetaData = const MapEntry('bar', 'foo'); + + await robot.submitMinimalFeedback(); + latestCall = robot.mockServices.mockApi.sendFeedbackInvocations.latest; + final secondFeedback = latestCall[0] as FeedbackItem?; + expect(secondFeedback!.metadata.custom, hasLength(1)); + expect(secondFeedback.metadata.custom!['bar'], 'foo'); + }); }); testWidgets( @@ -194,11 +269,12 @@ void main() { GestureDetector( onTap: () async { final wiredash = Wiredash.of(context); - wiredash.modifyMetaData((metaData) { - return metaData - ..custom[customMetaData.key] = customMetaData.value; - }); - wiredash.show(); + wiredash.show(options: WiredashFeedbackOptions( + collectMetaData: (metaData) { + return metaData + ..custom[customMetaData.key] = customMetaData.value; + }, + )); }, child: const Text('Feedback'), ), From 0431547467026690c7697d9fbfe463934508d2ec Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Thu, 30 Oct 2025 10:14:19 +0100 Subject: [PATCH 5/6] approach reseting metadata more gracefully --- lib/src/core/wiredash_controller.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/core/wiredash_controller.dart b/lib/src/core/wiredash_controller.dart index a0db62b1..38a1e666 100644 --- a/lib/src/core/wiredash_controller.dart +++ b/lib/src/core/wiredash_controller.dart @@ -150,6 +150,7 @@ class WiredashController { bool? inheritCupertinoTheme, WiredashFeedbackOptions? options, }) async { + print(options != null); _captureAppTheme(inheritMaterialTheme, inheritCupertinoTheme); _captureSessionMetaData(); _model.feedbackOptionsOverride = options; @@ -175,7 +176,8 @@ class WiredashController { ); // reset the metadata at the end of the feedback flow to avoid leaking metadata between feedbacks - resetMetaData(); + _model.customizableMetaData = + _model.customizableMetaData.copyWith(custom: {}); return result; } From 6ac4e0ffa07f1023aed4995f8f6e6a397a83cbe0 Mon Sep 17 00:00:00 2001 From: Justin Giering Date: Thu, 30 Oct 2025 10:16:49 +0100 Subject: [PATCH 6/6] test if function gets called --- test/issues/issue_393_test.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/issues/issue_393_test.dart b/test/issues/issue_393_test.dart index 1cd83609..2577c550 100644 --- a/test/issues/issue_393_test.dart +++ b/test/issues/issue_393_test.dart @@ -77,6 +77,8 @@ void main() { MapEntry customMetaData = const MapEntry('foo', 'bar'); + int collectMetaDataFunctionCalls = 0; + await robot.launchApp( collectMetaData: (metaData) { return metaData @@ -94,6 +96,7 @@ void main() { wiredash.show( options: WiredashFeedbackOptions( collectMetaData: (metaData) { + collectMetaDataFunctionCalls++; return metaData ..custom[customMetaData.key] = customMetaData.value; @@ -114,6 +117,8 @@ void main() { robot.mockServices.mockApi.sendFeedbackInvocations.latest; final firstFeedback = latestCall[0] as FeedbackItem?; + expect(collectMetaDataFunctionCalls, 1); // we fail here + expect(firstFeedback!.metadata.userEmail, 'user@mail.com'); expect(firstFeedback.metadata.userId, '123'); expect(firstFeedback.metadata.custom!['foz'], 'baz');