Skip to content

Conversation

matehat
Copy link
Contributor

@matehat matehat commented May 28, 2025

Fix #185

@matehat matehat changed the title fix(#185): .jsify() error polluting console logs fix: .jsify() error polluting console logs May 28, 2025
@jaredmixpanel jaredmixpanel requested a review from Copilot May 29, 2025 23:11
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces a safeJsify helper to wrap calls to .jsify() and prevent console errors when converting unsupported types, and replaces direct .jsify() invocations across various methods with safeJsify.

  • Adds safeJsify function handling Map, List, DateTime, primitive types, and fallback
  • Updates all mixpanel-web API calls to use safeJsify instead of direct .jsify()
  • Provides null-safe fallbacks for configuration and properties
Comments suppressed due to low confidence (3)

lib/mixpanel_flutter_web.dart:8

  • There are no unit tests for the new safeJsify function. Consider adding tests for Maps, Lists, DateTime, primitives, null, and already-JSAny inputs to verify correct behavior.
JSAny? safeJsify(dynamic value) {

lib/mixpanel_flutter_web.dart:9

  • Consider handling JSAny instances first (if (value is JSAny) return value;) so existing JS bindings aren’t wrapped again, avoiding potential double conversion issues.
if (value is Map) {

lib/mixpanel_flutter_web.dart:8

  • Add an explicit if (value == null) return null; check at the start of safeJsify to ensure null inputs are consistently handled and avoid unintended fallbacks.
JSAny? safeJsify(dynamic value) {

import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:mixpanel_flutter/web/mixpanel_js_bindings.dart';

JSAny? safeJsify(dynamic value) {
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc comment for safeJsify explaining accepted input types, return values, and its null handling behavior to improve readability and maintainability.

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@jaredmixpanel jaredmixpanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jaredmixpanel
Copy link
Collaborator

Thank you!

@jaredmixpanel jaredmixpanel merged commit 6deedc8 into mixpanel:main May 29, 2025
3 checks passed
@jaredmixpanel jaredmixpanel added the bug Something isn't working label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.4.0 breaks flutter web in release mode
2 participants