JBirdVegas / external_jbirdvegas_mGerrit

mGerrit is a Gerrit instance viewer
19 stars 8 forks source link

Feature/no analytics #52

Closed JBirdVegas closed 8 years ago

JBirdVegas commented 8 years ago

Create two productFlavors {noAnalytics|googlePlay}

The noAnalytics flavor will not send analytics as the AnalyticsHelper has been stubbed. The implementation for analytics only exists in the googlePlay. Also only import the analytics library and declare analytic keys in googlePlay productFlavor

Implement the the request of Issue #49 : #49

add comments remove getInstance where unneeded

p4r4n01d commented 8 years ago

How is the build process affected by this - I don't really want to type out a longer command to release a new version? Are the signing keys required for building a noAnalytics release build? If they are they shouldn't be. What would be great would be to specify what type of build flavor is being targeted in the local config (thinking local gradle properties here) which would build all builds for that flavor by default. As it is local config, I would specify to use the GP flavor, and this would not impact anyone else.

On this topic, I noticed incrementing the version is done AFTER the build which means to do a full release I need to build twice. Not ideal. The main thing is not to push and tag a new release if it doesn't build. It would be good not to increment the version, but it probably isn't worth the trouble here.

@M2ck Since F-droid builds will not use Google Anlaytics, we won't be able to get crash reports. Can you see to it that the description for where the app is downloaded says to raise a Github issue in this repository for bugs/crashes as we won't know about them otherwise? Thanks.

ghost commented 8 years ago

@p4r4n01d maybe that could help you do you know this librairy: ACRA? ACRA allows you get crash reports via a GoogleDoc form, would it be a good substitute to Google Analaytics?

p4r4n01d commented 8 years ago

@M2ck Good idea, I have been wanting to include some extra data in the crash reports as the stack trace isn't always that helpful when trying to fix issues. ACRA looks to be even better than the crash reports from Google Play in this regard. I shouldn't have mentioned crash reports in Google Analytics, they are overly superficial and without a stack trace they can really only be used to fix trivial issues.

ghost commented 8 years ago

@p4r4n01d glad I was able to direct you on a good alternative!

JBirdVegas commented 8 years ago

@p4r4n01d, Sorry for the delayed response this past sprint at work was a particularly crazy.

The build process won't be affected except that full builds will take longer because it's actually going to build 4 full apps (googlePlay:debug | googlePlay:release | noAnalytics:debug | noAnalytics:release).

You can get around this by being more specific about which package you would like to build. For example if you were building a release build typically you would do something ./gradlew clean build if you really just wanted to build only the production apps (debug and release) you could just do ./gradlew clean assembleGooglePlay

with this patch a full build ./gradlew build took 3 mins 3.99 secs where as building only the google play edition ./gradlew clean assembleGooglePlay took 1 mins 30.793 secs

But we could do better by only building the release apk and not the debug build. ./gradlew clean assembleGooglePlayRelease took 43.475 secs

Then the fdroid team can just build the app without analytics with something like ./gradlew clean assembleNoAnalytics (not sure if they care about the build being debuggable or not but both release and debug are built with this command)

As for the crash reports why not use a full featured crash analytics platform like fabric.io (formally crashlytics)? Or we could roll our own by registering an default uncaught exception handler in the TheApplication.

Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        // Send logs to an s3 bucket or server we setup
    }
});

I like fabric, it's easy and provides good stacktraces and detailed env information. I did a simple integration with fabric in PR #55.

JBirdVegas commented 8 years ago

I'll move the crash reports to fabric.io to the googlePlay build. This will keep it out of the noAnalytics apk for F-Droid

JBirdVegas commented 8 years ago

@p4r4n01d Given the changes to the build as described you good with merging?

p4r4n01d commented 8 years ago

@JBirdVegas Yep fine for you to merge this.

Not related to this PR, but I cannot build the app with Crashlytics (I temporarily enabled it for debug builds so I could test it):

                                                                    03-26 12:19:53.099 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .
                                                                    03-26 12:19:53.099 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.100 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.100 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.100 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .   \ |  | /
                                                                    03-26 12:19:53.100 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .    \    /
                                                                    03-26 12:19:53.101 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     \  /
                                                                    03-26 12:19:53.101 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .      \/
                                                                    03-26 12:19:53.101 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .
                                                                    03-26 12:19:53.101 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
                                                                                                                                             install an Android build tool and ask a team member to invite you to this app's organization.
                                                                    03-26 12:19:53.102 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .
                                                                    03-26 12:19:53.102 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .      /\
                                                                    03-26 12:19:53.102 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     /  \
                                                                    03-26 12:19:53.102 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .    /    \
                                                                    03-26 12:19:53.103 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .   / |  | \
                                                                    03-26 12:19:53.103 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.103 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.104 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .     |  |
                                                                    03-26 12:19:53.104 26323-26323/com.jbirdvegas.mgerrit E/CrashlyticsCore: .
                                                                    03-26 12:19:53.105 26323-26323/com.jbirdvegas.mgerrit D/AndroidRuntime: Shutting down VM
                                                                    03-26 12:19:53.108 26323-26323/com.jbirdvegas.mgerrit E/AndroidRuntime: FATAL EXCEPTION: main
                                                                    Process: com.jbirdvegas.mgerrit, PID: 26323
                                                                    Theme: themes:{}
                                                                    java.lang.RuntimeException: Unable to create application com.jbirdvegas.mgerrit.TheApplication: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.core.CrashlyticsMissingDependencyException: 
                                                                    This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
                                                                    install an Android build tool and ask a team member to invite you to this app's organization.

                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4754)
                                                                        at android.app.ActivityThread.-wrap1(ActivityThread.java)
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                        at android.app.ActivityThread.main(ActivityThread.java:5461)
                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                     Caused by: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.core.CrashlyticsMissingDependencyException: 
                                                                    This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
                                                                    install an Android build tool and ask a team member to invite you to this app's organization.

                                                                        at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:288)
                                                                        at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:236)
                                                                        at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44)
                                                                        at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611)
                                                                        at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43)
                                                                        at io.fabric.sdk.android.Kit.initialize(Kit.java:66)
                                                                        at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:439)
                                                                        at io.fabric.sdk.android.Fabric.init(Fabric.java:383)
                                                                        at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:340)
                                                                        at io.fabric.sdk.android.Fabric.with(Fabric.java:311)
                                                                        at com.jbirdvegas.mgerrit.TheApplication.onCreate(TheApplication.java:53)
                                                                        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4751)
                                                                            ... 8 more
                                                                     Caused by: com.crashlytics.android.core.CrashlyticsMissingDependencyException: 
                                                                    This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
                                                                    install an Android build tool and ask a team member to invite you to this app's organization.

                                                                        at com.crashlytics.android.core.BuildIdValidator.validate(BuildIdValidator.java:59)
                                                                        at com.crashlytics.android.core.CrashlyticsCore.setAndValidateKitProperties(CrashlyticsCore.java:319)
                                                                        at com.crashlytics.android.core.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:262)
                                                                            ... 20 more