Skip to content

Commit

Permalink
Remove code related to "live debug" sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslabari committed May 9, 2024
1 parent 461946e commit cb2de51
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 65 deletions.
1 change: 1 addition & 0 deletions embrace-android-sdk/api/embrace-android-sdk.api
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public final class io/embrace/android/embracesdk/Embrace : io/embrace/android/em
public fun setUserIdentifier (Ljava/lang/String;)V
public fun setUsername (Ljava/lang/String;)V
public fun start (Landroid/content/Context;)V
public fun start (Landroid/content/Context;Lio/embrace/android/embracesdk/Embrace$AppFramework;)V
public fun start (Landroid/content/Context;Z)V
public fun start (Landroid/content/Context;ZLio/embrace/android/embracesdk/Embrace$AppFramework;)V
public fun startMoment (Ljava/lang/String;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static org.junit.Assert.assertFalse;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;

Expand All @@ -23,14 +25,17 @@ public class PreSdkStartTest {
@Test
public void testStartWithNullContext() {
embrace.start(null);
embrace.start(null, Embrace.AppFramework.NATIVE);
embrace.start(null, true);
embrace.start(null, false, Embrace.AppFramework.NATIVE);
assertFalse(embrace.isStarted());
}

@Test
public void testStartWithNullAppFramework() {
embrace.start(testRule.harness.getOverriddenCoreModule().getContext(), false, null);
Context context = testRule.harness.getOverriddenCoreModule().getContext();
embrace.start(context, false, null);
embrace.start(context, null);
assertFalse(embrace.isStarted());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal class IntegrationTestRule(
val embraceImpl = EmbraceImpl(bootstrapper)
Embrace.setImpl(embraceImpl)
if (startImmediately) {
embraceImpl.startInternal(overriddenCoreModule.context, isDevMode, appFramework) { overriddenConfigService }
embraceImpl.startInternal(overriddenCoreModule.context, appFramework) { overriddenConfigService }
}
}
}
Expand All @@ -127,7 +127,7 @@ internal class IntegrationTestRule(
appFramework: AppFramework = harness.appFramework,
configServiceProvider: Provider<ConfigService> = { harness.overriddenConfigService }
) {
Embrace.getImpl().startInternal(context, false, appFramework, configServiceProvider)
Embrace.getImpl().startInternal(context, appFramework, configServiceProvider)
}

/**
Expand All @@ -136,7 +136,6 @@ internal class IntegrationTestRule(
internal class Harness(
currentTimeMs: Long = DEFAULT_SDK_START_TIME_MS,
val startImmediately: Boolean = true,
val isDevMode: Boolean = false,
val appFramework: AppFramework = AppFramework.NATIVE,
val overriddenClock: FakeClock = FakeClock(currentTime = currentTimeMs),
val overriddenInitModule: FakeInitModule = FakeInitModule(clock = overriddenClock),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal class CrashTest {
@Test
fun `React Native crash generates an OTel Log and matches the crashId in the session`() {
with(testRule) {
embrace.start(harness.overriddenCoreModule.context, false, Embrace.AppFramework.REACT_NATIVE)
embrace.start(harness.overriddenCoreModule.context, Embrace.AppFramework.REACT_NATIVE)

testRule.harness.recordSession {
embrace.reactNativeInternalInterface?.logUnhandledJsException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,36 @@ static void setImpl(@Nullable EmbraceImpl instance) {
@Override
public void start(@NonNull Context context) {
if (verifyNonNullParameters("start", context)) {
start(context, true, AppFramework.NATIVE);
start(context, AppFramework.NATIVE);
}
}

@Override
public void start(@NonNull Context context, @NonNull AppFramework appFramework) {
if (verifyNonNullParameters("start", context, appFramework)) {
impl.start(context, appFramework);
}
}

/**
* @deprecated Use {@link #start(Context)} instead.
*/
@Override
@Deprecated
public void start(@NonNull Context context, boolean isDevMode) {
if (verifyNonNullParameters("start", context)) {
start(context, isDevMode, AppFramework.NATIVE);
start(context);

Check warning on line 91 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/Embrace.java

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/Embrace.java#L91

Added line #L91 was not covered by tests
}
}

/**
* @deprecated Use {@link #start(Context, AppFramework)} instead.
*/
@Override
@Deprecated
public void start(@NonNull Context context, boolean isDevMode, @NonNull AppFramework appFramework) {
if (verifyNonNullParameters("start", context, appFramework)) {
impl.start(context, isDevMode, appFramework);
impl.start(context, appFramework);

Check warning on line 102 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/Embrace.java

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/Embrace.java#L102

Added line #L102 was not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ interface EmbraceAndroidApi extends EmbraceApi {
*/
void start(@NonNull Context context);

/**
* Starts instrumentation of the Android application using the Embrace SDK. This should be
* called during creation of the application, as early as possible.
* <p>
* See <a href="https://embrace.io/docs/android/">Embrace Docs</a> for
* integration instructions. For compatibility with other networking SDKs such as Akamai,
* the Embrace SDK must be initialized after any other SDK.
*
* @param context an instance of context
* @param appFramework the AppFramework of the application
*/
void start(@NonNull Context context,
@NonNull Embrace.AppFramework appFramework);

/**
* Starts instrumentation of the Android application using the Embrace SDK. This should be
* called during creation of the application, as early as possible.
Expand All @@ -36,7 +50,9 @@ interface EmbraceAndroidApi extends EmbraceApi {
* @param isDevMode if true, and the build type is debuggable, it
* sets the environment for all sessions to 'Development'.
*
* @deprecated Use {@link #start(Context)} instead.
*/
@Deprecated
void start(@NonNull Context context,
boolean isDevMode);

Expand All @@ -51,7 +67,11 @@ void start(@NonNull Context context,
* @param context an instance of context
* @param isDevMode if true, and the build type is debuggable, it
* sets the environment for all sessions to 'Development'.
* @param appFramework the AppFramework of the application
*
* @deprecated Use {@link #start(Context, Embrace.AppFramework)} instead.
*/
@Deprecated
void start(@NonNull Context context,
boolean isDevMode,
@NonNull Embrace.AppFramework appFramework);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,20 @@ final class EmbraceImpl {
* the Embrace SDK must be initialized after any other SDK.
*
* @param context an instance of context
* @param isDevMode if true, sets the environment for all sessions to 'Development',
* similar to using a build type with debuggable set to true.
* @param appFramework the AppFramework of the application
*
*/
void start(@NonNull Context context,
boolean isDevMode,
@NonNull Embrace.AppFramework appFramework) {
startInternal(context, isDevMode, appFramework, () -> null);
startInternal(context, appFramework, () -> null);
}

void startInternal(@NonNull Context context,
boolean isDevMode,
@NonNull Embrace.AppFramework appFramework,
@NonNull Function0<ConfigService> configServiceProvider) {
try {
Systrace.startSynchronous("sdk-start");
startImpl(context, isDevMode, appFramework, configServiceProvider);
startImpl(context, appFramework, configServiceProvider);
Systrace.endSynchronous();
} catch (Throwable t) {
internalEmbraceLogger.logError(
Expand All @@ -254,7 +252,6 @@ void startInternal(@NonNull Context context,
}

private void startImpl(@NonNull Context context,
boolean isDevMode,
@NonNull Embrace.AppFramework framework,
@NonNull Function0<ConfigService> configServiceProvider) {
if (application != null) {
Expand All @@ -271,7 +268,7 @@ private void startImpl(@NonNull Context context,

final long startTimeMs = sdkClock.now();
internalEmbraceLogger.logInfo("Starting SDK for framework " + framework.name());
moduleInitBootstrapper.init(context, isDevMode, framework, startTimeMs, customAppId, configServiceProvider);
moduleInitBootstrapper.init(context, framework, startTimeMs, customAppId, configServiceProvider);
Systrace.startSynchronous("post-services-setup");
telemetryService = moduleInitBootstrapper.getInitModule().getTelemetryService();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ internal class SdkEndpointBehavior(
companion object {
const val CONFIG_DEFAULT = "config.emb-api.com"
const val DATA_DEFAULT = "data.emb-api.com"
const val DATA_DEV_DEFAULT = "data-dev.emb-api.com"
}

/**
* Data base URL.
*/
fun getData(appId: String): String = local?.data ?: "https://a-$appId.$DATA_DEFAULT"

/**
* Data dev base URL.
*/
fun getDataDev(): String = local?.dataDev ?: "https://$DATA_DEV_DEFAULT"

/**
* Config base URL.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ internal class BaseUrlLocalConfig(
@Json(name = "data")
val data: String? = null,

@Json(name = "data_dev")
val dataDev: String? = null,

@Json(name = "images")
val images: String? = null
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.embrace.android.embracesdk.injection

import android.os.Debug
import io.embrace.android.embracesdk.arch.destination.LogWriter
import io.embrace.android.embracesdk.arch.destination.LogWriterImpl
import io.embrace.android.embracesdk.capture.connectivity.EmbraceNetworkConnectivityService
Expand Down Expand Up @@ -84,7 +83,6 @@ internal class EssentialServiceModuleImpl(
androidServicesModule: AndroidServicesModule,
storageModule: StorageModule,
customAppId: String?,
isDevMode: Boolean,
dataSourceModuleProvider: Provider<DataSourceModule>,
private val configServiceProvider: Provider<ConfigService?> = { null }
) : EssentialServiceModule {
Expand Down Expand Up @@ -229,16 +227,7 @@ internal class EssentialServiceModuleImpl(
localSupplier = localConfig.sdkConfig::baseUrls,
)

val isDebug = coreModule.isDebug &&
isDevMode &&
(Debug.isDebuggerConnected() || Debug.waitingForDebugger())

val coreBaseUrl = if (isDebug) {
sdkEndpointBehavior.getDataDev()
} else {
sdkEndpointBehavior.getData(appId)
}

val coreBaseUrl = sdkEndpointBehavior.getData(appId)
val configBaseUrl = sdkEndpointBehavior.getConfig(appId)

EmbraceApiUrlBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ internal class ModuleInitBootstrapper(
@JvmOverloads
fun init(
context: Context,
isDevMode: Boolean,
appFramework: AppFramework,
sdkStartTimeMs: Long,
customAppId: String? = null,
Expand Down Expand Up @@ -188,7 +187,6 @@ internal class ModuleInitBootstrapper(
androidServicesModule,
storageModule,
customAppId,
isDevMode,
{ dataSourceModule },
configServiceProvider
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ internal typealias EssentialServiceModuleSupplier = (
androidServicesModule: AndroidServicesModule,
storageModule: StorageModule,
customAppId: String?,
isDevMode: Boolean,
dataSourceModuleProvider: Provider<DataSourceModule>,
configServiceProvider: Provider<ConfigService?>
) -> EssentialServiceModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ internal class EssentialServiceModuleImplTest {
storageModule = FakeStorageModule(),
customAppId = "abcde",
dataSourceModuleProvider = { fakeDataSourceModule() },
isDevMode = false,
) { null }

assertTrue(module.memoryCleanerService is EmbraceMemoryCleanerService)
Expand Down Expand Up @@ -89,7 +88,6 @@ internal class EssentialServiceModuleImplTest {
storageModule = FakeStorageModule(),
customAppId = null,
dataSourceModuleProvider = { fakeDataSourceModule() },
isDevMode = false,
) { fakeConfigService }

assertSame(fakeConfigService, module.configService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ internal class LocalConfigTest {
logger
)
assertEquals(localConfig.sdkConfig.baseUrls?.data, "custom_data")
localConfig = LocalConfigParser.buildConfig(
"GrCPU",
false,
"{\"base_urls\": {\"data_dev\": \"custom_data_dev\"}}",
serializer,
logger
)
assertEquals(
localConfig.sdkConfig.baseUrls?.dataDev,
"custom_data_dev"
)
localConfig = LocalConfigParser.buildConfig(
"GrCPU",
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ internal class SdkEndpointBehaviorTest {
private val local = BaseUrlLocalConfig(
"https://config.example.com",
"https://data.example.com",
"https://data-dev.example.com",
"https://images.example.com"
)

Expand All @@ -19,7 +18,6 @@ internal class SdkEndpointBehaviorTest {
with(fakeSdkEndpointBehavior()) {
assertEquals("https://a-12345.config.emb-api.com", getConfig("12345"))
assertEquals("https://a-12345.data.emb-api.com", getData("12345"))
assertEquals("https://data-dev.emb-api.com", getDataDev())
}
}

Expand All @@ -28,7 +26,6 @@ internal class SdkEndpointBehaviorTest {
with(fakeSdkEndpointBehavior(localCfg = { local })) {
assertEquals("https://config.example.com", getConfig("12345"))
assertEquals("https://data.example.com", getData("12345"))
assertEquals("https://data-dev.example.com", getDataDev())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal class BaseUrlLocalConfigTest {
val obj = deserializeJsonFromResource<BaseUrlLocalConfig>("base_url_config.json")
assertEquals("https://config.example.com", obj.config)
assertEquals("https://data.example.com", obj.data)
assertEquals("https://data-dev.example.com", obj.dataDev)
assertEquals("https://images.example.com", obj.images)
}

Expand All @@ -32,7 +31,6 @@ internal class BaseUrlLocalConfigTest {
private fun verifyDefaults(obj: BaseUrlLocalConfig) {
assertNull("https://config.emb-api.com", obj.config)
assertNull("https://data.emb-api.com", obj.data)
assertNull("https://data-dev.emb-api.com", obj.dataDev)
assertNull("https://images.emb-api.com", obj.images)
}
}

0 comments on commit cb2de51

Please sign in to comment.