Skip to content

Commit

Permalink
feat: in-app message revamp (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 authored Sep 11, 2024
1 parent a8af7da commit 682ac42
Show file tree
Hide file tree
Showing 50 changed files with 2,142 additions and 2,742 deletions.
4 changes: 2 additions & 2 deletions .github/actions/setup-android/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ runs:
using: "composite"
steps:
- name: Install Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
distribution: 'zulu'
java-version: '17'

- name: Install Android SDK
Expand Down
32 changes: 19 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,54 +36,60 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
# Add more samples here as they are added to the project.
matrix:
sample: [kotlin_compose, java_layout]
api-level: [31]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-android

# Cache Gradle dependencies to speed up the build process
- name: Gradle cache
uses: gradle/actions/setup-gradle@v4
continue-on-error: true
timeout-minutes: 5
with:
cache-overwrite-existing: true
gradle-home-cache-cleanup: true

# Enable KVM (Kernel-based Virtual Machine) for better performance by allowing hardware virtualization
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Cache Gradle dependencies to speed up the build process
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

# Cache the Android Virtual Device (AVD) to avoid recreating it each time
- name: AVD cache
uses: actions/cache@v3
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-31
restore-keys: |
avd-
key: avd-${{ matrix.api-level }}

# Create AVD and generate snapshot for caching if not already cached
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
api-level: ${{ matrix.api-level }}
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -grpc 8554 -verbose -timezone America/New_York
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 31
api-level: ${{ matrix.api-level }}
cores: 3
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -grpc 8554 -verbose -timezone America/New_York
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
ram-size: 4096M
target: google_apis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import kotlinx.coroutines.test.UnconfinedTestDispatcher
class ScopeProviderStub : ScopeProvider {
override val eventBusScope: CoroutineScope = TestScope(UnconfinedTestDispatcher())
override val lifecycleListenerScope: CoroutineScope = TestScope(UnconfinedTestDispatcher())
override val inAppLifecycleScope: CoroutineScope = TestScope(UnconfinedTestDispatcher())
}
2 changes: 2 additions & 0 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public abstract interface class io/customer/sdk/core/util/Logger {

public abstract interface class io/customer/sdk/core/util/ScopeProvider {
public abstract fun getEventBusScope ()Lkotlinx/coroutines/CoroutineScope;
public abstract fun getInAppLifecycleScope ()Lkotlinx/coroutines/CoroutineScope;
public abstract fun getLifecycleListenerScope ()Lkotlinx/coroutines/CoroutineScope;
}

Expand All @@ -239,6 +240,7 @@ public final class io/customer/sdk/core/util/SdkDispatchers : io/customer/sdk/co
public final class io/customer/sdk/core/util/SdkScopeProvider : io/customer/sdk/core/util/ScopeProvider {
public fun <init> (Lio/customer/sdk/core/util/DispatchersProvider;)V
public fun getEventBusScope ()Lkotlinx/coroutines/CoroutineScope;
public fun getInAppLifecycleScope ()Lkotlinx/coroutines/CoroutineScope;
public fun getLifecycleListenerScope ()Lkotlinx/coroutines/CoroutineScope;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import kotlinx.coroutines.SupervisorJob
interface ScopeProvider {
val eventBusScope: CoroutineScope
val lifecycleListenerScope: CoroutineScope
val inAppLifecycleScope: CoroutineScope
}

class SdkScopeProvider(private val dispatchers: DispatchersProvider) : ScopeProvider {
override val eventBusScope: CoroutineScope
get() = CoroutineScope(dispatchers.default + SupervisorJob())
override val lifecycleListenerScope: CoroutineScope
get() = CoroutineScope(dispatchers.default + SupervisorJob())
override val inAppLifecycleScope: CoroutineScope
get() = CoroutineScope(dispatchers.default + SupervisorJob())
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import androidx.core.content.edit
interface GlobalPreferenceStore {
fun saveDeviceToken(token: String)
fun getDeviceToken(): String?

fun removeDeviceToken()
fun clear(key: String)
fun clearAll()
}

Expand All @@ -30,6 +31,8 @@ internal class GlobalPreferenceStoreImpl(
getString(KEY_DEVICE_TOKEN, null)
}

override fun removeDeviceToken() = clear(KEY_DEVICE_TOKEN)

companion object {
private const val KEY_DEVICE_TOKEN = "device_token"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ abstract class PreferenceStore(val context: Context) {
open fun clearAll() {
prefs.edit().clear().apply()
}

/**
* Clear a specific preference stored in associated preference file asynchronously.
*/
open fun clear(key: String) {
prefs.edit().remove(key).apply()
}
}

/**
Expand Down
4 changes: 0 additions & 4 deletions datapipelines/api/datapipelines.api
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ public final class io/customer/datapipelines/plugins/StringExtensionsKt {
public static final fun getScreenNameFromActivity (Ljava/lang/String;)Ljava/lang/String;
}

public abstract interface class io/customer/datapipelines/plugins/TrackableScreen {
public abstract fun getScreenName ()Ljava/lang/String;
}

public final class io/customer/sdk/CustomerIO : io/customer/sdk/DataPipelineInstance, io/customer/sdk/core/module/CustomerIOModule {
public static final field Companion Lio/customer/sdk/CustomerIO$Companion;
public synthetic fun <init> (Lio/customer/sdk/core/di/AndroidSDKComponent;Lio/customer/datapipelines/config/DataPipelinesModuleConfig;Lcom/segment/analytics/kotlin/core/Analytics;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,7 @@ import com.segment.analytics.kotlin.core.Analytics
import com.segment.analytics.kotlin.core.platform.Plugin
import io.customer.sdk.core.di.SDKComponent
import io.customer.sdk.core.util.Logger

/**
* Optional interface for activities that should be tracked using automated screen tracking.
*/
interface TrackableScreen {
/**
* Retrieve the name that should be used for tracking the screen. This name
* should be unique for each screen.
*
* @return name for tracking the screen, or null if the screen shouldn't be tracked.
*/
fun getScreenName(): String?
}
import io.customer.sdk.tracking.TrackableScreen

/**
* Plugin that automatically tracks screens via ActivityLifecycleCallbacks `onActivityStarted` event of an activity.
Expand Down
Loading

0 comments on commit 682ac42

Please sign in to comment.