SRGSSR / pillarbox-android

The modern SRG SSR Pillarbox player targeting Android platforms
https://android.pillarbox.ch/api
MIT License
13 stars 1 forks source link

Analytics events aren't sent out if initialized too late #532

Closed hoschiho closed 5 months ago

hoschiho commented 5 months ago

Description of the problem

We call SRGAnalytics.init(application, config) after we have consent from the user. However, in this case media player events aren't sent out. Manually triggered events like a page view event works correctly. And if we initialize it right in the main activity, everything works fine.

Relevant stack trace or log output

No response

Reproducibility

Always

Steps to reproduce

Call SRGAnalytics.init(application, config) not right in the beginning.

Library version

1.0

Operating system

Android 14

Code sample

No response

Is there an existing issue for this?

StaehliJ commented 5 months ago

Hello,

We expect you to initialize analytics inside your Application.onCreate.

I don't know how it works with Flutter but if you can try something like that:

class Application : FlutterApplication {
     override fun onCreate() {
          super.onCreate();
         // Start flutter engine
         // Invoke a dart code in the Plugin using methodChannel or etc.
        initSRGAnalytics(config = config)
       }
}

Or just don't create Player before initializing analytics.

You can update the user consent afterward with SRGAnalytics.setUserConsent.

MGaetan89 commented 5 months ago

@hoschiho do you need more help on this issue? Or is the comment above what you were looking for?

hoschiho commented 5 months ago

@MGaetan89 All good :) Thanks for your help!