diff --git a/android/app/libs/alipaySdk-15.7.6-20200521195109.aar b/android/app/libs/alipaySdk-15.7.6-20200521195109.aar index 58b776abf..7878da034 100644 Binary files a/android/app/libs/alipaySdk-15.7.6-20200521195109.aar and b/android/app/libs/alipaySdk-15.7.6-20200521195109.aar differ diff --git a/android/app/src/main/java/org/getlantern/mobilesdk/model/SessionManager.kt b/android/app/src/main/java/org/getlantern/mobilesdk/model/SessionManager.kt index 1c9292d3a..58841b846 100644 --- a/android/app/src/main/java/org/getlantern/mobilesdk/model/SessionManager.kt +++ b/android/app/src/main/java/org/getlantern/mobilesdk/model/SessionManager.kt @@ -24,6 +24,7 @@ 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 @@ -385,6 +386,7 @@ 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() diff --git a/android/app/src/main/kotlin/org/getlantern/lantern/LanternApp.kt b/android/app/src/main/kotlin/org/getlantern/lantern/LanternApp.kt index 755f59b1b..730fea353 100644 --- a/android/app/src/main/kotlin/org/getlantern/lantern/LanternApp.kt +++ b/android/app/src/main/kotlin/org/getlantern/lantern/LanternApp.kt @@ -6,8 +6,6 @@ import android.os.StrictMode import android.util.Log import androidx.appcompat.app.AppCompatDelegate import androidx.multidex.MultiDex -import org.getlantern.lantern.datadog.Datadog -import org.getlantern.lantern.datadog.FlutterExcludingComponentPredicate import org.getlantern.lantern.model.InAppBilling import org.getlantern.lantern.model.LanternHttpClient import org.getlantern.lantern.model.LanternSessionManager @@ -48,7 +46,6 @@ open class LanternApp : Application() { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) appContext = applicationContext session = LanternSessionManager(this) - if (!BuildConfig.DEBUG) Datadog.initialize() LanternProxySelector(session) diff --git a/android/app/src/main/kotlin/org/getlantern/lantern/datadog/Datadog.kt b/android/app/src/main/kotlin/org/getlantern/lantern/datadog/Datadog.kt index 29f5467f1..c98085d2f 100644 --- a/android/app/src/main/kotlin/org/getlantern/lantern/datadog/Datadog.kt +++ b/android/app/src/main/kotlin/org/getlantern/lantern/datadog/Datadog.kt @@ -1,7 +1,6 @@ package org.getlantern.lantern.datadog import android.util.Log -import com.datadog.android.Datadog as DatadogMain import com.datadog.android.DatadogSite import com.datadog.android.core.configuration.BatchSize import com.datadog.android.core.configuration.Configuration @@ -17,13 +16,20 @@ import org.getlantern.lantern.LanternApp import org.getlantern.mobilesdk.Logger import java.net.InetSocketAddress import java.net.Proxy +import java.net.URI import java.util.concurrent.atomic.AtomicBoolean +import com.datadog.android.Datadog as DatadogMain object Datadog { - private val tracedHosts = listOf( - "datadoghq.eu", - "127.0.0.1", - ) + private val tracedHosts = + listOf( + "datadoghq.eu", + "127.0.0.1", + "iantem.io", + "getlantern.org", + "getiantem.org", + "lantern.io", + ) private val initialized = AtomicBoolean() private lateinit var datadogConfig: Configuration @@ -33,13 +39,14 @@ object Datadog { DatadogMain.setVerbosity(Log.VERBOSE) datadogConfig = createDatadogConfiguration() - val datadogCredentials = Credentials( - clientToken = "puba617ab01333a95a25a9d3709f04e1654", - envName = "prod", - rumApplicationId = "f8eabf3c-5db3-4f7e-8e6a-5a72433b46d2", - variant = "release", - serviceName = "lantern-android", - ) + val datadogCredentials = + Credentials( + clientToken = "puba617ab01333a95a25a9d3709f04e1654", + envName = "prod", + rumApplicationId = "f8eabf3c-5db3-4f7e-8e6a-5a72433b46d2", + variant = "release", + serviceName = "lantern-android", + ) DatadogMain.initialize( LanternApp.getAppContext(), @@ -52,9 +59,20 @@ object Datadog { id = LanternApp.getSession().userId().toString(), ) - val monitor = RumMonitor.Builder().build() - GlobalRum.registerIfAbsent(monitor) + GlobalRum.registerIfAbsent { + RumMonitor.Builder().build() + } + val session = LanternApp.getSession() + setCountry(session.countryCode) initialized.set(true) + + // For some reason, sessions don't show up in DataDog RUM until we register a user action + // of some sort. So, here we fire the custom action "started" to get data to start flowing. + GlobalRum.get().addUserAction(RumActionType.CUSTOM, "started", emptyMap()) + } + + fun setCountry(country: String) { + GlobalRum.addAttribute("lantern.country_code", country) } fun addError( @@ -68,12 +86,12 @@ object Datadog { // trackUserAction is used to track specific user actions (such as taps, clicks, and scrolls) // with RumMonitor - fun trackUserAction( + private fun trackUserAction( actionType: RumActionType, name: String, actionAttributes: Map = emptyMap(), ) { - GlobalRum.get().addUserAction(actionType, name, actionAttributes) + GlobalRum.get().addUserAction(actionType, name, actionAttributes) } // trackUserClick is used to track user clicks with RumMonitor @@ -94,6 +112,8 @@ object Datadog { private fun createDatadogConfiguration(): Configuration { val session = LanternApp.getSession() + val hTTPAddr = session.hTTPAddr + val uri = URI("http://" + hTTPAddr) return Configuration.Builder( logsEnabled = true, tracesEnabled = true, @@ -105,8 +125,8 @@ object Datadog { Proxy( Proxy.Type.HTTP, InetSocketAddress( - session.settings.httpProxyHost, - session.settings.httpProxyPort.toInt(), + "127.0.0.1", + uri.getPort(), ), ), null, @@ -114,6 +134,7 @@ object Datadog { .sampleRumSessions(100f) .setUploadFrequency(UploadFrequency.FREQUENT) .useSite(DatadogSite.EU1) + .trackBackgroundRumEvents(true) .trackInteractions() .trackLongTasks() .setFirstPartyHosts(tracedHosts) diff --git a/android/app/src/main/kotlin/org/getlantern/lantern/service/LanternService.kt b/android/app/src/main/kotlin/org/getlantern/lantern/service/LanternService.kt index ac39595ae..a49cd12ba 100644 --- a/android/app/src/main/kotlin/org/getlantern/lantern/service/LanternService.kt +++ b/android/app/src/main/kotlin/org/getlantern/lantern/service/LanternService.kt @@ -13,6 +13,7 @@ import org.androidannotations.annotations.EService import org.getlantern.lantern.BuildConfig import org.getlantern.lantern.LanternApp import org.getlantern.lantern.R +import org.getlantern.lantern.datadog.Datadog import org.getlantern.lantern.model.AccountInitializationStatus import org.getlantern.lantern.model.LanternHttpClient import org.getlantern.lantern.model.LanternStatus @@ -109,6 +110,8 @@ open class LanternService : Service(), Runnable { createUser(0) } + Datadog.initialize() + if (!BuildConfig.PLAY_VERSION && !BuildConfig.DEVELOPMENT_MODE) { // check if an update is available autoUpdater.checkForUpdates() diff --git a/go.mod b/go.mod index 4a820a74f..3f8ed6ac8 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/getlantern/dnsgrab v0.0.0-20211216020425-5d5e155a01a8 github.com/getlantern/errors v1.0.3 github.com/getlantern/eventual/v2 v2.0.2 - github.com/getlantern/flashlight/v7 v7.6.7 + github.com/getlantern/flashlight/v7 v7.6.8 github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 github.com/getlantern/idletiming v0.0.0-20201229174729-33d04d220c4e github.com/getlantern/ipproxy v0.0.0-20230511223023-ee52513fd782 diff --git a/go.sum b/go.sum index 01fceed15..012d57712 100644 --- a/go.sum +++ b/go.sum @@ -373,8 +373,8 @@ github.com/getlantern/fdcount v0.0.0-20210503151800-5decd65b3731/go.mod h1:XZwE+ github.com/getlantern/filepersist v0.0.0-20160317154340-c5f0cd24e799/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c h1:mcz27xtAkb1OuOLBct/uFfL1p3XxAIcFct82GbT+UZM= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= -github.com/getlantern/flashlight/v7 v7.6.7 h1:61ueXqAv2tzM2TjSfmL14I0oaxf6LhTYK2eHLAx29QQ= -github.com/getlantern/flashlight/v7 v7.6.7/go.mod h1:FLZhyLFeSojL4sRjQEaLRtVl4RB1DdliWegTsIqgzlI= +github.com/getlantern/flashlight/v7 v7.6.8 h1:z4jdHzZuHa0NT98ua8Qx24QIblDViyQ2RfgIxXAfibw= +github.com/getlantern/flashlight/v7 v7.6.8/go.mod h1:FLZhyLFeSojL4sRjQEaLRtVl4RB1DdliWegTsIqgzlI= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede h1:yrU6Px3ZkvCsDLPryPGi6FN+2iqFPq+JeCb7EFoDBhw= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede/go.mod h1:nhnoiS6DE6zfe+BaCMU4YI01UpsuiXnDqM5S8jxHuuI= github.com/getlantern/fronted v0.0.0-20230601004823-7fec719639d8 h1:r/Z/SPPIfLXDI3QA7/tE6nOfPncrqeUPDjiFjnNGP50=