Skip to content

Commit

Permalink
Changes the way we flush events when app state changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Oct 13, 2023
1 parent ddca5ee commit 2e6675f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.3

- Changes the way we flush events when app state changes.

## 0.3.2

- Added a warning log when trackEvent is called with invalid parameters
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aptabase/react-native",
"version": "0.3.2",
"version": "0.3.3",
"private": false,
"description": "React Native SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
"sideEffects": false,
Expand Down
14 changes: 5 additions & 9 deletions src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ export function init(appKey: string, options?: AptabaseOptions) {
if (!AppState.isAvailable) return;

AppState.addEventListener("change", (next) => {
_client?.stopPolling();
_client?.flush();

switch (next) {
case "active":
_client?.startPolling(flushInterval);
break;

case "background":
_client?.flush();
break;
if (next === "active") {
_client?.startPolling(flushInterval);
} else {
_client?.stopPolling();
}
});
}
Expand Down

0 comments on commit 2e6675f

Please sign in to comment.