Standardise Analytics with iOS
iOS project have advanced analytics which are more diverse than currently implemented on the Android build.
Check all Analytics usage on iOS, and sync with our AnalyticsService.
The service is implemented slightly awkwardly; the AnalyticsProperties object created for the service can be refactored out and the code made slightly cleaner.
You may have to ask @oa-s or @hboon for how to find all instances of Analytics usage on iOS.
These are the entire list of analytics we log to Mixpanel: https://github.com/AlphaWallet/alpha-wallet-ios/blob/8fb539db514af55e86ae362b2e3574e369833a37/modules/AlphaWalletFoundation/AlphaWalletFoundation/Analytics/AnalyticsTypes.swift#L27.
Fire away if you have questions.
@JamesSmartCell Actually, if this isn't too urgent, this sounds like a great candidate for Kotlin code that involves simple native bridging. Do you think so?
Would that be the module that supports the sending of data? And supply an interface that we use to call analytic events? It sounds good but we would need to see if KMM works together with Firebase.
But for now, it doesn't affect adding analytics in as normal; we can abstract the calls out later.
Would that be the module that supports the sending of data? And supply an interface that we use to call analytic events? It sounds good but we would need to see if KMM works together with Firebase.
There are a few ways to look at why cross-platform code is useful for us:
A. Saves time. Just implement once (in theory!) B. Reduce communication and people synchronization. This ends up saving time and reducing bugs. C. More cross-functional/team developers
I strongly believe B is the more important one for us. So taking this as an example, there's this which can be cross-platform:
Defining the events and properties of each one and giving them a sensible function name, wrapped in a Analytics class. So both platforms only need to do something like this in Java/Swift:
Analytics().sendTransactionSentEvent(chainId: 1, type: :eth, speed: :default)
instead of:
Analytics().sendEvent("transaction_sent", {chainId: 1, type: :eth, speed: :default})
The latter requires a better shared understanding of the list of events and parameters, the former relies more on strong typing (the function name and arguments). We might also more easily check manually or figure out a way to automatically check which events are TODOs to log since we can look for method references, etc
B instead of A is also why I'm not so worried about cross-platform UI. Sure it saves time directly, but B is worth more and with has fewer downsides.
But for now, it doesn't affect adding analytics in as normal; we can abstract the calls out later.
Yes, just observing and building a list for the future :)
Ok I see where you're going - write a 'CISC' interface that we can easily implement and we know is the same for both platforms.
If we could build something like an interface we could show a meaningful error if any path remains un-implemented, too. It wouldn't catch all exemptions but would catch types.
Build this as an interface, then port the existing class to implement the interface, then when/if we implement the cross-platform analytics it'll be a simple drop-in (in theory - with a bit of hammering).
These are the entire list of analytics we log to Mixpanel: https://github.com/AlphaWallet/alpha-wallet-ios/blob/4098a9dc814f7462f40a7008a0e2e8e21341aa5c/AlphaWallet/Analytics/Models/AnalyticsTypes.swift#L22-L74.
Sorry, I wasn't clearer, need to change that URL to master to get the latest (I've fixed the one in the comment above to be more recent since the file has moved due to some refactoring).