Skip to content

Commit 9ef33f0

Browse files
authored
Bump CT SDK version to fix logger and UTM Visited (#516)
1 parent 7750a87 commit 9ef33f0

File tree

6 files changed

+31
-26
lines changed

6 files changed

+31
-26
lines changed

AndroidSDKCore/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies {
4242
api "androidx.legacy:legacy-support-v4:1.0.0"
4343
api "androidx.appcompat:appcompat:${APPCOMPAT_LIBRARY_VERSION}"
4444

45-
api "com.clevertap.android:clevertap-android-sdk:4.6.3"
45+
api "com.clevertap.android:clevertap-android-sdk:4.6.4"
4646
}
4747

4848
task generateJavadoc(type: Javadoc) {

AndroidSDKCore/src/main/java/com/leanplum/internal/Log.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public static void setLogLevel(int level) {
4646
Log.level = level;
4747
}
4848

49+
public static int getLogLevel() {
50+
return level;
51+
}
52+
4953
public static void e(String msg, Object... args) {
5054
log(LogType.ERROR, msg, args);
5155
}
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.leanplum.migration
22

3+
import com.clevertap.android.sdk.CleverTapAPI
4+
import com.leanplum.internal.Log
5+
36
object MigrationConstants {
47
const val IDENTITY = "Identity"
58
const val STATE_PREFIX = "state_"
6-
const val UTM_VISITED = "UTM Visited"
79

810
const val CHARGED_EVENT_PARAM = "event"
911
const val VALUE_PARAM = "value"
@@ -12,4 +14,12 @@ object MigrationConstants {
1214
const val GP_PURCHASE_DATA_PARAM = "googlePlayPurchaseData"
1315
const val GP_PURCHASE_DATA_SIGNATURE_PARAM = "googlePlayPurchaseDataSignature"
1416
const val IAP_ITEM_PARAM = "item"
17+
18+
fun mapLogLevel(lpLevel: Int): CleverTapAPI.LogLevel = when (lpLevel) {
19+
Log.Level.OFF -> CleverTapAPI.LogLevel.OFF
20+
Log.Level.ERROR -> CleverTapAPI.LogLevel.INFO
21+
Log.Level.INFO -> CleverTapAPI.LogLevel.INFO
22+
Log.Level.DEBUG -> CleverTapAPI.LogLevel.VERBOSE
23+
else -> CleverTapAPI.LogLevel.INFO
24+
}
1525
}

AndroidSDKCore/src/main/java/com/leanplum/migration/wrapper/CTWrapper.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ internal class CTWrapper(
3333
override fun launch(context: Context, callback: CleverTapInstanceCallback?) {
3434
instanceCallback = callback
3535

36+
val lpLevel = Log.getLogLevel()
37+
val ctLevel = MigrationConstants.mapLogLevel(lpLevel).intValue()
38+
3639
val config = CleverTapInstanceConfig.createInstance(
3740
context,
3841
accountId,
3942
accountToken,
4043
accountRegion).apply {
4144
enableCustomCleverTapId = true
45+
debugLevel = ctLevel // set instance log level
46+
setLogLevel(lpLevel) // set static log level, arg needs to be Leanplum's level
4247
}
4348

4449
val cleverTapId = identityManager.cleverTapId()
@@ -228,21 +233,12 @@ internal class CTWrapper(
228233
}
229234

230235
override fun setTrafficSourceInfo(info: Map<String, String>) {
231-
val event = MigrationConstants.UTM_VISITED
232-
val properties = info.mapKeys { (key, _) ->
233-
when (key) {
234-
"publisherId" -> "utm_source_id"
235-
"publisherName" -> "utm_source"
236-
"publisherSubPublisher" -> "utm_medium"
237-
"publisherSubSite" -> "utm_subscribe.site"
238-
"publisherSubCampaign" -> "utm_campaign"
239-
"publisherSubAdGroup" -> "utm_sourcepublisher.ad_group"
240-
"publisherSubAd" -> "utm_SourcePublisher.ad"
241-
else -> key
242-
}
243-
}
244-
Log.d("Wrapper: Leanplum.setTrafficSourceInfo will call pushEvent with $event and $properties")
245-
cleverTapInstance?.pushEvent(event, properties)
236+
val source = info["publisherName"]
237+
val medium = info["publisherSubPublisher"]
238+
val campaign = info["publisherSubCampaign"]
239+
Log.d("Wrapper: Leanplum.setTrafficSourceInfo will call pushInstallReferrer with " +
240+
"$source, $medium, and $campaign")
241+
cleverTapInstance?.pushInstallReferrer(source, medium, campaign)
246242
}
247243

248244
}

AndroidSDKCore/src/main/java/com/leanplum/migration/wrapper/IWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ interface IWrapper {
5353

5454
fun registerLifecycleCallback(app: Application) = Unit
5555

56-
fun setLogLevel(level: Int) = Unit
56+
fun setLogLevel(lpLevel: Int) = Unit
5757

5858
}

AndroidSDKCore/src/main/java/com/leanplum/migration/wrapper/StaticMethodsWrapper.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.app.Application
44
import com.clevertap.android.sdk.ActivityLifecycleCallback
55
import com.clevertap.android.sdk.CleverTapAPI
66
import com.leanplum.internal.Log
7+
import com.leanplum.migration.MigrationConstants
78

89
/**
910
* Singleton wrapping the static utility methods of CT SDK, used as a delegate from [CTWrapper].
@@ -17,14 +18,8 @@ object StaticMethodsWrapper : IWrapper {
1718
ActivityLifecycleCallback.register(app)
1819
}
1920

20-
override fun setLogLevel(level: Int) {
21-
when(level) {
22-
Log.Level.OFF -> CleverTapAPI.setDebugLevel(CleverTapAPI.LogLevel.OFF)
23-
Log.Level.ERROR -> CleverTapAPI.setDebugLevel(CleverTapAPI.LogLevel.INFO)
24-
Log.Level.INFO -> CleverTapAPI.setDebugLevel(CleverTapAPI.LogLevel.INFO)
25-
Log.Level.DEBUG -> CleverTapAPI.setDebugLevel(CleverTapAPI.LogLevel.VERBOSE)
26-
else -> Unit
27-
}
21+
override fun setLogLevel(lpLevel: Int) {
22+
CleverTapAPI.setDebugLevel(MigrationConstants.mapLogLevel(lpLevel))
2823
}
2924

3025
}

0 commit comments

Comments
 (0)