mixpanel / mixpanel-flutter

Official Flutter Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
68 stars 75 forks source link

web: Running into NoSuchMethodError under build mode release #107

Open markusrubey opened 1 year ago

markusrubey commented 1 year ago
caught PlatformException(error, NoSuchMethodError: method not found: 'identify' (mixpanel.identify is not a function), null, null)
    at Object.f (http://localhost:8080/main.dart.js:5183:3)
    at agI.aj1 (http://localhost:8080/main.dart.js:86999:14)
    at http://localhost:8080/main.dart.js:87091:98
    at bq8.a (http://localhost:8080/main.dart.js:6454:62)
    at bq8.$2 (http://localhost:8080/main.dart.js:56414:14)
    at boF.$1 (http://localhost:8080/main.dart.js:56408:21)
    at asd.a5s (http://localhost:8080/main.dart.js:57087:34)
    at b9h.$0 (http://localhost:8080/main.dart.js:56699:11)
    at Object.KC (http://localhost:8080/main.dart.js:6564:40)
    at aV.yf (http://localhost:8080/main.dart.js:56631:3)
core_patch.dart:241 Uncaught PlatformException(error, NoSuchMethodError: method not found: 'set' on null, null, null)
    at Object.f (http://localhost:8080/main.dart.js:5183:3)
    at agI.aj1 (http://localhost:8080/main.dart.js:86999:14)
    at http://localhost:8080/main.dart.js:87091:98
    at bq8.a (http://localhost:8080/main.dart.js:6454:62)
    at bq8.$2 (http://localhost:8080/main.dart.js:56414:14)
    at boF.$1 (http://localhost:8080/main.dart.js:56408:21)
    at asd.a5s (http://localhost:8080/main.dart.js:57087:34)
    at b9h.$0 (http://localhost:8080/main.dart.js:56699:11)
    at Object.KC (http://localhost:8080/main.dart.js:6564:40)
    at aV.yf (http://localhost:8080/main.dart.js:56631:3)
2core_patch.dart:241 Uncaught PlatformException(error, NoSuchMethodError: method not found: 'register' (mixpanel.register is not a function), null, null)
    at Object.f (http://localhost:8080/main.dart.js:5183:3)
    at agI.aj1 (http://localhost:8080/main.dart.js:86999:14)
    at http://localhost:8080/main.dart.js:87091:98
    at bq8.a (http://localhost:8080/main.dart.js:6454:62)
    at bq8.$2 (http://localhost:8080/main.dart.js:56414:14)
    at boF.$1 (http://localhost:8080/main.dart.js:56408:21)
    at asd.a5s (http://localhost:8080/main.dart.js:57087:34)
    at b9h.$0 (http://localhost:8080/main.dart.js:56699:11)
    at Object.KC (http://localhost:8080/main.dart.js:6564:40)
    at aV.yf (http://localhost:8080/main.dart.js:56631:3)

I followed the set up instructions from pub dev and also checked your example here. I have no issues under debug. My call to Mixpanel.init throws no error.

I noticed I am missing some functionality in my main.dart.js when comparing:

Mixpanel Example main.dart.js ```js A.Mixpanel.prototype = { hasOptedOutTracking$0() { var $async$goto = 0, $async$completer = A._makeAsyncAwaitCompleter(type$.nullable_bool), $async$returnValue; var $async$hasOptedOutTracking$0 = A._wrapJsFunctionForAsync(function($async$errorCode, $async$result) { if ($async$errorCode === 1) return A._asyncRethrow($async$result, $async$completer); while (true) switch ($async$goto) { case 0: // Function start $async$goto = 3; return A._asyncAwait(B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("hasOptedOutTracking", null, false, type$.bool), $async$hasOptedOutTracking$0); case 3: // returning from await. $async$returnValue = $async$result; // goto return $async$goto = 1; break; case 1: // return return A._asyncReturn($async$returnValue, $async$completer); } }); return A._asyncStartSync($async$hasOptedOutTracking$0, $async$completer); }, identify$1(distinctId) { if (distinctId.length !== 0) B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("identify", A.LinkedHashMap_LinkedHashMap$_literal(["distinctId", distinctId], type$.String, type$.dynamic), false, type$.void); else A.log0("`identify` failed: distinctId cannot be blank", "Mixpanel"); }, alias$2(alias, distinctId) { if (alias.length === 0) { A.log0("`alias` failed: alias cannot be blank", "mixpanel"); return; } if (distinctId.length === 0) { A.log0("`alias` failed: distinctId cannot be blank", "Mixpanel"); return; } B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("alias", A.LinkedHashMap_LinkedHashMap$_literal(["alias", alias, "distinctId", distinctId], type$.String, type$.dynamic), false, type$.void); }, track$2$properties(_, eventName, properties) { if (eventName.length !== 0) B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("track", A.LinkedHashMap_LinkedHashMap$_literal(["eventName", eventName, "properties", properties], type$.String, type$.dynamic), false, type$.void); else A.log0("`track` failed: eventName cannot be blank", "Mixpanel"); }, track$1($receiver, eventName) { return this.track$2$properties($receiver, eventName, null); }, getSuperProperties$0() { var $async$goto = 0, $async$completer = A._makeAsyncAwaitCompleter(type$.nullable_Map_dynamic_dynamic), $async$returnValue; var $async$getSuperProperties$0 = A._wrapJsFunctionForAsync(function($async$errorCode, $async$result) { if ($async$errorCode === 1) return A._asyncRethrow($async$result, $async$completer); while (true) switch ($async$goto) { case 0: // Function start $async$goto = 3; return A._asyncAwait(B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("getSuperProperties", null, false, type$.Map_dynamic_dynamic), $async$getSuperProperties$0); case 3: // returning from await. $async$returnValue = $async$result; // goto return $async$goto = 1; break; case 1: // return return A._asyncReturn($async$returnValue, $async$completer); } }); return A._asyncStartSync($async$getSuperProperties$0, $async$completer); }, getDistinctId$0() { var t1 = type$.String; return B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("getDistinctId", null, false, t1).then$1$1(new A.Mixpanel_getDistinctId_closure(), t1); }, flush$0(_) { var $async$goto = 0, $async$completer = A._makeAsyncAwaitCompleter(type$.void); var $async$flush$0 = A._wrapJsFunctionForAsync(function($async$errorCode, $async$result) { if ($async$errorCode === 1) return A._asyncRethrow($async$result, $async$completer); while (true) switch ($async$goto) { case 0: // Function start $async$goto = 2; return A._asyncAwait(B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("flush", null, false, type$.dynamic), $async$flush$0); case 2: // returning from await. // implicit return return A._asyncReturn(null, $async$completer); } }); return A._asyncStartSync($async$flush$0, $async$completer); } }; ```
My Project main.dart.js ```js A.Mixpanel.prototype = { track$2$properties(_, eventName, properties) { if (eventName.length !== 0) B.MethodChannel_0nx._invokeMethod$1$3$arguments$missingOk("track", A.LinkedHashMap_LinkedHashMap$_literal(["eventName", eventName, "properties", properties], type$.String, type$.dynamic), false, type$.void); } }; ```
bselwe commented 1 year ago

I am also running into the same issue in production. Did you find any solution to that @markusrubey?

minified:jI: PlatformException(error, NoSuchMethodError: method not found: 'track' (mixpanel.track is not a function. (In 'mixpanel.track(o,A.ae(r))', 'mixpanel.track' is undefined)), null, null)

cc @zihejia

DavidRG13 commented 10 months ago

Hi @bselwe, @zihejia and @markusrubey I am facing this issue while running version 2.2.0 of the library locally in Chrome. Have you found a solution or workaround? Thank you!

adar2378 commented 7 months ago

Anyone found any fixes? Is this resolved in latest 2.3.0 version?

yelkamel commented 6 months ago

I have the same issue only on release mode for web.

And I'm block to the version 2.2.0 of mixpanel because to upgrade to 2.3.0

I need to change to much package in my app ...

for the moment, I turned of mixpanel on web on my project :/