Skip to content

Commit

Permalink
For mozilla-mobile#1298: Work on Adjust campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Oct 16, 2019
1 parent c16f0dc commit 2268994
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
14 changes: 14 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,17 @@
# Keep motionlayout internal methods
# https://github.com/mozilla-mobile/fenix/issues/2094
-keep class androidx.constraintlayout.** { *; }

# Keep adjust relevant classes
-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package="org.mozilla.fenix">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/mozilla/fenix/components/Analytics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.mozilla.fenix.components.metrics.AdjustMetricsService
import org.mozilla.fenix.components.metrics.GleanMetricsService
import org.mozilla.fenix.components.metrics.LeanplumMetricsService
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.test.Mockable
import org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID
import org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION
Expand Down Expand Up @@ -84,7 +83,7 @@ class Analytics(
LeanplumMetricsService(context as Application),
AdjustMetricsService(context)
),
isTelemetryEnabled = { context.settings().isTelemetryEnabled }
isTelemetryEnabled = { true }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,32 @@ import android.util.Log
import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig
import com.adjust.sdk.LogLevel
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.ext.settings

class AdjustMetricsService(private val application: Application) : MetricsService {
override fun start() {
if ((BuildConfig.ADJUST_TOKEN.isNullOrEmpty())) {
Log.i(LOGTAG, "No adjust token defined")

if (Config.channel.isReleased) {
throw IllegalStateException("No adjust token defined for release build")
}

return
}

Log.d("Sawyer", "Starting Adjust service")
val fakeToken = "012345678901"
val config = AdjustConfig(
application,
BuildConfig.ADJUST_TOKEN,
AdjustConfig.ENVIRONMENT_PRODUCTION,
true
fakeToken,
AdjustConfig.ENVIRONMENT_SANDBOX,
false
)

config.setLogLevel(LogLevel.VERBOSE)

config.setOnAttributionChangedListener {
it.campaign?.let { campaign ->
Log.d("Sawyer", "campaign: " + campaign)
application.settings().adjustCampaignId = campaign
}
}

config.setLogLevel(LogLevel.SUPRESS)

Adjust.onCreate(config)
Adjust.setEnabled(true)

application.registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.facts.FactProcessor
import mozilla.components.support.base.facts.Facts
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.CrashReporter
Expand Down Expand Up @@ -348,8 +347,7 @@ interface MetricController {

companion object {
fun create(services: List<MetricsService>, isTelemetryEnabled: () -> Boolean): MetricController {
return if (BuildConfig.TELEMETRY) return ReleaseMetricController(services, isTelemetryEnabled)
else DebugMetricController()
return ReleaseMetricController(services, isTelemetryEnabled )
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ object Versions {
const val robolectric = "4.2.1"

const val google_ads_id_version = "16.0.0"
const val google_analytics_version = "16.0.4"

const val airbnb_lottie = "3.0.7"
}
Expand Down Expand Up @@ -212,6 +213,7 @@ object Deps {
const val fenix_megazord_forUnitTests = "org.mozilla.appservices:fenix-megazord-forUnitTests:${Versions.mozilla_appservices}"

const val google_ads_id = "com.google.android.gms:play-services-ads-identifier:${Versions.google_ads_id_version}"
const val google_play_analytics = "com.google.android.gms:play-services-analytics:${Versions.google_analytics_version}"

const val lottie = "com.airbnb.android:lottie:${Versions.airbnb_lottie}"
}

0 comments on commit 2268994

Please sign in to comment.