Skip to content
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

Investigate using/recommending ProcessLifecycleOwner for tracking lifecycle calls #594

Open
prudrabhat opened this issue Dec 8, 2023 · 0 comments
Assignees
Labels
discussion enhancement New feature or request

Comments

@prudrabhat
Copy link
Contributor

prudrabhat commented Dec 8, 2023

  • The application.launch metric is collected as part of the lifecycle application foreground (triggered by MobileCore.lifecycleStart()) which is a notification that the application is in the foreground. This notification is recommended to be sent when each activity of the application resumes.
  • The application.close metric is collected as part of and lifecycle application background (triggered by MobileCore.lifecyclePause()) event which is a notification that the application is in the background. This notification recommended to be sent when each activity of the application pauses.

Since these lifecycle metrics are collected for each activity, transitioning from one activity to another will result in the following events in order:

  1. Lifecycle application foreground (first activity starts)
  2. Lifecycle application background (first activity pauses)
  3. Lifecycle application foreground (second activity starts).

However, if the time between the first activity pausing and the second activity resuming is less than 500 milliseconds, the lifecycle session is said to be continuing and events 2 and 3 are not sent. If the time between first activity pausing and the second activity resuming is more that 500 milliseconds, the events 2 and 3 are sent marking them as separate sessions.

This approach does not allow Edge customers to rely on application.launches for reliably tracking launches.

Investigate using ProcessLifecycleOwner and change their app to do the following instead of lifecycle calls per activity.

class App : Application(), DefaultLifecycleObserver {

    override fun onCreate() {
        super.onCreate()
        ProcessLifecycleOwner.get().lifecycle.addObserver(this)
    }

     override fun onResume(owner: LifecycleOwner) {
        super.onResume(owner)
        MobileCore.lifecycleStart(vinMapping)
    }

    override fun onPause(owner: LifecycleOwner) {
        super.onPause(owner)
        MobileCore.lifecyclePause()
    }

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants