@SuppressLint({"SimpleDateFormat"})
 private void onDestroySurvey()
 {
   if (this.mMixpanel != null)
   {
     if (this.mUpdateDisplayState != null)
     {
       Object localObject2 = getSurveyState();
       Survey localSurvey = ((UpdateDisplayState.DisplayState.SurveyState)localObject2).getSurvey();
       Object localObject3 = localSurvey.getQuestions();
       Object localObject1 = this.mUpdateDisplayState.getDistinctId();
       localObject1 = this.mMixpanel.getPeople().withIdentity((String)localObject1);
       ((MixpanelAPI.People)localObject1).append("$responses", Integer.valueOf(localSurvey.getCollectionId()));
       localObject2 = ((UpdateDisplayState.DisplayState.SurveyState)localObject2).getAnswers();
       localObject3 = ((List)localObject3).iterator();
       while (((Iterator)localObject3).hasNext())
       {
         Object localObject4 = (Survey.Question)((Iterator)localObject3).next();
         String str = ((UpdateDisplayState.AnswerMap)localObject2).get(Integer.valueOf(((Survey.Question)localObject4).getId()));
         if (str != null) {
           try
           {
             JSONObject localJSONObject = new JSONObject();
             localJSONObject.put("$survey_id", localSurvey.getId());
             localJSONObject.put("$collection_id", localSurvey.getCollectionId());
             localJSONObject.put("$question_id", ((Survey.Question)localObject4).getId());
             localJSONObject.put("$question_type", ((Survey.Question)localObject4).getType().toString());
             localObject4 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
             ((DateFormat)localObject4).setTimeZone(TimeZone.getTimeZone("UTC"));
             localJSONObject.put("$time", ((DateFormat)localObject4).format(new Date()));
             localJSONObject.put("$value", str);
             ((MixpanelAPI.People)localObject1).append("$answers", localJSONObject);
           }
           catch (JSONException localJSONException)
           {
             Log.e("MixpanelAPI.SrvyActvty", "Couldn't record user's answer.", localJSONException);
           }
         }
       }
     }
     this.mMixpanel.flush();
   }
   UpdateDisplayState.releaseDisplayState(this.mIntentId);
 }
 private void trackSurveyAttempted()
 {
   Survey localSurvey = getSurveyState().getSurvey();
   MixpanelAPI.People localPeople = this.mMixpanel.getPeople().withIdentity(this.mUpdateDisplayState.getDistinctId());
   localPeople.append("$surveys", Integer.valueOf(localSurvey.getId()));
   localPeople.append("$collections", Integer.valueOf(localSurvey.getCollectionId()));
 }
  public void testIdentifyAfterSet() {
    final List<JSONObject> messages = new ArrayList<JSONObject>();

    final AnalyticsMessages listener =
        new AnalyticsMessages(getContext()) {
          @Override
          public void peopleMessage(JSONObject heard) {
            messages.add(heard);
          }
        };

    MixpanelAPI mixpanel =
        new TestUtils.CleanMixpanelAPI(
            getContext(), mMockPreferences, "TEST TOKEN testIdentifyAfterSet") {
          @Override
          protected AnalyticsMessages getAnalyticsMessages() {
            return listener;
          }
        };

    MixpanelAPI.People people = mixpanel.getPeople();
    people.increment("the prop", 0L);
    people.append("the prop", 1);
    people.set("the prop", 2);
    people.increment("the prop", 3L);
    people.increment("the prop", 4);
    people.append("the prop", 5);
    people.append("the prop", 6);
    people.identify("Personal Identity");

    assertEquals(messages.size(), 7);
    try {
      for (JSONObject message : messages) {
        String distinctId = message.getString("$distinct_id");
        assertEquals(distinctId, "Personal Identity");
      }

      assertTrue(messages.get(0).has("$add"));
      assertTrue(messages.get(1).has("$append"));
      assertTrue(messages.get(2).has("$set"));
      assertTrue(messages.get(3).has("$add"));
      assertTrue(messages.get(4).has("$add"));
    } catch (JSONException e) {
      fail("Unexpected JSON error in stored messages.");
    }
  }