Skip to content

Commit

Permalink
Release features-0.2.0 (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: rahul27 <[email protected]>
  • Loading branch information
moonsense-ci and rahul27 authored Jan 30, 2023
1 parent 19f595b commit 268ac36
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The SDK reference can be found at [android.sdk-docs.moonsense.io](https://androi
This repo includes three sample apps:

- `sample-app` - This sample app demonstrates the use of the Moonsense Android SDK within an application context. The example in this case is quite simple and minimal and can serve as a good starting point for developers looking for a quick integration.
- `sample-payment-app` - This sample app demonstrates the library usage of the Moonsense Android SDK. Note that the `sample-payment-app` does not directly depend on the Moonsense Android SDK. Instead it includes a dependency to the `sample-payment-sdk` which then packages the Moonsense Android SDK. The app developer here does not have any visibility into the Moonsense Android SDK as they only interface with the `sample-payment-sdk`. The example is useful for SDK/library developers looking to integrate the Moonsense Android SDK. This sample app comes in two variants, the features variant records a session with the [Features SDK](https://docs.moonsense.io/articles/sdk/feature-generation) and the standard variant does not.
- `sample-payment-app` - This sample app demonstrates the library usage of the Moonsense Android SDK. Note that the `sample-payment-app` does not directly depend on the Moonsense Android SDK. Instead it includes a dependency to the `sample-payment-sdk` which then packages the Moonsense Android SDK. The app developer here does not have any visibility into the Moonsense Android SDK as they only interface with the `sample-payment-sdk`. The example is useful for SDK/library developers looking to integrate the Moonsense Android SDK. This sample app comes in two variants, the features variant records a session with the [Features SDK](https://docs.moonsense.io/articles/sdk/feature-generation) and [Network Telemetry](https://docs.moonsense.io/articles/network-telemetry/getting-started) configuration while the standard variant does not.
- `sample-core-app` - This sample app shows how to integrate a variation of the Moonsense Android SDK called the Core SDK. For all intents and purposes the standard Android SDK (referred to as the Cloud SDK) should suffice for a majority of use cases. In case you do need specialized use of the Moonsense SDK contact [[email protected]](mailto:[email protected]) for access. Additional information regarding the Core SDK can be found here - [Advanced Usage](https://docs.moonsense.io/articles/sdk/advanced-usage).

## Terms Of Service
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ object Versions {
const val gson = "2.10.1"
const val mockWebServer = "4.10.0"
const val gradleVersionsPlugin = "0.44.0"
const val moonsenseFeatures = "0.1.1"
const val moonsenseFeatures = "0.2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.moonsense.sample.payment.sdk.generators

import io.moonsense.features.CompositeFeatureGenerator
import io.moonsense.features.DeviceMotionFeatureGenerator
import io.moonsense.features.PointerFeatureGenerator
import io.moonsense.features.operator.Operator
import io.moonsense.features.transform.FocusChangeTransform
import io.moonsense.models.v2.FocusChange
import io.moonsense.sdk.config.NetworkTelemetryConfig
import io.moonsense.sdk.config.SessionConfig
import io.moonsense.sdk.features.FeatureGenerator

/**
* Responsible for returning a [SessionConfig] with [FeatureGenerator]s
* and a [NetworkTelemetryConfig].
*/
internal object FeatureConfigFactory {

/**
* Return a session config with features generated by a set of
* configured [FeatureGenerator]s.
*
* Also enable ip based network telemetry data that captures
* network based features.
*/
fun getSessionConfig(): SessionConfig? = SessionConfig(
featureGenerators = listOf(
// generators for all device motion sensors
DeviceMotionFeatureGenerator(),
// generators for summarizing pointer data
PointerFeatureGenerator(),
// a composite generator that count the number of times an edit text gains focus
CompositeFeatureGenerator(
listOf(
FocusChangeTransform(
"focus_gained" to { focusChange ->
if (focusChange.type == FocusChange.Type.FOCUS_GAINED) {
1.0
} else {
null
}
}
)
),
Operator.COUNT
)
),
networkTelemetryConfig = NetworkTelemetryConfig(ip = true)
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit
import com.google.android.material.bottomsheet.BottomSheetBehavior

import android.widget.FrameLayout
import io.moonsense.sample.payment.sdk.generators.FeatureGeneratorFactory
import io.moonsense.sample.payment.sdk.generators.FeatureConfigFactory
import io.moonsense.sdk.config.SessionConfig
import java.lang.StringBuilder

Expand Down Expand Up @@ -164,14 +164,15 @@ class PaymentDialog(private val paymentListener: PaymentListener) :
listOf(PAYMENT_SDK_LABEL_ALL_SENSORS)
)

val featureGenerators = FeatureGeneratorFactory.getFeatureGenerators()
// if there are available feature generators then record a session with features
if (featureGenerators.isNotEmpty()) {
val sessionConfig = FeatureConfigFactory.getSessionConfig()
// if there is a session config available with feature generators then
// record a session with features
if (sessionConfig != null) {
// start a shorter session
sessionWithFeatures = Moonsense.startSession(
TimeUnit.SECONDS.toMillis(FEATURES_SESSION_DURATION_SECONDS),
// provide the requested generators
SessionConfig(featureGenerators = featureGenerators),
// provide the requested config
sessionConfig,
listOf(PAYMENT_SDK_LABEL_FEATURES)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.moonsense.sample.payment.sdk.generators

import io.moonsense.sdk.features.FeatureGenerator
import io.moonsense.sdk.config.NetworkTelemetryConfig
import io.moonsense.sdk.config.SessionConfig

/**
* Responsible for returning a [SessionConfig] with [FeatureGenerator]s
* and a [NetworkTelemetryConfig].
*/
internal object FeatureConfigFactory {

/**
* The standard version does not record features or report
* network telemetry data.
*/
@Suppress("FunctionOnlyReturningConstant")
fun getSessionConfig(): SessionConfig? = null
}

This file was deleted.

0 comments on commit 268ac36

Please sign in to comment.