Skip to content

Commit 2e6675f

Browse files
committed
Changes the way we flush events when app state changes.
1 parent ddca5ee commit 2e6675f

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.3
2+
3+
- Changes the way we flush events when app state changes.
4+
15
## 0.3.2
26

37
- Added a warning log when trackEvent is called with invalid parameters

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aptabase/react-native",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"private": false,
55
"description": "React Native SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
66
"sideEffects": false,

src/track.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ export function init(appKey: string, options?: AptabaseOptions) {
2828
if (!AppState.isAvailable) return;
2929

3030
AppState.addEventListener("change", (next) => {
31-
_client?.stopPolling();
31+
_client?.flush();
3232

33-
switch (next) {
34-
case "active":
35-
_client?.startPolling(flushInterval);
36-
break;
37-
38-
case "background":
39-
_client?.flush();
40-
break;
33+
if (next === "active") {
34+
_client?.startPolling(flushInterval);
35+
} else {
36+
_client?.stopPolling();
4137
}
4238
});
4339
}

0 commit comments

Comments
 (0)