-
Notifications
You must be signed in to change notification settings - Fork 1
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
[analytics] Option to Deinit / dispose SRGAnalytics #889
Comments
Where do you init analytics in you project? Because if you do it like it is recommended inside the |
So we have following problem: As I develop a plugin for flutter to abstract this functionality of analytics, we need to hand over the params via a method channel. This can only happen as soon as the android part of the app is already running and not during Flutter starts its lifecycle once the app is in foreground (unless you do some magic stuff messing with this, or explicitely want something to also run in the background). So regularly the code is initialized on every foreground event. It is also then possible to notice, as soon as the app goes in the background to e.g. unitialize native stuff. There's also the ability to restore states, how it was previous to going in the background: For me it would be cleaner to unitialize the analytics and then initialize as soon as it's in the foreground instead of explicitely saving this state. In general, I think it is always good practise to have the option to tidy up the things manually. |
Do you know if it is executed into the same process, I hope so. SRGAnalytics is a Singleton responsible to init comscore library which uses dlls. Do you try to put the init call between try catch? try {
initSRGAnalytics(config = config)
} catch (e: IllegalArgumentException) {
e.printStackTrace()
} So first time it initialize and the second times it does nothing because it is already initiialized. |
Are you sur you can create a Android Application classe like it is done here ? : flutter/flutter#46329 package com.your.package.
import io.flutter.view.FlutterMain
import android.app.Application
class DemoApplication : Application() {
override fun onCreate() {
super.onCreate()
initSRGAnalytics(config)
FlutterMain.startInitialization(applicationContext)
}
} |
I can indeed, in my user facing app: The information to initialize the SRG analytics are parameters, which need to be passed to the native code while the native app already has been initialized. Before the app does not have any information about its Flutter application (besides the things which are hardcoded / given natively). To think in a bigger picture, this package abstraction is useful, as the initialization of SRGAnalytics only has to be done once for every user of the package. This abstraction then is applied to all platforms: android, ios, web and in further scenarios also linux and windows. So a Flutter dev does not need to deal with platform code (in 6 languages), and rather just calls this method in Flutter, which works for every platform out of the box. |
Yes, that's exactly how we currently manage the code right now. Non-the-less, it's a bug and the root cause should be properly handled. |
Is there an existing similar feature request?
I have searched existing features and found no similar request.
I have browsed the available API and found no way to achieve the use case I described.
Use case description
If initializing Analytics twice with
SRGAnalytics.init(applicationContext, config)
, it gives the following error message:To prevent that, we need the possibility to
deinit
the analyics, e.g. when the app goes in background or is closed, as our app life cycle starts when the app is in the foreground.Acceptance criteria
Ability to properly deinit the SRGAnalytics
Proposed solution
Add a
dispose
ordeinit
method.Alternatives considered
Allow to initialize SRG Analytics more than once (?)
The text was updated successfully, but these errors were encountered: