felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.67k stars 3.38k forks source link

docs: product analytics #3635

Open jenshor opened 1 year ago

jenshor commented 1 year ago

Description

I'm currently implementing product analytics using mixpanel (however, the particular analytics solution shouldn't matter too much). I already read the docs regarding BlocObserver but are there additional docs or example apps showing how to track and process events?

I'm also curious about how VGV is doing product analytics. I'd love to hear about your best practices 👍🏻

Context The idea of using a BlocObserver to do the tracking is simple: This way we have easy access to all the emitted events and can just ingest them into our analytics solution. In addition, we do not need to clutter Bloc code with an additional AnalyticsRepository. However, depending on the event the BlocObserver approach might also track data we do not want to have in our analytics solution (e.g. password data from a PasswordChanged event). Therefore, we are looking to exclude some of the events or properties.

Since there are a few options to accomplish excluding events and/or properties I'm asking for best practices to guide our decision.

Thanks in advance

TheGlorySaint commented 1 year ago

That would be good to know or have explanation

jenshor commented 1 year ago

Felix just shared this gist with me https://gist.github.com/felangel/cfd2e4195fa8afbf153f2e663e3f51bd which allows for tracking specific events as well as defining which properties are tracked.

However, there are obviously different approaches that one could go with which are to be discussed.