コード例 #1
0
  private void readSuperProperties() {
    String props = mStoredPreferences.getString("super_properties", "{}");
    if (MPConfig.DEBUG) Log.d(LOGTAG, "Loading Super Properties " + props);

    try {
      mSuperProperties = new JSONObject(props);
    } catch (JSONException e) {
      Log.e(LOGTAG, "Cannot parse stored superProperties");
      mSuperProperties = new JSONObject();
      storeSuperProperties();
    }
  }
コード例 #2
0
  /**
   * Register properties that will be sent with every subsequent call to {@link #track(String,
   * JSONObject)}.
   *
   * <p>SuperProperties are a collection of properties that will be sent with every event to
   * Mixpanel, and persist beyond the lifetime of your application.
   *
   * <p>Setting a superProperty with registerSuperProperties will store a new superProperty,
   * possibly overwriting any existing superProperty with the same name (to set a superProperty only
   * if it is currently unset, use {@link #registerSuperPropertiesOnce(JSONObject)})
   *
   * <p>SuperProperties will persist even if your application is taken completely out of memory. to
   * remove a superProperty, call {@link #unregisterSuperProperty(String)} or {@link
   * #clearSuperProperties()}
   *
   * @param superProperties A JSONObject containing super properties to register
   * @see #registerSuperPropertiesOnce(JSONObject)
   * @see #unregisterSuperProperty(String)
   * @see #clearSuperProperties()
   */
  public void registerSuperProperties(JSONObject superProperties) {
    if (MPConfig.DEBUG) Log.d(LOGTAG, "registerSuperProperties");

    for (Iterator<?> iter = superProperties.keys(); iter.hasNext(); ) {
      String key = (String) iter.next();
      try {
        mSuperProperties.put(key, superProperties.get(key));
      } catch (JSONException e) {
        Log.e(LOGTAG, "Exception registering super property.", e);
      }
    }

    storeSuperProperties();
  }
コード例 #3
0
  /**
   * Remove a single superProperty, so that it will not be sent with future calls to {@link
   * #track(String, JSONObject)}.
   *
   * <p>If there is a superProperty registered with the given name, it will be permanently removed
   * from the existing superProperties. To clear all superProperties, use {@link
   * #clearSuperProperties()}
   *
   * @param superPropertyName
   * @see #registerSuperProperties(JSONObject)
   */
  public void unregisterSuperProperty(String superPropertyName) {
    mSuperProperties.remove(superPropertyName);

    storeSuperProperties();
  }