Analytics constructor

Analytics(
  1. Configuration config,
  2. Store _store, {
  3. HTTPClient httpClient(
    1. Analytics
    )?,
})

Implementation

Analytics(Configuration config, this._store,
    {HTTPClient Function(Analytics)? httpClient})
    : _state = StateManager(_store, System(true, false), config),
      _timeline = Timeline() {
  _state.init(error);

  this.httpClient = httpClient == null ? HTTPClient(this) : httpClient(this);

  state.ready.then((_) => _onStateReady());

  if (config.autoAddSegmentDestination) {
    final segmentDestination = SegmentDestination();
    addPlugin(segmentDestination);
  }

  // Setup platform specific plugins
  _platformPlugins.forEach(addPlugin);

  // Start flush policies
  final flushPolicies = state.configuration.state.flushPolicies ?? [];
  _flushPolicyExecuter = FlushPolicyExecuter(flushPolicies, () => flush());
  _flushPolicyExecuter.start();
}