Skip to content

Commit

Permalink
Remove use of Datadog RUM (#925)
Browse files Browse the repository at this point in the history
* Remove datadog

* Update CI

* update Makefile

* update Makefile

* remove datadog directory

* Use Sentry for crash reporting (#927)

* update Makefile

* Add back Sentry for crash reporting

* remove datadog from gradle config
  • Loading branch information
atavism authored Oct 10, 2023
1 parent 3fd7183 commit 5ff6078
Show file tree
Hide file tree
Showing 23 changed files with 230 additions and 355 deletions.
8 changes: 8 additions & 0 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 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
16 changes: 5 additions & 11 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 @@ -299,7 +293,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 +308,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 +322,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 +337,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
49 changes: 30 additions & 19 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 @@ -180,8 +180,6 @@ android {
buildConfigField "boolean", "STICKY_CONFIG", getBoolean("stickyConfig")
buildConfigField "boolean", "STAGING", getBoolean("useStaging")
buildConfigField "boolean", "PLAY_VERSION", getBoolean("playVersion")
buildConfigField "String", "DD_CLIENT_TOKEN", ddClientToken()
buildConfigField "String", "DD_APPLICATION_ID", ddApplicationID()
buildConfigField "String", "COUNTRY", userCountry()
buildConfigField "String", "PAYMENT_PROVIDER", paymentProvider()
buildConfigField "String", "PRO_SERVER_URL", proServerUrl()
Expand Down Expand Up @@ -323,22 +321,6 @@ def getInt(name) {
return value.toInteger()
}

def ddApplicationID() {
def value = project.getProperties().get("ddApplicationID")
if (value == null || !value?.trim()) {
return "\"\""
}
return String.format("\"%s\"", value)
}

def ddClientToken() {
def value = project.getProperties().get("ddClientToken")
if (value == null || !value?.trim()) {
return "\"\""
}
return String.format("\"%s\"", value)
}

def userCountry() {
def value = project.getProperties().get("country")
if (value == null || !value?.trim()) {
Expand Down Expand Up @@ -473,3 +455,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 @@ -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 5ff6078

Please sign in to comment.