Parsely / parsely-android

The official Parse.ly Android toolkit -- for instrumenting your apps with Parse.ly
https://docs.parse.ly/android-sdk/
Other
6 stars 6 forks source link

Send events automatically on application `onStop` #77

Closed wzieba closed 1 year ago

wzieba commented 1 year ago

Closes: #76

Description

This PR introduces a new behavior of automatically flushing the events queue using ProcessLifecycleOwner. This API is used in e.g. AppLifecycleIntegration.kt from Sentry Android SDK which works similarly to Parse.ly SDK in the sense of observing application lifecycle.

At the same time, this PR deprecates manual queue flushing.

How to test

Before

  1. Checkout main
  2. Install and run example app
  3. Tap "track URL"
  4. Move app to the background (don't kill)
  5. After ~20 seconds, you should see POST Data {"events": log

After

  1. Checkout this branch
  2. Install and run example app
  3. Tap "track URL"
  4. Move app to the background (don't kill)
  5. See that POST Data {"events": log is logged imidiatelly after app is moved to the background

Dependency change report

 \--- androidx.appcompat:appcompat:1.4.2
      +--- androidx.core:core:1.7.0
-     |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.0
-     |    |    +--- androidx.arch.core:core-runtime:2.1.0
-     |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
-     |    |    |    \--- androidx.arch.core:core-common:2.1.0
-     |    |    |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
-     |    |    +--- androidx.lifecycle:lifecycle-common:2.4.0
-     |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
-     |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
-     |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.6.2
+     |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    +--- androidx.arch.core:core-common:2.2.0
+     |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    +--- androidx.arch.core:core-runtime:2.2.0
+     |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    \--- androidx.arch.core:core-common:2.2.0 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2
+     |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10
+     |    |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.10
+     |    |    |    |    \--- org.jetbrains:annotations:13.0
+     |    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4
+     |    |    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4
+     |    |    |    |    |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4
+     |    |    |    |    |         +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4
+     |    |    |    |    |         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 (c)
+     |    |    |    |    |         |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 (c)
+     |    |    |    |    |         |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 (c)
+     |    |    |    |    |         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.8.10
+     |    |    |    |    |         |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    |    |    |         |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.10
+     |    |    |    |    |         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    |    |    |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21 -> 1.8.10
+     |    |    |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.4 (*)
+     |    |    |    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21 -> 1.8.10 (*)
+     |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
+     |    |    +--- androidx.profileinstaller:profileinstaller:1.3.0
+     |    |    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
+     |    |    |    +--- androidx.concurrent:concurrent-futures:1.1.0
+     |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    |    \--- com.google.guava:listenablefuture:1.0
+     |    |    |    +--- androidx.startup:startup-runtime:1.1.1
+     |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    |    \--- androidx.tracing:tracing:1.0.0
+     |    |    |    |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    \--- com.google.guava:listenablefuture:1.0
+     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
+     |    |    \--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
-     |    \--- androidx.concurrent:concurrent-futures:1.0.0
-     |         +--- com.google.guava:listenablefuture:1.0
-     |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    \--- androidx.concurrent:concurrent-futures:1.0.0 -> 1.1.0 (*)
      +--- androidx.activity:activity:1.2.4
-     |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.0 (*)
+     |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.6.2 (*)
-     |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1
-     |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.6.2
+     |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
+     |    |    \--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
-     |    +--- androidx.savedstate:savedstate:1.1.0
-     |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
-     |    |    +--- androidx.arch.core:core-common:2.0.1 -> 2.1.0 (*)
-     |    |    \--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.4.0 (*)
+     |    +--- androidx.savedstate:savedstate:1.1.0 -> 1.2.1
+     |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    +--- androidx.arch.core:core-common:2.1.0 -> 2.2.0 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.1 -> 2.6.2 (*)
+     |    |    \--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
-     |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1
-     |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
-     |    |    +--- androidx.savedstate:savedstate:1.1.0 (*)
-     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1
-     |    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
-     |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 (*)
-     |    |    |    \--- androidx.lifecycle:lifecycle-common:2.3.1 -> 2.4.0 (*)
-     |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+     |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1 -> 2.6.2
+     |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.3.0
+     |    |    +--- androidx.core:core-ktx:1.2.0
+     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.41 -> 1.8.10 (*)
+     |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    |    |    \--- androidx.core:core:1.2.0 -> 1.7.0 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2
+     |    |    |    +--- androidx.arch.core:core-common:2.1.0 -> 2.2.0 (*)
+     |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 -> 2.2.0 (*)
+     |    |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (*)
+     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (*)
+     |    |    +--- androidx.savedstate:savedstate:1.2.1 (*)
+     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    \--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
-     |    \--- androidx.tracing:tracing:1.0.0
-     |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
+     |    \--- androidx.tracing:tracing:1.0.0 (*)
      +--- androidx.fragment:fragment:1.3.6
      |    +--- androidx.loader:loader:1.0.0
-     |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
-     |    |    |    +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
-     |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0 -> 2.3.1 (*)
-     |    |    |    \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.2
+     |    |    |    +--- androidx.arch.core:core-common:2.1.0 -> 2.2.0 (*)
+     |    |    |    +--- androidx.arch.core:core-runtime:2.1.0 -> 2.2.0 (*)
+     |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (*)
+     |    |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-process:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
-     |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.3.1 (*)
+     |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.6.2 (*)
-     |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 (*)
+     |    +--- androidx.lifecycle:lifecycle-livedata-core:2.3.1 -> 2.6.2 (*)
-     |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+     |    +--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.6.2 (*)
-     |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1 (*)
+     |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1 -> 2.6.2 (*)
-     |    \--- androidx.savedstate:savedstate:1.1.0 (*)
+     |    \--- androidx.savedstate:savedstate:1.1.0 -> 1.2.1 (*)
-     +--- androidx.savedstate:savedstate:1.1.0 (*)
+     +--- androidx.savedstate:savedstate:1.1.0 -> 1.2.1 (*)
      +--- androidx.emoji2:emoji2:1.0.0
-     |    +--- androidx.lifecycle:lifecycle-process:2.4.0
-     |    |    +--- androidx.lifecycle:lifecycle-runtime:2.4.0 (*)
-     |    |    \--- androidx.startup:startup-runtime:1.0.0
-     |    |         +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
-     |    |         \--- androidx.tracing:tracing:1.0.0 (*)
+     |    +--- androidx.lifecycle:lifecycle-process:2.4.0 -> 2.6.2
+     |    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
+     |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (*)
+     |    |    +--- androidx.startup:startup-runtime:1.1.1 (*)
+     |    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 (*)
+     |    |    +--- androidx.lifecycle:lifecycle-runtime:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.6.2 (c)
+     |    |    +--- androidx.lifecycle:lifecycle-common:2.6.2 (c)
+     |    |    \--- androidx.lifecycle:lifecycle-livedata:2.6.2 (c)
-     |    \--- androidx.startup:startup-runtime:1.0.0 (*)
+     |    \--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 (*)
-     +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.0 (*)
+     +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.6.2 (*)
-     \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 (*)
+     \--- androidx.lifecycle:lifecycle-viewmodel:2.3.1 -> 2.6.2 (*)
++--- androidx.lifecycle:lifecycle-process:2.6.2 (*)
++--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10 (c)
+\--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.10 (c)
wzieba commented 1 year ago

~Sorry, it's still WIP @ParaskP7 . I'll ping you again when it'll be ready 👍~ False alarm, actually it's good to go 👍

ParaskP7 commented 1 year ago

👋 @wzieba !

Took another look at the extra 2 commits added, thanks and everything LGTM, feel free to merge this when you're ready! 🚀