Conversation
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements Flutter Web support for setLoggingEnabled by invoking the JavaScript set_config API with a debug flag and adds a basic unit test for the new method.
- Added a
setLoggingEnabledcase in the web plugin’s method handler and implementedhandleSetLoggingEnabledto callset_config({'debug': loggingEnabled})viasafeJsify. - Included a new test to verify the argument structure for
loggingEnabled.
Reviewed Changes
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/mixpanel_flutter_web.dart | Added setLoggingEnabled case and handleSetLoggingEnabled implementation |
| test/mixpanel_flutter_web_unit_test.dart | Added unit test for setLoggingEnabled argument structure |
Comments suppressed due to low confidence (2)
test/mixpanel_flutter_web_unit_test.dart:212
- The new test only checks a literal args map instead of invoking
handleSetLoggingEnabledand verifying thatset_configis called with the correct argument. Consider adding a test that calls the plugin handler (e.g., via aMethodCall) and asserts the invocation ofset_configwithsafeJsify({'debug': true}).
test('setLoggingEnabled method structure', () {
lib/mixpanel_flutter_web.dart:213
- [nitpick] Consider adding a short dartdoc comment for
handleSetLoggingEnabled, describing its purpose and the expected structure of theMethodCallarguments, to improve maintainability and clarity.
void handleSetLoggingEnabled(MethodCall call) {
|
The new test only checks a literal args map instead of invoking handleSetLoggingEnabled and verifying that set_config is called with the correct argument. Add a test that calls the plugin handler (e.g., via a MethodCall) and asserts the invocation of set_config with safeJsify({'debug': true}). Add a short dartdoc comment for handleSetLoggingEnabled, describing its purpose and the expected structure of the MethodCall arguments, to improve maintainability and clarity. |
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
Added dartdoc comment for handleSetLoggingEnabled and improved test that verifies MethodCall processing and the correct parameter structure passed to set_config. The test validates both true and false values are handled correctly. Commit: 7a8b2cd |
Summary
This PR implements
setLoggingEnabledsupport for Flutter Web platform, which was previously throwing an "Unimplemented" error. The implementation follows the existing pattern used bysetServerURLand uses the JavaScript library'sset_configmethod with thedebugparameter.Changes Made
1. Added Web Platform Support
setLoggingEnabledcase to the method handler switch statement inlib/mixpanel_flutter_web.darthandleSetLoggingEnabledmethod that callsset_config({'debug': loggingEnabled})2. Implementation Details
3. Test Coverage
Technical Approach
The implementation follows the exact same pattern as the existing
setServerURLmethod:set_configJavaScript binding with appropriate parametersafeJsifyfor proper JavaScript interopBefore:
After:
Verification
Fixes #201.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.