visitorExposed method

Future<void> visitorExposed()

Implementation

Future<void> visitorExposed() async {
  // Before expose whe should check the Type
  Modification? modification =
      this._visitorDelegate?.getFlagModification(this._key);
  if (modification != null) {
    // Check if the default value is set
    if (this._defaultValue != null) {
      if (modification.value == null ||
          _isSameTypeOrDefaultValueNull(modification.value)) {
        Flagship.logger(
            Level.DEBUG, "Send exposure flag (activate) for : " + _key);

        // Update modification with default value
        modification.defaultValue = this.defaultValue;
        // Activate flag
        this._visitorDelegate?.activateFlag(modification);
      } else {
        Flagship.logger(Level.DEBUG,
            "For the visitor ${this._visitorDelegate?.visitor.visitorId}, the flag with key ${this.key} has a different type compared to the default value. Therefore, the exposure is interrupted.");
      }
    } else {
      Flagship.logger(Level.ALL,
          "Assuming the value() method has not previously invoked the flag ${this.key} for the Visitor ${this._visitorDelegate?.visitor.visitorId}, the exposure is canceled");
    }
  } else {
    Flagship.logger(Level.DEBUG,
        "For the visitor ${this._visitorDelegate?.visitor.visitorId}, no flags were found with the key ${this.key}. As a result, user exposure will not be sent.");
  }
}