Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EMBR-631] Make ApiUrlBuilder independent from ConfigService. #10

Merged
merged 22 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aaa8fc0
[EMBR-631] Make ApiUrlBuilder independent from ConfigService.
lucaslabari Oct 18, 2023
389abb9
Revert "[EMBR-631] Make ApiUrlBuilder independent from ConfigService."
lucaslabari Oct 27, 2023
e8c06c1
Merge branch 'master' into lucas/EMBR-631
lucaslabari Oct 27, 2023
2c58825
[EMBR-631] Break circular dependencies within EssentialServiceModule.
lucaslabari Oct 27, 2023
25ee1bc
Merge branch 'master' into lucas/EMBR-631
lucaslabari Oct 27, 2023
79225b4
Merge branch 'master' into lucas/EMBR-631
lucaslabari Oct 30, 2023
ae14578
[EMBR-631] Use deviceId from preferenceService in test.
lucaslabari Oct 30, 2023
dd9969b
[EMBR-631] Create FakeApiUrlBuilder
lucaslabari Oct 30, 2023
bf2d0c5
[EMBR-631] Avoid init in FakeCoreModule
lucaslabari Oct 30, 2023
f6875be
[EMBR-631] Rename lazy properties.
lucaslabari Oct 30, 2023
26d1fb3
[EMBR-631] Remove lazy from appId as it's already resolved.
lucaslabari Oct 30, 2023
13973df
[EMBR-631] Remove condition that inits EmbraceNetworkConnectivityServ…
lucaslabari Oct 30, 2023
2a50e6b
Merge branch 'master' into lucas/EMBR-631
lucaslabari Oct 31, 2023
ea6650f
Merge branch 'master' into lucas/EMBR-631
lucaslabari Oct 31, 2023
9e03f8e
[EMBR-631] Fix Unit tests.
lucaslabari Oct 31, 2023
557f2e0
[EMBR-631] Move SdkEndpointBehavior to EssentialServiceModule
lucaslabari Oct 31, 2023
1fe6a7f
[EMBR-631] Move appVersionName and appVersionCode to EssentialService…
lucaslabari Oct 31, 2023
2692a85
[EMBR-631] Remove comma.
lucaslabari Nov 1, 2023
2b7c81a
[EMBR-631] Add comment.
lucaslabari Nov 1, 2023
fb07da8
[EMBR-631] Update logic that handles network status changes.
lucaslabari Nov 1, 2023
7427bfa
[EMBR-631] Update logic that handles network status changes.
lucaslabari Nov 1, 2023
6764ab3
Merge branch 'master' into lucas/EMBR-631
lucaslabari Nov 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[EMBR-631] Rename lazy properties.
  • Loading branch information
lucaslabari committed Oct 30, 2023
commit f6875be80a10e6c9c5fb0b3adef459206c3da64e
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
private val scheduledExecutorService: ScheduledExecutorService,
networkConnectivityService: NetworkConnectivityService,
private val cacheManager: DeliveryCacheManager,
private val deviceId: Lazy<String>,
private val appId: Lazy<String>
private val lazyDeviceId: Lazy<String>,
private val lazyAppId: Lazy<String>
) : ApiService, NetworkConnectivityListener {

private val retryQueue: DeliveryFailedApiCalls by lazy { cacheManager.loadFailedApiCalls() }
Expand Down Expand Up @@ -178,14 +178,14 @@
)
}
val request: ApiRequest = eventBuilder(url).copy(
deviceId = deviceId.value,
appId = appId.value,
deviceId = lazyDeviceId.value,
appId = lazyAppId.value,

Check warning on line 182 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt#L181-L182

Added lines #L181 - L182 were not covered by tests
url = url,
httpMethod = HttpMethod.POST,
contentEncoding = "gzip"
)

postAEIBlob(blobMessage, request)

Check warning on line 188 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiService.kt#L188

Added line #L188 was not covered by tests
}

/**
Expand Down Expand Up @@ -253,8 +253,8 @@
)
}
val request: ApiRequest = eventBuilder(url).copy(
deviceId = deviceId.value,
appId = appId.value,
deviceId = lazyDeviceId.value,
appId = lazyAppId.value,
url = url,
httpMethod = HttpMethod.POST,
contentEncoding = "gzip"
Expand Down Expand Up @@ -378,8 +378,8 @@
return ApiRequest(
url = url,
httpMethod = HttpMethod.POST,
appId = appId.value,
deviceId = deviceId.value,
appId = lazyAppId.value,
deviceId = lazyDeviceId.value,
contentEncoding = "gzip"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
private val enableIntegrationTesting: Boolean,
private val isDebug: Boolean,
private val sdkEndpointBehavior: SdkEndpointBehavior,
private val appId: Lazy<String>,
private val deviceId: Lazy<String>,
private val lazyAppId: Lazy<String>,
private val lazyDeviceId: Lazy<String>,
context: Context,
) : ApiUrlBuilder {
companion object {
Expand All @@ -25,19 +25,19 @@
val packageInfo = packageManager.getPackageInfo(context.packageName, 0)
val versionName = packageInfo.versionName.toString().trim { it <= ' ' }
versionName
} catch (e: PackageManager.NameNotFoundException) {
"UNKNOWN"

Check warning on line 29 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiUrlBuilder.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiUrlBuilder.kt#L28-L29

Added lines #L28 - L29 were not covered by tests
}

private fun getConfigBaseUrl() =
buildUrl(sdkEndpointBehavior.getConfig(appId.value), CONFIG_API_VERSION, "config")
buildUrl(sdkEndpointBehavior.getConfig(lazyAppId.value), CONFIG_API_VERSION, "config")

private fun getOperatingSystemCode() = Build.VERSION.SDK_INT.toString() + ".0.0"

private fun getCoreBaseUrl(): String = if (isDebugBuild()) {
sdkEndpointBehavior.getDataDev(appId.value)
sdkEndpointBehavior.getDataDev(lazyAppId.value)

Check warning on line 38 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiUrlBuilder.kt

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/comms/api/EmbraceApiUrlBuilder.kt#L38

Added line #L38 was not covered by tests
} else {
sdkEndpointBehavior.getData(appId.value)
sdkEndpointBehavior.getData(lazyAppId.value)
}

private fun isDebugBuild(): Boolean {
Expand All @@ -49,8 +49,8 @@
}

override fun getConfigUrl(): String {
return "${getConfigBaseUrl()}?appId=${appId.value}&osVersion=${getOperatingSystemCode()}" +
"&appVersion=$appVersionName&deviceId=${deviceId.value}"
return "${getConfigBaseUrl()}?appId=${lazyAppId.value}&osVersion=${getOperatingSystemCode()}" +
"&appVersion=$appVersionName&deviceId=${lazyDeviceId.value}"
}

override fun getEmbraceUrlWithSuffix(suffix: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ internal class EssentialServiceModuleImpl(
coreModule.jsonSerializer
)

private val appId = lazy { localConfig.appId }
private val lazyAppId = lazy { localConfig.appId }

private val deviceId = lazy(androidServicesModule.preferencesService::deviceIdentifier)
private val lazyDeviceId = lazy(androidServicesModule.preferencesService::deviceIdentifier)

private val thresholdCheck: BehaviorThresholdCheck =
BehaviorThresholdCheck(androidServicesModule.preferencesService::deviceIdentifier)
lucaslabari marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -168,8 +168,8 @@ internal class EssentialServiceModuleImpl(
enableIntegrationTesting = enableIntegrationTesting,
isDebug = coreModule.isDebug,
sdkEndpointBehavior = sdkEndpointBehavior,
appId = appId,
deviceId = deviceId,
lazyAppId = lazyAppId,
lazyDeviceId = lazyDeviceId,
context = coreModule.context,
)
}
Expand Down Expand Up @@ -235,8 +235,8 @@ internal class EssentialServiceModuleImpl(
apiRetryExecutor,
networkConnectivityService,
deliveryCacheManager,
deviceId,
appId
lazyDeviceId,
lazyAppId
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ internal class EmbraceApiUrlBuilderTest {
enableIntegrationTesting = false,
isDebug = false,
sdkEndpointBehavior = fakeSdkEndpointBehavior(localCfg = { BaseUrlLocalConfig() }),
appId = lazy { APP_ID },
deviceId = lazy { preferenceService.deviceIdentifier },
lazyAppId = lazy { APP_ID },
lazyDeviceId = lazy { preferenceService.deviceIdentifier },
context = context,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ internal class EmbraceApiServiceTest {
scheduledExecutorService = testScheduledExecutor,
networkConnectivityService = networkConnectivityService,
cacheManager = mockCacheManager,
deviceId = lazy { "07D85B44E4E245F4A30E559BFC0D07FF" },
appId = lazy { "o0o0o" },
lazyDeviceId = lazy { "07D85B44E4E245F4A30E559BFC0D07FF" },
lazyAppId = lazy { "o0o0o" },
)

failedApiCalls.clear()
Expand Down
Loading