Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into atavism/google-play-test
Browse files Browse the repository at this point in the history
  • Loading branch information
atavism committed Oct 10, 2023
2 parents 9d9f249 + bd226a0 commit 0601186
Show file tree
Hide file tree
Showing 24 changed files with 254 additions and 347 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/browerstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
run: |
git config --global url."https://${{ secrets.GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@v1
with:
version: latest
token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets
organization: getlantern
project: android

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -62,7 +70,7 @@ jobs:
CI: "true"
run: |
flutter pub get
make do-android-debug ANDROID_ARCH=all
make appium-test-build
- name: List files in current directory
run: ls -la
Expand All @@ -74,7 +82,7 @@ jobs:
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-prod-debug.apk"
BROWSERSTACK_APP_PATH: "build/app/outputs/flutter-apk/app-appiumtest-debug.apk"
run: |
response=$(curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload" \
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ permissions:
env:
GOPRIVATE: github.com/getlantern
S3_BUCKET: lantern
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_SITE: datadoghq.eu
jobs:
set-version:
runs-on:
Expand Down Expand Up @@ -84,6 +82,14 @@ jobs:
run: |
git config --global url."https://${{ secrets.GH_TOKEN }}:[email protected]/".insteadOf "https://github.com/"
- name: Setup Sentry CLI
uses: mathieu-bour/setup-sentry-cli@v1
with:
version: latest
token: ${{ SECRETS.SENTRY_TOKEN }} # from GitHub secrets
organization: getlantern
project: android

- name: Setup JDK 11
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -118,16 +124,9 @@ jobs:
fileDir: './android/app'
encodedString: ${{ secrets.KEYSTORE }}

- name: Install Datadog CI
run: npm install -g @datadog/datadog-ci

- name: Build Android installers
run: make package-android
env:
DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_SITE: datadoghq.eu
INTERSTITIAL_AD_UNIT: "${{ secrets.INTERSTITIAL_AD_UNIT_ID }}"
VERSION: "${{ env.version }}"

Expand Down
8 changes: 8 additions & 0 deletions .run/Appium Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Appium Test" type="FlutterRunConfigurationType" factoryName="Flutter">
<option name="additionalArgs" value="--dart-define=app.flavor=appiumTest" />
<option name="buildFlavor" value="appiumTest" />
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
<method v="2" />
</configuration>
</component>
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ ADB := $(call get-command,adb)
OPENSSL := $(call get-command,openssl)
GMSAAS := $(call get-command,gmsaas)
SENTRY := $(call get-command,sentry-cli)
DATADOGCI := $(call get-command,datadog-ci)
BASE64 := $(call get-command,base64)

GIT_REVISION_SHORTCODE := $(shell git rev-parse --short HEAD)
Expand Down Expand Up @@ -90,7 +89,6 @@ PROD_BASE_NAME ?= $(INSTALLER_NAME)
## secrets Keys
INTERSTITIAL_AD_UNIT=ca-app-pub-2685698271254859/9922829329
## vault secrets
VAULT_DD_SECRETS_PATH ?= secret/apps/datadog/android
VAULT_ADS_SECRETS_PATH ?= secret/googleAds

## vault keys
Expand Down Expand Up @@ -245,10 +243,6 @@ require-magick:
require-sentry:
@if [[ -z "$(SENTRY)" ]]; then echo 'Missing "sentry-cli" command. See sentry.io for installation instructions.'; exit 1; fi

.PHONY: require-datadog-ci
require-datadog-ci:
@if [[ -z "$(DATADOGCI)" ]]; then echo 'Missing "datadog-ci" command. See https://www.npmjs.com/package/@datadog/datadog-ci for installation instructions.'; exit 1; fi

release-autoupdate: require-version
@TAG_COMMIT=$$(git rev-list --abbrev-commit -1 $(TAG)) && \
if [[ -z "$$TAG_COMMIT" ]]; then \
Expand Down Expand Up @@ -280,9 +274,12 @@ $(MOBILE_ANDROID_LIB): $(ANDROID_LIB)
mkdir -p $(MOBILE_LIBS) && \
cp $(ANDROID_LIB) $(MOBILE_ANDROID_LIB)

.PHONY: android-lib
.PHONY: android-lib appium-test-build
android-lib: $(MOBILE_ANDROID_LIB)

appium-test-build:
flutter build apk --flavor=appiumTest --dart-define=app.flavor=appiumTest --debug

$(MOBILE_TEST_APK) $(MOBILE_TESTS_APK): $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
@$(GRADLE) -PandroidArch=$(ANDROID_ARCH) \
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
Expand All @@ -299,7 +296,7 @@ do-android-debug: $(MOBILE_SOURCES) $(MOBILE_ANDROID_LIB)
echo "Value of DART_DEFINES is: $$DART_DEFINES" && \
CI="$$CI" && \
echo "Value of CI is: $$CI" && \
$(GRADLE) -Pdart-defines="$$DART_DEFINES" -PlanternVersion=$(DEBUG_VERSION) -PddClientToken=$$DD_CLIENT_TOKEN -PddApplicationID=$$DD_APPLICATION_ID \
$(GRADLE) -Pdart-defines="$$DART_DEFINES" -PlanternVersion=$(DEBUG_VERSION) \
-PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) -Pcountry=$(COUNTRY) \
-PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) \
Expand All @@ -314,7 +311,7 @@ $(MOBILE_DEBUG_APK): $(MOBILE_SOURCES) $(GO_SOURCES)
make do-android-debug && \
cp $(MOBILE_ANDROID_DEBUG) $(MOBILE_DEBUG_APK)

$(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
$(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-sentry
echo $(MOBILE_ANDROID_LIB) && \
mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
Expand All @@ -328,13 +325,12 @@ $(MOBILE_RELEASE_APK): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) req
-PandroidArchJava="$(ANDROID_ARCH_JAVA)" -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=$(FORCE_PLAY_VERSION) -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) \
-PversionCode=$(VERSION_CODE) -PdevelopmentMode=$(DEVELOPMENT_MODE) -b $(MOBILE_DIR)/app/build.gradle assembleProdSideload && \
DATADOG_API_KEY=4901456bb88bbf1dc7799eab7d4f71ae DATADOG_SITE=datadoghq.eu datadog-ci flutter-symbols upload --service-name lantern-android --dart-symbols-location build/app/intermediates/merged_native_libs/prodSideload/out/lib \
--android-mapping-location build/app/outputs/mapping/prodSideload/mapping.txt --android-mapping --ios-dsyms && \
sentry-cli upload-dif --wait -o getlantern -p android build/app/intermediates/merged_native_libs/prodSideload/out/lib && \
cp $(MOBILE_ANDROID_RELEASE) $(MOBILE_RELEASE_APK) && \
cat $(MOBILE_RELEASE_APK) | bzip2 > lantern_update_android_arm.bz2


$(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-datadog-ci
$(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-sentry
@mkdir -p ~/.gradle && \
ln -fs $(MOBILE_DIR)/gradle.properties . && \
COUNTRY="$$COUNTRY" && \
Expand All @@ -344,6 +340,7 @@ $(MOBILE_BUNDLE): $(MOBILE_SOURCES) $(GO_SOURCES) $(MOBILE_ANDROID_LIB) require-
$(GRADLE) -PlanternVersion=$$VERSION -PlanternRevisionDate=$(REVISION_DATE) -PandroidArch=$(ANDROID_ARCH) -PandroidArchJava="$(ANDROID_ARCH_JAVA)" \
-PddClientToken=$(DD_CLIENT_TOKEN) -PddApplicationID=$(DD_APPLICATION_ID) -PproServerUrl=$(PRO_SERVER_URL) -PpaymentProvider=$(PAYMENT_PROVIDER) \
-Pcountry=$(COUNTRY) -PplayVersion=true -PuseStaging=$(STAGING) -PstickyConfig=$(STICKY_CONFIG) -b $(MOBILE_DIR)/app/build.gradle bundlePlay && \
sentry-cli upload-dif --wait -o getlantern -p android build/app/intermediates/merged_native_libs/prodPlay/out/lib && \
cp $(MOBILE_ANDROID_BUNDLE) $(MOBILE_BUNDLE)

android-debug: $(MOBILE_DEBUG_APK)
Expand Down
37 changes: 34 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'com.google.protobuf'
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "1.10.0"
id "io.sentry.android.gradle" version "3.13.0"
}

def localProperties = new Properties()
Expand Down Expand Up @@ -170,8 +170,7 @@ android {
}

buildTypes {

debug {
debug {
minifyEnabled false
shrinkResources false
debuggable true
Expand Down Expand Up @@ -254,6 +253,9 @@ android {
autoTest {
versionCode 1 // so we can always test auto-update.
}
appiumTest {
buildConfigField "boolean", "CI", "true"
}
}

splits {
Expand Down Expand Up @@ -455,3 +457,32 @@ dependencies {
}

apply plugin: 'com.google.gms.google-services'

sentry {

// Disables or enables the handling of Proguard mapping for Sentry.
// If enabled the plugin will generate a UUID and will take care of
// uploading the mapping to Sentry. If disabled, all the logic
// related to proguard mapping will be excluded.
// Default is enabled.
includeProguardMapping = true


// Whether the plugin should attempt to auto-upload the mapping file to Sentry or not.
// If disabled the plugin will run a dry-run and just generate a UUID.
// The mapping file has to be uploaded manually via sentry-cli in this case.
// Default is enabled.
autoUploadProguardMapping = true

// Disables or enables the automatic configuration of Native Symbols
// for Sentry. This executes sentry-cli automatically so
// you don't need to do it manually.
// Default is disabled.
uploadNativeSymbols = true

// Does or doesn't include the source code of native code for Sentry.
// This executes sentry-cli with the --include-sources param. automatically so
// you don't need to do it manually.
// Default is disabled.
includeNativeSources = false
}
4 changes: 2 additions & 2 deletions android/app/libs/liblantern-all.aar
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import io.lantern.model.BaseModel
import io.lantern.model.Vpn
import org.getlantern.lantern.BuildConfig
import org.getlantern.lantern.LanternApp
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.model.Bandwidth
import org.getlantern.lantern.model.Stats
import org.getlantern.lantern.model.Utils
Expand Down Expand Up @@ -329,7 +328,7 @@ abstract class SessionManager(application: Application) : Session {
val isPaymentTestMode: Boolean
get() {
val paymentTestMode = prefs.getBoolean(PAYMENT_TEST_MODE, false)
val ciValue = BuildConfig.CI
val ciValue = BuildConfig.FLAVOR == "appiumTest"
return ciValue || paymentTestMode
}

Expand Down Expand Up @@ -386,7 +385,6 @@ abstract class SessionManager(application: Application) : Session {

override fun setCountry(country: String) {
prefs.edit().putString(GEO_COUNTRY_CODE, country).apply()
Datadog.setCountry(country)
}

private val hasUpdatedStats = AtomicBoolean()
Expand Down
5 changes: 0 additions & 5 deletions android/app/src/main/kotlin/io/lantern/model/SessionModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.getlantern.lantern.MainActivity
import org.getlantern.lantern.R
import org.getlantern.lantern.activity.FreeKassaActivity_
import org.getlantern.lantern.activity.WebViewActivity_
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.model.LanternHttpClient
import org.getlantern.lantern.model.LanternHttpClient.ProCallback
import org.getlantern.lantern.model.LanternHttpClient.ProUserCallback
Expand Down Expand Up @@ -182,10 +181,6 @@ class SessionModel(
}
}

"trackUserAction" -> {
Datadog.trackUserClick(call.argument("message")!!)
}

"acceptTerms" -> {
LanternApp.getSession().acceptTerms()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package org.getlantern.lantern
import android.app.Application
import android.content.Context
import android.os.StrictMode
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDex
import org.getlantern.lantern.model.InAppBilling
import org.getlantern.lantern.model.LanternHttpClient
import org.getlantern.lantern.model.LanternSessionManager
import org.getlantern.lantern.util.debugOnly
import org.getlantern.lantern.util.LanternProxySelector
import org.getlantern.mobilesdk.Logger
import org.getlantern.lantern.util.SentryUtil
import org.getlantern.mobilesdk.util.HttpClient

open class LanternApp : Application() {
Expand Down Expand Up @@ -40,13 +39,14 @@ open class LanternApp : Application() {

override fun onCreate() {
super.onCreate()
SentryUtil.enableGoPanicEnrichment(this)

// Necessary to locate a back arrow resource we use from the
// support library. See http://stackoverflow.com/questions/37615470/support-library-vectordrawable-resourcesnotfoundexception
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
appContext = applicationContext
session = LanternSessionManager(this)

LanternProxySelector(session)

if (session.isPlayVersion) inAppBilling = InAppBilling(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import io.lantern.model.VpnModel
import kotlinx.coroutines.*
import okhttp3.Response
import org.getlantern.lantern.activity.WebViewActivity_
import org.getlantern.lantern.datadog.Datadog
import org.getlantern.lantern.event.EventManager
import org.getlantern.lantern.model.AccountInitializationStatus
import org.getlantern.lantern.model.Bandwidth
Expand Down Expand Up @@ -79,7 +78,6 @@ class MainActivity :
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
val start = System.currentTimeMillis()
super.configureFlutterEngine(flutterEngine)
FlutterEngineCache.getInstance().put("datadoghq_engine", flutterEngine)
messagingModel = MessagingModel(this, flutterEngine)
vpnModel = VpnModel(this, flutterEngine, ::switchLantern)
sessionModel = SessionModel(this, flutterEngine)
Expand All @@ -89,7 +87,6 @@ class MainActivity :
eventManager = object : EventManager("lantern_event_channel", flutterEngine) {
override fun onListen(event: Event) {
if (LanternApp.getSession().lanternDidStart()) {
flutterNavigation.invokeMethod("initDatadog", null)
fetchLoConf()
Logger.debug(
TAG,
Expand Down Expand Up @@ -305,7 +302,7 @@ class MainActivity :
private fun updateUserData() {
lanternClient.userData(object : ProUserCallback {
override fun onFailure(throwable: Throwable?, error: ProError?) {
Datadog.addError("Unable to fetch user data: $error", throwable)
Logger.error(TAG, "Unable to fetch user data: $error", throwable)
}

override fun onSuccess(response: Response, user: ProUser?) {
Expand All @@ -330,7 +327,7 @@ class MainActivity :
private fun updatePlans() {
lanternClient.getPlans(object : PlansCallback {
override fun onFailure(throwable: Throwable?, error: ProError?) {
Datadog.addError("Unable to fetch user plans: $error", throwable)
Logger.error(TAG, "Unable to fetch user plans: $error", throwable)
}

override fun onSuccess(proPlans: Map<String, ProPlan>) {
Expand All @@ -347,7 +344,7 @@ class MainActivity :
private fun updatePaymentMethods() {
lanternClient.plansV3(object : PlansV3Callback {
override fun onFailure(throwable: Throwable?, error: ProError?) {
Datadog.addError("Unable to fetch payment methods: $error", throwable)
Logger.error(TAG, "Unable to fetch payment methods: $error", throwable)
}

override fun onSuccess(
Expand Down
Loading

0 comments on commit 0601186

Please sign in to comment.