1
0
Fork 0

Fixes #891 - Adds the leanplum sdk

master
Jeff Boek 2019-03-06 23:19:31 -08:00
parent 7bd49a05c9
commit 521ca74836
6 changed files with 56 additions and 4 deletions

4
.gitignore vendored
View File

@ -73,3 +73,7 @@ gen-external-apklibs
# macOS
.DS_Store
# Token files
.leanplum_token
.adjust_token

View File

@ -181,12 +181,12 @@ android.applicationVariants.all { variant ->
def buildDate = Config.generateBuildDate()
buildConfigField 'String', 'BUILD_DATE', '"' + buildDate + '"'
// -------------------------------------------------------------------------------------------------
// Adjust: Read token from locale file if it exists (Only release builds)
// -------------------------------------------------------------------------------------------------
def variantName = variant.getName()
// -------------------------------------------------------------------------------------------------
// Adjust: Read token from local file if it exists (Only release builds)
// -------------------------------------------------------------------------------------------------
print("Adjust token: ")
if (variantName.contains("Release")) {
@ -202,6 +202,25 @@ android.applicationVariants.all { variant ->
buildConfigField 'String', 'ADJUST_TOKEN', 'null'
println("--")
}
// -------------------------------------------------------------------------------------------------
// Leanplum: Read token from local file if it exists
// -------------------------------------------------------------------------------------------------
print("Leanplum token: ")
try {
def parts = new File("${rootDir}/.leanplum_token").text.trim().split(":")
def id = parts[0]
def key = parts[1]
buildConfigField 'String', 'LEANPLUM_ID', '"' + id + '"'
buildConfigField 'String', 'LEANPLUM_TOKEN', '"' + key + '"'
println "(Added from .leanplum_token file)"
} catch (FileNotFoundException ignored) {
buildConfigField 'String', 'LEANPLUM_ID', 'null'
buildConfigField 'String', 'LEANPLUM_TOKEN', 'null'
println("X_X")
}
}
androidExtensions {
@ -224,6 +243,8 @@ dependencies {
implementation Deps.sentry
implementation Deps.leanplum
implementation Deps.mozilla_concept_engine
implementation Deps.mozilla_concept_storage
implementation Deps.mozilla_concept_toolbar

View File

@ -21,6 +21,7 @@ import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.base.log.sink.AndroidLogSink
import mozilla.components.support.rustlog.RustLog
import org.mozilla.fenix.AdjustHelper.setupAdjustIfNeeded
import org.mozilla.fenix.LeanplumHelper.setupLeanplumIfNeeded
import org.mozilla.fenix.components.Components
import java.io.File
@ -49,6 +50,7 @@ open class FenixApplication : Application() {
setupGlean(this)
loadExperiments()
setupAdjustIfNeeded(this)
setupLeanplumIfNeeded(this)
}
protected open fun setupLeakCanary() {

View File

@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix
import com.leanplum.Leanplum
import com.leanplum.LeanplumActivityHelper
import com.leanplum.annotations.Parser
object LeanplumHelper {
fun setupLeanplumIfNeeded(application: FenixApplication) {
Leanplum.setApplicationContext(application)
Parser.parseVariables(application)
LeanplumActivityHelper.enableLifecycleCallbacks(application)
Leanplum.setAppIdForProductionMode(BuildConfig.LEANPLUM_ID, BuildConfig.LEANPLUM_TOKEN)
Leanplum.start(application)
}
}

View File

@ -30,6 +30,9 @@ allprojects {
maven {
url "https://maven.mozilla.org/maven2"
}
maven {
url "https://repo.leanplum.com/"
}
jcenter()
}
}

View File

@ -11,6 +11,7 @@ private object Versions {
const val anko = "0.10.8"
const val sentry = "1.7.10"
const val leakcanary = "1.6.3"
const val leanplum = "4.3.1"
const val androidx_appcompat = "1.1.0-alpha02"
const val androidx_constraint_layout = "2.0.0-alpha2"
@ -110,6 +111,8 @@ object Deps {
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}"
const val leakcanary_noop = "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakcanary}"
const val leanplum = "com.leanplum:leanplum-core:${Versions.leanplum}"
const val tools_test_runner = "com.android.support.test:runner:${Versions.test_tools}"
const val tools_espresso_core = "com.android.support.test.espresso:espresso-core:${Versions.espresso_core}"