Analytics constructor
Analytics(
- Configuration config,
- Store _store, {
- HTTPClient httpClient()?,
Implementation
Analytics(Configuration config, this._store, {HTTPClient Function(Analytics)? httpClient})
: _state = StateManager(_store, System(true, false), config),
_timeline = Timeline() {
_state.init(error, config.storageJson!);
this.httpClient = httpClient == null ? HTTPClient(this) : httpClient(this);
state.ready.then((_) => _onStateReady());
if (config.autoAddHightouchDestination) {
final hightouchDestination = HightouchDestination();
addPlugin(hightouchDestination);
}
if (config.token != null) {
_platformPlugins.add(InjectToken(config.token!));
}
// Setup platform specific plugins
_platformPlugins.forEach(addPlugin);
// Start flush policies
final flushPolicies = state.configuration.state.flushPolicies ?? [];
_flushPolicyExecuter = FlushPolicyExecuter(flushPolicies, () => flush());
_flushPolicyExecuter.start();
}