initMatomo static method

Future<void> initMatomo(
  1. bool screenshotMode, {
  2. DispatchSettings dispatchSettings = const DispatchSettings.persistent(),
})

Undispatched actions survive a restart for a day, and no longer: the default PersistenceFilter of DispatchSettings.persistent drops anything older than 23h59m59s when the queue is loaded.

Implementation

static Future<void> initMatomo(
  bool screenshotMode, {
  DispatchSettings dispatchSettings = const DispatchSettings.persistent(),
}) async {
  _packageInfo = await PackageInfo.fromPlatform();
  if (screenshotMode) {
    _setCrashReports(false);
    _setAnalyticsReports(false);
    return;
  }
  try {
    await MatomoTracker.instance.initialize(
      url: 'https://analytics.openfoodfacts.org/matomo.php',
      siteId: '2',
      visitorId: _visitorId,
      dispatchSettings: dispatchSettings,
    );
  } catch (err) {
    // With Hot Reload, this may trigger a late field already initialized
  }
}