Skip to content

Commit

Permalink
dispatch queue after initialize if its not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
EPNW-Eric committed May 27, 2023
1 parent d8da3da commit 34287d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const _matomoEndpoint = 'http://localhost:8765/matomo.php';
const _sideId = 1;
const _testUserId = 'Nelson Pandela';

// Usage: run the example, cause some actions by clicking around,
// close the example within 5min to prevent the dispatchment of
// the actions, run the example again, wait at least 5min, then
// finally check the Matomo dashboard to see if all actions are
// there.
// Use this as dispatchSettings in MatomoTracker.instance.initialize()
// to test persistent actions. Then run the example, cause some actions
// by clicking around, close the example within 5min to prevent the
// dispatchment of the actions, run the example again, wait at least 5min,
// finally check the Matomo dashboard to see if all actions are there.
const DispatchSettings dispatchSettingsEndToEndTest =
DispatchSettings.persistent(dequeueInterval: Duration(minutes: 5));

Expand All @@ -23,7 +23,7 @@ void main() async {
siteId: _sideId,
url: _matomoEndpoint,
verbosityLevel: Level.all,
dispatchSettings: dispatchSettingsEndToEndTest,
// dispatchSettings: dispatchSettingsEndToEndTest,
);
MatomoTracker.instance.setVisitorUserId(_testUserId);
runApp(const MyApp());
Expand Down
4 changes: 4 additions & 0 deletions lib/src/matomo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ class MatomoTracker {
_ping();
});
}

if (queue.isNotEmpty) {
await dispatchActions();
}
}

@visibleForTesting
Expand Down

0 comments on commit 34287d4

Please sign in to comment.