Class EvaluationExposureKey

java.lang.Object
com.launchdarkly.sdk.android.integrations.EvaluationExposureKey

public final class EvaluationExposureKey extends Object
Identifies the evaluation result a hook is about to be told about, so that an EvaluationExposureDeduper can recognize a repeat of it.

Two evaluations are the same exposure when every component here matches. The value is included directly rather than inferred from the variation and version: those are the identity LaunchDarkly uses to bucket summary events, but neither by itself guarantees that the payload is unchanged. The environment is a component because a hook configured on LDConfig is one instance shared by the clients for every environment in secondaryMobileKeys, and so is its deduper. It is identified by a hash of the mobile key rather than by the key itself, so that a hook cannot read the credential out of what it is told, and rather than by the configured environment name, which is arbitrary metadata that is always "default" for the primary environment.

The components describe the result the evaluation returns, which is how the SDK identifies an evaluation on analytics events too. An evaluation the SDK has no flag data for returns the default value, and so is described by that value with the placeholder variation and version the SDK reports for a flag it did not find, the same identity it summarizes such an evaluation under. Evaluations made before the client has flags are of that kind, as are evaluations of a flag that does not exist, so the data arriving changes the value, variation, and version, and the hook is told about the flag again rather than waiting out a window. A flag whose data carries no value, which is what a flag that is off without an off variation has, likewise returns the default value and is described by it, under the flag's own variation and version. The environment is never unknown this way: it is derived from the configuration, so it is fixed before the client it belongs to exists.

The reason the SDK gives for a result is not a component, so neither is the experiment membership drawn from it. A prerequisite that starts failing to the variation an experiment had been choosing leaves the value, the variation, and the version unchanged while moving the flag out of that experiment, and the evaluations that follow are repeats here. The analytics the SDK sends are untouched by any of this, each carrying its own reason, so what LaunchDarkly attributes to an experiment does not depend on the window; a hook that reads the reason itself is what can miss such a change until the window elapses.

Instances are immutable, and their hash code is computed once, the first time one is asked for.

  • Constructor Details

    • EvaluationExposureKey

      public EvaluationExposureKey(String mobileKeyHash, String flagKey, int variation, int flagVersion, String fullyQualifiedContextKey)
      Creates a key with a JSON null value. Prefer the overload accepting value, since the variation and version do not by themselves distinguish one result from another.
      Parameters:
      mobileKeyHash - a hash of the mobile key of the environment the evaluation was made against
      flagKey - the flag key
      variation - the variation index of the result
      flagVersion - the flag version reported on events
      fullyQualifiedContextKey - the fully qualified key of the evaluation context
    • EvaluationExposureKey

      public EvaluationExposureKey(String mobileKeyHash, String flagKey, LDValue value, int variation, int flagVersion, String fullyQualifiedContextKey)
      Parameters:
      mobileKeyHash - a hash of the mobile key of the environment the evaluation was made against
      flagKey - the flag key
      value - the value the evaluation returns, which is the default value if the flag was not found
      variation - the variation index of the result
      flagVersion - the flag version reported on events
      fullyQualifiedContextKey - the fully qualified key of the evaluation context
  • Method Details

    • getMobileKeyHash

      public String getMobileKeyHash()
      Identifies the environment the evaluation was made against, for comparison only: the mobile key is hashed so that a hook is not handed the credential, and the hash the SDK uses is not part of its contract. All that is guaranteed is that two evaluations made against the same environment give the same value, and evaluations made against different environments do not.
      Returns:
      a hash of the mobile key of the environment the evaluation was made against
    • getFlagKey

      public String getFlagKey()
      Returns:
      the flag key
    • getValue

      public LDValue getValue()
      Returns:
      the value the evaluation returns, which is the default value if the flag was not found
    • getVariation

      public int getVariation()
      Returns:
      the variation index of the result
    • getFlagVersion

      public int getFlagVersion()
      Returns:
      the flag version reported on events
    • getFullyQualifiedContextKey

      public String getFullyQualifiedContextKey()
      Returns:
      the fully qualified key of the evaluation context
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object