Skip to content

Commit 67eb95b

Browse files
authored
Fix impression for embedded actions (#507)
* Fix impression for embedded actions Bellow commits are fixing several Travis build issues: * Trigger Build * Debug failing build * Debug build * Trying to fix build * Try temporary fix for the build * Print debug log * Try fix build * Fix unit tests because of robolectric network issues * Try fix travis * List all jdks * Pick open jdk * Shorten logs * Print logs * Add m2 caching * Remove detailed logs * Enable all tests * Clear travis debug
1 parent ab75aa5 commit 67eb95b

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

.travis.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,27 @@ android:
2121
components:
2222
- tools
2323

24-
jdk:
25-
- oraclejdk11
24+
# Uncomment and remove lines in before_install when issue with JDK is resolved
25+
# Check thread here: https://travis-ci.community/t/installing-oraclejdk-11-failed/13050/10
26+
# jdk:
27+
# - oraclejdk11
2628

2729
licenses:
2830
- 'android-sdk-preview-license-.+'
2931
- 'android-sdk-license-.+'
3032
- 'google-gdk-license-.+'
3133

34+
cache:
35+
directories:
36+
# cache is used for the Robolectric dependencies that are frequently failing to download
37+
- .autoconf
38+
- $HOME/.m2
39+
3240
before_install:
41+
- curl -s "https://get.sdkman.io" | bash
42+
- source "$HOME/.sdkman/bin/sdkman-init.sh"
43+
- sdk install java 11.0.12-open
44+
- sdk use java 11.0.12-open
3345
# Install cmdline-tools (older tools doesn't support Java 11)
3446
- wget -q "https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip" -O android-commandline-tools-linux.zip
3547
- mkdir -p ${ANDROID_HOME}/cmdline-tools

AndroidSDKCore/src/main/java/com/leanplum/actions/internal/ActionManagerExecution.kt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,28 @@ private fun ActionManager.performActionsImpl() {
197197
private fun ActionManager.recordImpression(action: Action) {
198198
try {
199199
val ctx = action.context
200-
if (action.actionType == Action.ActionType.CHAINED) {
201-
// We do not want to count occurrences for action kind, because in multi message
202-
// campaigns the Open URL action is not a message. Also if the user has defined
203-
// actions of type Action we do not want to count them.
204-
val actionKind = definitions.findDefinition(ctx.actionName())?.kind
205-
if (actionKind == Leanplum.ACTION_KIND_ACTION) {
206-
recordChainedActionImpression(ctx.messageId)
207-
} else {
200+
when (action.actionType) {
201+
202+
Action.ActionType.CHAINED -> {
203+
// We do not want to count occurrences for action kind, because in multi message
204+
// campaigns the Open URL action is not a message. Also if the user has defined
205+
// actions of type Action we do not want to count them.
206+
207+
val actionKind = definitions.findDefinition(ctx.actionName())?.kind
208+
if (actionKind == Leanplum.ACTION_KIND_ACTION) {
209+
recordChainedActionImpression(ctx.messageId)
210+
} else {
211+
recordMessageImpression(ctx.messageId)
212+
}
213+
}
214+
215+
Action.ActionType.SINGLE -> {
208216
recordMessageImpression(ctx.messageId)
209217
}
210218

211-
} else {
212-
recordMessageImpression(action.context.messageId)
219+
Action.ActionType.EMBEDDED -> {
220+
// do nothing
221+
}
213222
}
214223
} catch (t: Throwable) {
215224
Log.exception(t)

AndroidSDKTests/src/test/java/com/leanplum/LeanplumInboxMessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* @author Sayaan Saha
4747
*/
4848
@RunWith(RobolectricTestRunner.class)
49-
@Config(sdk = VERSION_CODES.P) // temporarily fix issue with Robolectric and Android SDK 29
49+
@Config(sdk = 16)
5050
public class LeanplumInboxMessageTest {
5151

5252
private LeanplumInboxMessage createMessageTestData(

AndroidSDKTests/src/test/java/com/leanplum/internal/JsonConverterTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
import com.leanplum.__setup.LeanplumTestApp;
2424

25+
import org.json.JSONException;
26+
import org.json.JSONObject;
2527
import org.junit.Test;
2628
import org.junit.runner.RunWith;
2729
import org.powermock.core.classloader.annotations.PowerMockIgnore;
@@ -42,7 +44,7 @@
4244
@SuppressWarnings("unused")
4345
@RunWith(RobolectricTestRunner.class)
4446
@Config(
45-
sdk = 21,
47+
sdk = 16,
4648
application = LeanplumTestApp.class
4749
)
4850
@PowerMockIgnore({
@@ -70,9 +72,9 @@ public class JsonConverterTest {
7072
"\"map\":{\"a\":1,\"b\":2,\"array\":[1,2,3]},\"array\":[1,\"string\",{\"a\":\"b\"}]}";
7173

7274
@Test
73-
public void testToJson() {
75+
public void testToJson() throws JSONException {
7476
assertNull(JsonConverter.toJson(null));
75-
assertEquals(json, JsonConverter.toJson(map));
77+
assertEquals(new JSONObject(json).toString(), JsonConverter.toJson(map));
7678
}
7779

7880
@Test

0 commit comments

Comments
 (0)