PostHog / posthog-ios

PostHog iOS SDK
https://posthog.com/docs/libraries/ios
MIT License
35 stars 41 forks source link

Set `is_testflight` and `is_sideloaded` property #117

Open marandaneto opened 6 months ago

marandaneto commented 6 months ago

Description

Relates to https://github.com/PostHog/posthog-android/issues/113 Sets a property if the running version was installed via testflight or its sideloaded.

marandaneto commented 6 months ago

on iOS, you can check the appStoreReceiptURL https://developer.apple.com/documentation/foundation/bundle/1407276-appstorereceipturl https://stackoverflow.com/questions/26081543/how-to-tell-at-runtime-whether-an-ios-app-is-running-through-a-testflight-beta-i

Also https://github.com/ravitejaavv/store_checker/blob/master/ios/Classes/SwiftStoreCheckerPlugin.swift mobileprovision is another hint, if its not none of them, most likely is sideloaded.

marandaneto commented 6 months ago

On Android, you can check packageManager.getInstallerPackageName(packageName), its null if its side loaded, or its the name of the installer (store). Its not possible to know at runtime if the Android app is installed for internal testing only since its the same binary. Here is the list of installer names https://github.com/ravitejaavv/store_checker/blob/feca50e3168763828e7aa024bb0b3c40b9ce42ab/lib/store_checker.dart#L31-L69