samzilverberg / cordova-mixpanel-plugin

A Cordova Plugin that wraps Mixpanel's sdk
MIT License
78 stars 98 forks source link

Encountered an uncaught exception. All Mixpanel instances were archived #93

Closed Sampath-Lokuge closed 6 years ago

Sampath-Lokuge commented 6 years ago

Hi,

iOS app crashes on iPhone due to the mixpanel plugin. This is happening on app's login use case. Please see the below code snippet too. It is working fine on an Android device. I have removed and add the plugin and iOS platform too. But the same issue. Can you tell me what is the workaround for this? Thanks.

> ionic info

Ionic:

   ionic (Ionic CLI)  : 4.0.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : ios 4.5.4

System:

   ios-deploy : 2.0.0
   NodeJS     : v8.11.3 (/usr/local/bin/node)
   npm        : 5.6.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : not set

package.json

{
    "name": "ambassador",
    "version": "3.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "config": {
        "ionic_copy": "./config/copy.config.js"
    },
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@agm/core": "^1.0.0-beta.2",
        "@angular/common": "5.0.3",
        "@angular/compiler": "5.0.3",
        "@angular/compiler-cli": "5.0.3",
        "@angular/core": "5.0.3",
        "@angular/forms": "5.0.3",
        "@angular/http": "5.0.3",
        "@angular/platform-browser": "5.0.3",
        "@angular/platform-browser-dynamic": "5.0.3",
        "@ionic-native/app-version": "^4.11.0",
        "@ionic-native/background-mode": "^4.8.0",
        "@ionic-native/camera": "^4.5.2",
        "@ionic-native/clipboard": "^4.9.1",
        "@ionic-native/contacts": "^4.7.0",
        "@ionic-native/core": "^4.14.0",
        "@ionic-native/deeplinks": "^4.5.2",
        "@ionic-native/document-viewer": "^4.11.0",
        "@ionic-native/facebook": "^4.12.2",
        "@ionic-native/file": "^4.5.2",
        "@ionic-native/file-opener": "^4.11.0",
        "@ionic-native/file-transfer": "^4.11.0",
        "@ionic-native/geolocation": "^4.5.2",
        "@ionic-native/google-maps": "^4.14.0",
        "@ionic-native/image-resizer": "^4.7.0",
        "@ionic-native/in-app-browser": "^4.12.0",
        "@ionic-native/keyboard": "^4.11.0",
        "@ionic-native/location-accuracy": "^4.5.2",
        "@ionic-native/mixpanel": "^4.15.0",
        "@ionic-native/music-controls": "^4.8.0",
        "@ionic-native/onesignal": "^4.15.0",
        "@ionic-native/screen-orientation": "^4.11.0",
        "@ionic-native/social-sharing": "^4.9.1",
        "@ionic-native/splash-screen": "4.4.0",
        "@ionic-native/status-bar": "4.4.0",
        "@ionic/pro": "^1.0.20",
        "@ionic/storage": "2.1.3",
        "@vimeo/player": "^2.6.3",
        "angular-progress-bar": "^1.0.3",
        "angular2-google-place": "^2.0.2",
        "angular2-jwt": "^0.2.3",
        "angularfire2": "5.0.0-rc.6",
        "animate.css": "^3.5.2",
        "com.synconset.imagepicker": "^2.1.10",
        "cordova-android": "6.4.0",
        "cordova-clipboard": "^1.2.1",
        "cordova-ios": "4.5.4",
        "cordova-plugin-app-version": "^0.1.9",
        "cordova-plugin-background-mode": "git+https://github.com/katzer/cordova-plugin-background-mode.git",
        "cordova-plugin-camera": "^4.0.3",
        "cordova-plugin-contacts": "^3.0.1",
        "cordova-plugin-device": "^2.0.2",
        "cordova-plugin-facebook4": "^2.5.0",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-file-opener2": "^2.0.19",
        "cordova-plugin-file-transfer": "^1.7.1",
        "cordova-plugin-geolocation": "^4.0.1",
        "cordova-plugin-googlemaps": "^2.4.6",
        "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git#2.6.0",
        "cordova-plugin-inappbrowser": "^3.0.0",
        "cordova-plugin-ionic-webview": "^1.2.1",
        "cordova-plugin-mixpanel": "^4.5.0",
        "cordova-plugin-music-controls": "^2.1.4",
        "cordova-plugin-request-location-accuracy": "^2.2.3",
        "cordova-plugin-screen-orientation": "^3.0.1",
        "cordova-plugin-splashscreen": "^5.0.2",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "cordova-plugin-x-socialsharing": "^5.4.1",
        "cordova-sqlite-storage": "^2.4.0",
        "css-animator": "^2.3.0",
        "es6-promise-plugin": "^4.2.2",
        "firebase": "4.8.2",
        "google-maps": "^3.2.1",
        "info.protonet.imageresizer": "^0.1.1",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionic2-auto-complete": "^1.6.2-alpha",
        "ionic2-google-places-autocomplete": "^1.0.2",
        "ionicons": "3.0.0",
        "jwt-decode": "^2.2.0",
        "list": "1.0.0",
        "ng4-geoautocomplete": "^0.1.0",
        "onesignal-cordova-plugin": "^2.4.4",
        "promise-polyfill": "^8.0.0",
        "pubnub": "^4.21.5",
        "pubnub-angular2": "^1.3.1",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "3.1.11",
        "typescript": "2.4.2"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "ionic-plugin-keyboard": {},
            "cordova-plugin-whitelist": {},
            "cordova-plugin-device": {},
            "cordova-plugin-camera": {
                "CAMERA_USAGE_DESCRIPTION": "Upload profile pic",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": "Upload profile pic",
                "PHOTO_LIBRARY_USAGE_DESCRIPTION": "App would like to access the library."
            },
            "cordova-plugin-file": {},
            "cordova-plugin-file-transfer": {},
            "cordova-plugin-geolocation": {
                "GEOLOCATION_USAGE_DESCRIPTION": "To locate your Location"
            },
            "cordova-plugin-contacts": {
                "CONTACTS_USAGE_DESCRIPTION": "To invite Friends"
            },
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-request-location-accuracy": {},
            "cordova-plugin-statusbar": {},
            "info.protonet.imageresizer": {},
            "cordova-sqlite-storage": {},
            "cordova-plugin-ionic-webview": {},
            "cordova-plugin-music-controls": {},
            "cordova-plugin-background-mode": {},
            "cordova-clipboard": {},
            "cordova-plugin-x-socialsharing": {},
            "cordova-plugin-screen-orientation": {},
            "cordova-plugin-file-opener2": {},
            "cordova-plugin-app-version": {},
            "cordova-plugin-inappbrowser": {},
            "com.synconset.imagepicker": {
                "PHOTOLIBRARY_USAGE_DESCRIPTION": "App would like to access the library.",
                "PHOTO_LIBRARY_USAGE_DESCRIPTION": "App would like to access the library."
            },
            "cordova-plugin-facebook4": {
                "APP_ID": "2178440625814934",
                "APP_NAME": "You Are a CEO",
                "FACEBOOK_ANDROID_SDK_VERSION": "4.+"
            },
            "cordova-plugin-googlemaps": {
                "API_KEY_FOR_ANDROID": "AIzaSyA2uxgl_R0l-Ggpwp-DBCt5lb4k4CAgrp0",
                "API_KEY_FOR_IOS": "AIzaSyA2uxgl_R0l-Ggpwp-DBCt5lb4k4CAgrp0",
                "PLAY_SERVICES_VERSION": "15.0.1",
                "ANDROID_SUPPORT_V4_VERSION": "27.+"
            },
            "onesignal-cordova-plugin": {},
            "cordova-plugin-mixpanel": {}
        },
        "cordova-plugin-ionic": {
            "APP_ID": "7043185f",
            "CHANNEL_NAME": "Production",
            "UPDATE_METHOD": "background",
            "MAX_STORE": "2"
        },
        "cordova-plugin-ionic-webview": {},
        "platforms": [
            "android",
            "ios"
        ]
    },
    "platforms": [
        "android",
        "ios"
    ]
}

login.ts

  login() {
    this.user.signIn(signInData).subscribe((response: HttpResponse<any>) => {
      let res = response.body;
      if (!res.error) {
        if (this.platform.is('cordova')) {
          this.mixpanel.track('Login');
          this.mixpanelPeople.identify(res.token); //Here it emits the exception
          const properties = { 'Attribution Source': this.jwtHelper.decodeToken(res.token).id };
          this.mixpanelPeople.set(properties);
          this.mixpanel.getSuperProperties().then(oldProperties => {
            this.mixpanel.registerSuperProperties({ ...oldProperties, properties });
          });
        }
    }, (caughtError: HttpErrorResponse) => {

    })
  }

Run time error:

2018-09-29 19:30:14.974077+0530 You are a CEO[593:196484] CDVWKWebViewEngine: handleStopScroll
2018-09-29 19:30:17.236505+0530 You are a CEO[593:196484] Encountered an uncaught exception. All Mixpanel instances were archived.
2018-09-29 19:30:17.236625+0530 You are a CEO[593:196484] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0x1817fed8c 0x1809b85ec 0x181797750 0x1816c7810 0x1009bd170 0x100ed5814 0x1009996e0 0x100999544 0x10099af94 0x19150ba2c 0x1914a8734 0x1914aa8a4 0x191211d18 0x19145120c 0x1911d4cfc 0x1911d7704 0x188e3612c 0x188e363ec 0x1817a7404 0x1817a6c2c 0x1817a479c 0x1816c4da8 0x1836aa020 0x18b6e4758 0x1008a2884 0x181155fc0)
libc++abi.dylib: terminating with uncaught exception of type NSException

screen shot 2018-09-29 at 7 33 20 pm

samzilverberg commented 6 years ago

one> mixpanel.people.identify is long ago deprecated, so use mixpanel.identify.

two> your'e not passing in onSuccess and onFail functions to all your calls as required. try doing so and let me know if it solves your problem

window.mixpanel.identify(distinctId, usePeople, onSuccess, onFail)

samzilverberg commented 6 years ago

no response for quite a while, closing issue for now