-
Notifications
You must be signed in to change notification settings - Fork 4
Update the Event Flushing Mechanism to save in disk #10
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
base: main
Are you sure you want to change the base?
Conversation
…work issues or game being closed - Add the option to save events to disk if they failed to be sent when the game loses focus on the device screen.
…behaviour of Flush methods
…running or without saved cache events
…flowing the PlayerPrefs limit capacity
bump to merge |
@@ -103,7 +103,7 @@ public static void OnApplicationFocus(bool hasFocus) | |||
} | |||
else | |||
{ | |||
Flush(); | |||
_dispatcher.FlushOrSaveToDisk(); | |||
StopPolling(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we need to make this return a Task
as well:
public static Task Flush()
{
return _dispatcher.Flush();
}
Also I think we should avoid async void
methods, eg:
private static async void StartPolling(int flushTimer)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flush already return a Task
And I do agree that we need to avoid async void.
The goal of this PR is to keep changes to a minimal
@@ -42,7 +49,7 @@ private void Enqueue(List<Event> data) | |||
_events.Enqueue(eventData); | |||
} | |||
|
|||
public async void Flush() | |||
public async Task Flush() | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned we don't have any kind of thread safety mechanism on the Flush method
|
||
namespace AptabaseSDK | ||
{ | ||
public class WebGLDispatcher: IDispatcher | ||
{ | ||
private const string EVENT_ENDPOINT = "/api/v0/event"; | ||
private const string APTABASE_KEY = "aptabase_key"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a better name for this key, eg aptabase_events_cache
?
Update the Event Flushing Mechanism to avoid losing events due to network issues or game being closed
Reasoning