Skip to content

Commit

Permalink
Initial basic implementation of Analytics (quran#1471)
Browse files Browse the repository at this point in the history
Implement analytics in such a way as to be able to swap out the
implementation with a NoopImplementation for cases where we don't want
to use Firebase.
  • Loading branch information
ahmedre authored Oct 25, 2020
1 parent 21bddef commit b3aac8f
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ if (new File(rootDir, 'extras/extras.gradle').exists()) {
}

dependencies {
implementation project(path: ':common:analytics')
implementation project(path: ':common:audio')
implementation project(path: ':common:data')
implementation project(path: ':common:networking')
Expand Down
1 change: 1 addition & 0 deletions app/pluggable.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dependencies {
implementation project(path: ':pages:madani')
implementation project(path: ':feature:analytics-noop')
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.quran.labs.androidquran.di.component.application;

import com.quran.analytics.provider.AnalyticsModule;
import com.quran.common.networking.NetworkModule;
import com.quran.data.page.provider.QuranPageModule;
import com.quran.labs.androidquran.QuranApplication;
Expand Down Expand Up @@ -40,6 +41,7 @@

@Singleton
@Component(modules = {
AnalyticsModule.class,
ApplicationModule.class,
DatabaseModule.class,
NetworkModule.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.widget.ArrayAdapter;
import android.widget.Toast;

import com.quran.analytics.AnalyticsProvider;
import com.quran.data.core.QuranInfo;
import com.quran.data.model.SuraAyah;
import com.quran.labs.androidquran.HelpActivity;
Expand Down Expand Up @@ -219,6 +220,7 @@ public class PagerActivity extends QuranActionBarActivity implements
@Inject QuranInfo quranInfo;
@Inject QuranFileUtils quranFileUtils;
@Inject AudioPresenter audioPresenter;
@Inject AnalyticsProvider analyticsProvider;

private CompositeDisposable compositeDisposable;
private final CompositeDisposable foregroundDisposable = new CompositeDisposable();
Expand Down
10 changes: 10 additions & 0 deletions common/analytics/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'

dependencies {
implementation "androidx.annotation:annotation:${androidxAnnotationVersion}"

// dagger
kapt deps.dagger.apt
implementation deps.dagger.runtime
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.quran.analytics

fun interface AnalyticsProvider {
fun logEvent(name: String, params: Map<String, Any>)
}
11 changes: 11 additions & 0 deletions feature/analytics-noop/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'

dependencies {
implementation project(":common:analytics")
implementation "androidx.annotation:annotation:${androidxAnnotationVersion}"

// dagger
kapt deps.dagger.apt
implementation deps.dagger.runtime
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.quran.analytics.provider

import com.quran.analytics.AnalyticsProvider
import dagger.Binds
import dagger.Module

@Module
interface AnalyticsModule {

@Binds
fun provideAnalyticsProvider(noopAnalyticsProvider: NoopAnalyticsProvider): AnalyticsProvider
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.quran.analytics.provider

import com.quran.analytics.AnalyticsProvider
import javax.inject.Inject

class NoopAnalyticsProvider @Inject constructor() : AnalyticsProvider {

override fun logEvent(
name: String,
params: Map<String, Any>
) {
}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
include ':app'
include ':common:analytics'
include ':common:audio'
include ':common:data'
include ':common:networking'
include ':common:pages'
include ':common:search'
include ':feature:analytics-noop'
include ':feature:audio'
include ':pages:madani'

Expand Down

0 comments on commit b3aac8f

Please sign in to comment.