-
Notifications
You must be signed in to change notification settings - Fork 101
Implement setLoggingEnabled for Flutter Web #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
setLoggingEnabled
case in the web plugin’s method handler and implementedhandleSetLoggingEnabled
to 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
handleSetLoggingEnabled
and verifying thatset_config
is called with the correct argument. Consider adding a test that calls the plugin handler (e.g., via aMethodCall
) and asserts the invocation ofset_config
withsafeJsify({'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 theMethodCall
arguments, 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
setLoggingEnabled
support for Flutter Web platform, which was previously throwing an "Unimplemented" error. The implementation follows the existing pattern used bysetServerURL
and uses the JavaScript library'sset_config
method with thedebug
parameter.Changes Made
1. Added Web Platform Support
setLoggingEnabled
case to the method handler switch statement inlib/mixpanel_flutter_web.dart
handleSetLoggingEnabled
method that callsset_config({'debug': loggingEnabled})
2. Implementation Details
3. Test Coverage
Technical Approach
The implementation follows the exact same pattern as the existing
setServerURL
method:set_config
JavaScript binding with appropriate parametersafeJsify
for 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.