@@ -174,7 +174,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
174174 profileUnsetPushId (list );
175175 break ;
176176 case "init" :
177- startWithConfig (list );
177+ startWithConfig (list , result );
178178 break ;
179179 default :
180180 result .notImplemented ();
@@ -490,86 +490,90 @@ private void profileUnsetPushId(List list) {
490490 SensorsDataAPI .sharedInstance ().profileUnsetPushId ((String ) list .get (0 ));
491491 }
492492
493- private void startWithConfig (List list ) {
494- Map map = (Map ) list .get (0 );
495- Object serverUrl = map .get ("serverUrl" );
496-
497- SAConfigOptions configOptions = new SAConfigOptions (serverUrl == null ? "" : serverUrl .toString ());
498- Object autotrackTypes = map .get ("autotrackTypes" );
499- if (autotrackTypes != null ) {
500- configOptions .setAutoTrackEventType ((Integer ) autotrackTypes );
501- }
502-
503- Object networkTypes = map .get ("networkTypes" );
504- if (networkTypes != null ) {
505- configOptions .setNetworkTypePolicy ((Integer ) networkTypes );
506- }
507-
508- Object flushInterval = map .get ("flushInterval" );
509- if (flushInterval != null ) {
510- configOptions .setFlushInterval ((Integer ) flushInterval );
511- }
493+ private void startWithConfig (List list , Result result ) {
494+ try {
495+ Map map = (Map ) list .get (0 );
496+ Object serverUrl = map .get ("serverUrl" );
512497
513- Object flushBulkSize = map .get ("flushBulkSize" );
514- if (flushBulkSize != null ) {
515- configOptions .setFlushBulkSize ((Integer ) flushBulkSize );
516- }
498+ SAConfigOptions configOptions = new SAConfigOptions (serverUrl == null ? "" : serverUrl .toString ());
499+ Object autotrackTypes = map .get ("autotrackTypes" );
500+ if (autotrackTypes != null ) {
501+ configOptions .setAutoTrackEventType ((Integer ) autotrackTypes );
502+ }
517503
518- Object enableLog = map .get ("enableLog " );
519- if (enableLog != null ) {
520- configOptions .enableLog (( Boolean ) enableLog );
521- }
504+ Object networkTypes = map .get ("networkTypes " );
505+ if (networkTypes != null ) {
506+ configOptions .setNetworkTypePolicy (( Integer ) networkTypes );
507+ }
522508
523- Object encrypt = map .get ("encrypt " );
524- if (encrypt != null ) {
525- configOptions .enableEncrypt (( Boolean ) encrypt );
526- }
509+ Object flushInterval = map .get ("flushInterval " );
510+ if (flushInterval != null ) {
511+ configOptions .setFlushInterval (( Integer ) flushInterval );
512+ }
527513
528- Object heatMap = map .get ("heatMap " );
529- if (heatMap != null ) {
530- configOptions .enableHeatMap (( Boolean ) heatMap );
531- }
514+ Object flushBulkSize = map .get ("flushBulkSize " );
515+ if (flushBulkSize != null ) {
516+ configOptions .setFlushBulkSize (( Integer ) flushBulkSize );
517+ }
532518
533- Object androidConfig = map .get ("android" );
534- boolean jellybean = false ;
535- if (androidConfig != null ) {
536- Map androidConfigMap = (Map ) androidConfig ;
537- Object maxCacheSize = androidConfigMap .get ("maxCacheSize" );
538- if (maxCacheSize != null ) {
539- configOptions .setMaxCacheSize (Long .parseLong (maxCacheSize .toString ()));
519+ Object enableLog = map .get ("enableLog" );
520+ if (enableLog != null ) {
521+ configOptions .enableLog ((Boolean ) enableLog );
540522 }
541523
542- Object jellybeanObj = androidConfigMap .get ("jellybean " );
543- if (jellybeanObj != null ) {
544- jellybean = ( boolean ) jellybeanObj ;
524+ Object encrypt = map .get ("encrypt " );
525+ if (encrypt != null ) {
526+ configOptions . enableEncrypt (( Boolean ) encrypt ) ;
545527 }
546- Object subProcessFlush = androidConfigMap .get ("subProcessFlush" );
547- if (subProcessFlush != null && (boolean ) subProcessFlush ) {
548- configOptions .enableSubProcessFlushData ();
528+
529+ Object heatMap = map .get ("heatMap" );
530+ if (heatMap != null ) {
531+ configOptions .enableHeatMap ((Boolean ) heatMap );
549532 }
550- }
551533
552- Object javaScriptBridge = map .get ("javaScriptBridge" );
553- if (javaScriptBridge != null && (boolean ) javaScriptBridge ) {
554- configOptions .enableJavaScriptBridge (jellybean );
555- }
534+ Object androidConfig = map .get ("android" );
535+ boolean jellybean = false ;
536+ if (androidConfig != null ) {
537+ Map androidConfigMap = (Map ) androidConfig ;
538+ Object maxCacheSize = androidConfigMap .get ("maxCacheSize" );
539+ if (maxCacheSize != null ) {
540+ configOptions .setMaxCacheSize (Long .parseLong (maxCacheSize .toString ()));
541+ }
556542
557- Object visualizedConfig = map .get ("visualized" );
558- if (visualizedConfig != null ) {
559- Map visualizedConfigMap = (Map ) visualizedConfig ;
560- Object autoTrack = visualizedConfigMap .get ("autoTrack" );
561- if (autoTrack != null ) {
562- configOptions .enableVisualizedAutoTrack ((Boolean ) autoTrack );
543+ Object jellybeanObj = androidConfigMap .get ("jellybean" );
544+ if (jellybeanObj != null ) {
545+ jellybean = (boolean ) jellybeanObj ;
546+ }
547+ Object subProcessFlush = androidConfigMap .get ("subProcessFlush" );
548+ if (subProcessFlush != null && (boolean ) subProcessFlush ) {
549+ configOptions .enableSubProcessFlushData ();
550+ }
563551 }
564552
565- Object properties = visualizedConfigMap .get ("properties " );
566- if (properties != null ) {
567- configOptions .enableVisualizedProperties (( Boolean ) properties );
553+ Object javaScriptBridge = map .get ("javaScriptBridge " );
554+ if (javaScriptBridge != null && ( boolean ) javaScriptBridge ) {
555+ configOptions .enableJavaScriptBridge ( jellybean );
568556 }
569- }
570557
558+ Object visualizedConfig = map .get ("visualized" );
559+ if (visualizedConfig != null ) {
560+ Map visualizedConfigMap = (Map ) visualizedConfig ;
561+ Object autoTrack = visualizedConfigMap .get ("autoTrack" );
562+ if (autoTrack != null ) {
563+ configOptions .enableVisualizedAutoTrack ((Boolean ) autoTrack );
564+ }
571565
572- SensorsDataAPI .startWithConfigOptions (mActivity , configOptions );
566+ Object properties = visualizedConfigMap .get ("properties" );
567+ if (properties != null ) {
568+ configOptions .enableVisualizedProperties ((Boolean ) properties );
569+ }
570+ }
571+
572+ SensorsDataAPI .startWithConfigOptions (mActivity , configOptions );
573+ } catch (Exception e ) {
574+ SALog .printStackTrace (e );
575+ }
576+ result .success (null );
573577 }
574578
575579 private JSONObject assertProperties (Map map ) {
0 commit comments