Skip to content

Commit

Permalink
Merge pull request #818 from embrace-io/lucas/improved_dev_mode
Browse files Browse the repository at this point in the history
Renamed `enableIntegrationTesting` param to `isDevMode` in `Embrace.start()`
  • Loading branch information
lucaslabari committed May 6, 2024
2 parents ed34242 + bfcd826 commit b44ff17
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 38 deletions.
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, enableIntegrationTesting, appFramework) { overriddenConfigService }
embraceImpl.startInternal(overriddenCoreModule.context, isDevMode, appFramework) { overriddenConfigService }
}
}
}
Expand All @@ -136,7 +136,7 @@ internal class IntegrationTestRule(
internal class Harness(
currentTimeMs: Long = DEFAULT_SDK_START_TIME_MS,
val startImmediately: Boolean = true,
val enableIntegrationTesting: Boolean = false,
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 @@ -75,16 +75,16 @@ public void start(@NonNull Context context) {
}

@Override
public void start(@NonNull Context context, boolean enableIntegrationTesting) {
public void start(@NonNull Context context, boolean isDevMode) {
if (verifyNonNullParameters("start", context)) {
start(context, enableIntegrationTesting, AppFramework.NATIVE);
start(context, isDevMode, AppFramework.NATIVE);
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ interface EmbraceAndroidApi extends EmbraceApi {
* the Embrace SDK must be initialized after any other SDK.
*
* @param context an instance of context
* @param enableIntegrationTesting if true, debug sessions (those which are not part of a
* release APK) will go to the live integration testing tab
* of the dashboard. If false, they will appear in 'recent
* sessions'.
* @param isDevMode if true, and the build type is debuggable, it
* sets the environment for all sessions to 'Development'.
*
*/
void start(@NonNull Context context,
boolean enableIntegrationTesting);
boolean isDevMode);

/**
* Starts instrumentation of the Android application using the Embrace SDK. This should be
Expand All @@ -50,13 +49,11 @@ void start(@NonNull Context context,
* the Embrace SDK must be initialized after any other SDK.
*
* @param context an instance of context
* @param enableIntegrationTesting if true, debug sessions (those which are not part of a
* release APK) will go to the live integration testing tab
* of the dashboard. If false, they will appear in 'recent
* sessions'.
* @param isDevMode if true, and the build type is debuggable, it
* sets the environment for all sessions to 'Development'.
*/
void start(@NonNull Context context,
boolean enableIntegrationTesting,
boolean isDevMode,
@NonNull Embrace.AppFramework appFramework);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,22 @@ final class EmbraceImpl {
* the Embrace SDK must be initialized after any other SDK.
*
* @param context an instance of context
* @param enableIntegrationTesting if true, debug sessions (those which are not part of a
* release APK) will go to the live integration testing tab
* of the dashboard. If false, they will appear in 'recent
* sessions'.
* @param isDevMode if true, sets the environment for all sessions to 'Development',
* similar to using a build type with debuggable set to true.
*/
void start(@NonNull Context context,
boolean enableIntegrationTesting,
boolean isDevMode,
@NonNull Embrace.AppFramework appFramework) {
startInternal(context, enableIntegrationTesting, appFramework, () -> null);
startInternal(context, isDevMode, appFramework, () -> null);
}

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

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

final long startTimeMs = sdkClock.now();
internalEmbraceLogger.logInfo("Starting SDK for framework " + framework.name());
moduleInitBootstrapper.init(context, enableIntegrationTesting, framework, startTimeMs, customAppId, configServiceProvider);
moduleInitBootstrapper.init(context, isDevMode, 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 @@ -84,7 +84,7 @@ internal class EssentialServiceModuleImpl(
androidServicesModule: AndroidServicesModule,
storageModule: StorageModule,
customAppId: String?,
enableIntegrationTesting: Boolean,
isDevMode: Boolean,
dataSourceModuleProvider: Provider<DataSourceModule>,
private val configServiceProvider: Provider<ConfigService?> = { null }
) : EssentialServiceModule {
Expand Down Expand Up @@ -230,7 +230,7 @@ internal class EssentialServiceModuleImpl(
)

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

val coreBaseUrl = if (isDebug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal class ModuleInitBootstrapper(
@JvmOverloads
fun init(
context: Context,
enableIntegrationTesting: Boolean,
isDevMode: Boolean,
appFramework: AppFramework,
sdkStartTimeMs: Long,
customAppId: String? = null,
Expand Down Expand Up @@ -188,7 +188,7 @@ internal class ModuleInitBootstrapper(
androidServicesModule,
storageModule,
customAppId,
enableIntegrationTesting,
isDevMode,
{ dataSourceModule },
configServiceProvider
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal typealias EssentialServiceModuleSupplier = (
androidServicesModule: AndroidServicesModule,
storageModule: StorageModule,
customAppId: String?,
enableIntegrationTesting: Boolean,
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,7 @@ internal class EssentialServiceModuleImplTest {
storageModule = FakeStorageModule(),
customAppId = "abcde",
dataSourceModuleProvider = { fakeDataSourceModule() },
enableIntegrationTesting = false,
isDevMode = false,
) { null }

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

assertSame(fakeConfigService, module.configService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal class ModuleInitBootstrapperTest {
assertTrue(
moduleInitBootstrapper.init(
context = context,
enableIntegrationTesting = false,
isDevMode = false,
appFramework = Embrace.AppFramework.NATIVE,
sdkStartTimeMs = 0L,
)
Expand All @@ -69,15 +69,15 @@ internal class ModuleInitBootstrapperTest {
assertTrue(
moduleInitBootstrapper.init(
context = context,
enableIntegrationTesting = false,
isDevMode = false,
appFramework = Embrace.AppFramework.NATIVE,
sdkStartTimeMs = 0L,
)
)
assertFalse(
moduleInitBootstrapper.init(
context = context,
enableIntegrationTesting = false,
isDevMode = false,
appFramework = Embrace.AppFramework.NATIVE,
sdkStartTimeMs = 0L,
)
Expand All @@ -89,7 +89,7 @@ internal class ModuleInitBootstrapperTest {
assertTrue(
moduleInitBootstrapper.init(
context = context,
enableIntegrationTesting = false,
isDevMode = false,
appFramework = Embrace.AppFramework.NATIVE,
sdkStartTimeMs = 0L,
)
Expand All @@ -114,7 +114,7 @@ internal class ModuleInitBootstrapperTest {
assertTrue(
bootstrapper.init(
context = context,
enableIntegrationTesting = false,
isDevMode = false,
appFramework = Embrace.AppFramework.NATIVE,
sdkStartTimeMs = 0L,
)
Expand Down

0 comments on commit b44ff17

Please sign in to comment.