diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/api/.gitignore @@ -0,0 +1 @@ +/build diff --git a/api/README.md b/api/README.md new file mode 100644 index 000000000..0a58d3927 --- /dev/null +++ b/api/README.md @@ -0,0 +1,6 @@ +# API module + +This module contains the public API interfaces and types exposed to consumers of the Split SDK. + +Classes in this module are part of the public API contract and should maintain backwards compatibility. + diff --git a/api/build.gradle b/api/build.gradle new file mode 100644 index 000000000..c32f26549 --- /dev/null +++ b/api/build.gradle @@ -0,0 +1,22 @@ +plugins { + id 'com.android.library' +} + +apply from: "$rootDir/gradle/common-android-library.gradle" + +android { + namespace 'io.split.android.client.api' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation libs.annotation + + testImplementation libs.junit4 + testImplementation libs.mockitoCore +} + diff --git a/api/consumer-rules.pro b/api/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/api/proguard-rules.pro b/api/proguard-rules.pro new file mode 100644 index 000000000..cf504086a --- /dev/null +++ b/api/proguard-rules.pro @@ -0,0 +1,22 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + diff --git a/api/src/androidTest/java/.gitkeep b/api/src/androidTest/java/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/api/src/main/AndroidManifest.xml b/api/src/main/AndroidManifest.xml new file mode 100644 index 000000000..cf2d636b6 --- /dev/null +++ b/api/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/api/src/main/java/io/split/android/client/api/EventMetadata.java b/api/src/main/java/io/split/android/client/api/EventMetadata.java new file mode 100644 index 000000000..e1648c388 --- /dev/null +++ b/api/src/main/java/io/split/android/client/api/EventMetadata.java @@ -0,0 +1,58 @@ +package io.split.android.client.api; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * Represents metadata associated with SDK events. + *

+ * Values are sanitized to only allow String, Number, Boolean, or List<String>. + */ +public interface EventMetadata { + + /** + * Returns the set of keys in this metadata. + * + * @return set of keys + */ + @NonNull + Set keys(); + + /** + * Returns the collection of values in this metadata. + * + * @return collection of values + */ + @NonNull + Collection values(); + + /** + * Returns the value associated with the given key. + * + * @param key the key to look up + * @return the value associated with the key, or null if not found + */ + @Nullable + Object get(@NonNull String key); + + /** + * Returns whether this metadata contains the given key. + * + * @param key the key to check + * @return true if the key exists, false otherwise + */ + boolean containsKey(@NonNull String key); + + /** + * Returns a copy of the underlying data as a Map. + * + * @return a copy of the metadata map + */ + @NonNull + Map toMap(); +} + diff --git a/api/src/test/java/io/split/android/client/api/.gitkeep b/api/src/test/java/io/split/android/client/api/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/build.gradle b/build.gradle index cf29b1342..9e7652e16 100644 --- a/build.gradle +++ b/build.gradle @@ -141,6 +141,8 @@ dependencies { include project(':main') include project(':logger') include project(':events') + include project(':events-domain') + include project(':api') } def splitPOM = { diff --git a/events-domain/.gitignore b/events-domain/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/events-domain/.gitignore @@ -0,0 +1 @@ +/build diff --git a/events-domain/README.md b/events-domain/README.md new file mode 100644 index 000000000..518ad3f6d --- /dev/null +++ b/events-domain/README.md @@ -0,0 +1,3 @@ +# Events Domain module + +This module provides Split-specific events management implementation. diff --git a/events-domain/build.gradle b/events-domain/build.gradle new file mode 100644 index 000000000..d23b67ccc --- /dev/null +++ b/events-domain/build.gradle @@ -0,0 +1,24 @@ +plugins { + id 'com.android.library' +} + +apply from: "$rootDir/gradle/common-android-library.gradle" + +android { + namespace 'io.split.android.client.events' + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation libs.annotation + + implementation project(':api') + implementation project(':events') + + testImplementation libs.junit4 + testImplementation libs.mockitoCore +} diff --git a/events-domain/consumer-rules.pro b/events-domain/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/events-domain/proguard-rules.pro b/events-domain/proguard-rules.pro new file mode 100644 index 000000000..cf504086a --- /dev/null +++ b/events-domain/proguard-rules.pro @@ -0,0 +1,22 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + diff --git a/events-domain/src/androidTest/java/.gitkeep b/events-domain/src/androidTest/java/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/events-domain/src/main/AndroidManifest.xml b/events-domain/src/main/AndroidManifest.xml new file mode 100644 index 000000000..cf2d636b6 --- /dev/null +++ b/events-domain/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/events-domain/src/main/java/io/split/android/client/events/.gitkeep b/events-domain/src/main/java/io/split/android/client/events/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/events-domain/src/test/java/io/split/android/client/events/.gitkeep b/events-domain/src/test/java/io/split/android/client/events/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/main/build.gradle b/main/build.gradle index 241ba786e..dba2405f2 100644 --- a/main/build.gradle +++ b/main/build.gradle @@ -49,9 +49,11 @@ android { } dependencies { - // Internal module dependencies + // Public api modules api project(':logger') - implementation project(':events') + api project(':api') + // Internal module dependencies + implementation project(':events-domain') // External dependencies implementation libs.roomRuntime diff --git a/settings.gradle b/settings.gradle index 246c9b203..b584365a6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,7 @@ rootProject.name = 'android-client' +include ':api' include ':logger' include ':main' include ':events' +include ':events-domain'