Visitor constructor

Visitor(
  1. FlagshipConfig config,
  2. String visitorId,
  3. bool _isAuthenticated,
  4. Map<String, Object> context, {
  5. bool hasConsented = true,
})

Create new instance for visitor

config: this object manage the mode of the sdk and other params visitorId : the user ID for the visitor context : Map that represent the conext for the visitor

Implementation

Visitor(this.config, this.visitorId, this._isAuthenticated,
    Map<String, Object> context,
    {bool hasConsented = true}) {
  if (_isAuthenticated == true) {
    this.anonymousId = FlagshipTools.generateFlagshipId();
  } else {
    anonymousId = null;
  }

  // Load preset_Context
  this.updateContextWithMap(FlagshipContextManager.getPresetContextForApp());

  // Update context
  this.updateContextWithMap(context);
  // Set delegate
  _visitorDelegate = VisitorDelegate(this);
  // Set the consent
  _hasConsented = hasConsented;
  // Send the consent hit on false at the start
  if (!_hasConsented) {
    _visitorDelegate.sendHit(Consent(hasConsented: _hasConsented));
  }
}