[Android]Rework Optable API configuration and request forming#35
[Android]Rework Optable API configuration and request forming#35ValentinPostindustria wants to merge 41 commits intomasterfrom
Conversation
Remove `app` path parameter. Add `tenant` and `originSlug` parameters. Make host dynamic and apply path `v2`. Move all configuration parameters in Config class and reuse it everywhere. Separate `GoogleAdIdManager` and `LocalStorage` logic from the network client. Rename `Client` to `NetworkClient`. Move hash logic to separate `TypeHasher` class. Separate network interceptors. Refactor SDK code.
Support secret api keys. Fetch user agent only once. Write unit tests with the mock web server.
android_sdk/src/main/java/co/optable/android_sdk/core/UserAgentHolder.kt
Show resolved
Hide resolved
Remove custom network Adapter. Use native Retrofit adapter. Add Kotlin suspension.
Migrate from TypeHasher to IdentifiersEncoder. Add all identifier types. Cover with unit tests.
Use callbacks API. Rewrite demo apps to make the examples more readable. Use shorter logs. Create Optable SDK instance once during application creation and reuse everywhere. Move fragments to one folder.
Add missed "reg" query param. Make Consents mutable. Provide `receiveGaidAutomatically` property. Refactor main methods javadoc.
DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/TheApplication.java
Outdated
Show resolved
Hide resolved
DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/GamBannerFragment.java
Show resolved
Hide resolved
DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/PrebidBannerFragment.java
Outdated
Show resolved
Hide resolved
DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GamBannerFragment.kt
Show resolved
Hide resolved
android_sdk/src/main/java/co/optable/android_sdk/core/IdentifiersEncoder.kt
Outdated
Show resolved
Hide resolved
android_sdk/src/main/java/co/optable/android_sdk/core/IdentifiersEncoder.kt
Outdated
Show resolved
Hide resolved
android_sdk/src/main/java/co/optable/android_sdk/core/IdentifiersEncoder.kt
Outdated
Show resolved
Hide resolved
android_sdk/src/main/java/co/optable/android_sdk/OptableIdentifiers.kt
Outdated
Show resolved
Hide resolved
android_sdk/src/test/java/co/optable/android_sdk/OptableIdentifiersTest.kt
Outdated
Show resolved
Hide resolved
android_sdk/src/main/java/co/optable/android_sdk/core/network/NetworkClient.kt
Outdated
Show resolved
Hide resolved
Change public API to accept list of OptableIdentifier. Rewrite encoder. Restore unit tests.
| * @param id The identifier that traits and neighbors will be linked to. This value takes precedence over the passport if provided. | ||
| * @param neighbors An array of identifiers to link to the id or passport | ||
| */ | ||
| data class OptableTraits @JvmOverloads constructor ( |
There was a problem hiding this comment.
This class encapsulates parameters to the profile API call, perhaps it makes sense to name it OptableProfileParams. Ideally we should make this class private and make the public profile API take traits,id, neighbors as raw parameters, not nested inside the object. This will be consistent with iOS impelmentation. Internally these params can be set into this object and it can be passed to other internal calls, just not exposed to the public via facade API.
|
|
||
| MainScope().launch { | ||
| adId = adInfo?.id | ||
| limitAdTracking = adInfo?.isLimitAdTrackingEnabled |
There was a problem hiding this comment.
We don't seem to use this anywhere. I'm not sure we should set the adId in IdentifiersEncoder if isLimitAdTrackingEnabled as it would lead to "00000000-0000-0000-0000-000000000000" identifier being sent.
| val uri = urlString.lowercase(Locale.ROOT).toUri() | ||
| val id = uri.getQueryParameter("oeid") | ||
|
|
||
| val wrongId = (id == null) || (id.length != 64) || (id.matches("^[a-f0-9]$".toRegex())) |
There was a problem hiding this comment.
This regex matches exactly a single char. Likely miss + quantifier
|
|
||
| ```kotlin | ||
| MainActivity.OPTABLE = OptableSDK(this, "dcn.customer.com", "my-app", false, "custom-ua") | ||
| val ids = OptableIdentifiers( |
There was a problem hiding this comment.
This no longer exists, the README need to be revisited to match the API change
| private fun applyOptableToGam(builder: AdManagerAdRequest.Builder, targeting: OptableTargeting?) { | ||
| if (targeting == null) return | ||
|
|
||
| val audiences = targeting.audiences |
| GlobalScope.launch { | ||
| var adInfo: AdvertisingIdClient.Info? = null | ||
| try { | ||
| adInfo = AdvertisingIdClient.getAdvertisingIdInfo(config.context) |
There was a problem hiding this comment.
Is this async? Can this race with the first identify() call?
| * of the API response object. On error, the response `message` string provides a description | ||
| * of the error and related debug information. | ||
| */ | ||
| data class OptableResponse<out T>(val status: Status, val data: T?, val message: String?) { |
There was a problem hiding this comment.
This class is not being used anywhere but tests





Closes #33.
Breaking changes:
apppath parameter.tenantandoriginSlugquery parameters.v2.Other features:
apiKey.Configclass and reuse it everywhere.GoogleAdIdManagerandLocalStoragelogic from the network client.ClienttoNetworkClient.TypeHasherclass.