Skip to content

Event drop issue fix #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/core/lib/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ class Analytics with ClientMethods {
Future _process(RawEvent event) async {
applyRawEventData(event);
if (state.isReady) {
final processedEvent = await _timeline.process(event);
_flushPolicyExecuter.notify(event);
return _timeline.process(event);
return processedEvent;
} else {
_pendingEvents.add(event);
return event;
Expand Down
1 change: 0 additions & 1 deletion packages/core/lib/plugins/queue_flushing_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class QueueFlushingPlugin extends UtilityPlugin {
if (!_isPendingUpload) {
_isPendingUpload = true;
await _onFlush(events);
_state!.flush();
}
} finally {
_isPendingUpload = false;
Expand Down
10 changes: 8 additions & 2 deletions packages/core/lib/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,14 @@ class QueueState<T extends JSONSerialisable> extends PersistedState<List<T>> {
await modifyState((state) async => setState([...state, t]));
}

void flush({int? number}) {
setState([]);
Future<void> flush({int? number}) async{
final events = await state;
if(number==null || number >= events.length){
setState([]);
return;
}
events.removeRange(0, number);
setEvents(events);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions packages/core/lib/timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class Timeline {
for (var plugin in plugins) {
if (result != null) {
try {
final pluginResult = plugin.execute(result);
final pluginResult = await plugin.execute(result);
// Each destination is independent from each other, so we don't roll over changes caused internally in each one of their processing
if (type != PluginType.destination) {
result = await pluginResult;
result = pluginResult;
}
} catch (error) {
reportInternalError(
Expand Down
Loading