Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal/Attempt to remove library desugaring #675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions snowplow-demo-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ android {
}

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand All @@ -52,6 +51,4 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.google.code.gson:gson:2.9.0'

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.9'
}
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ private boolean setupWithLocalConfig() {
gcConfiguration.add("ruleSetExampleTag", new GlobalContext(Collections.singletonList(new SelfDescribingJson(SCHEMA_IDENTIFY, pairs))));

PluginConfiguration plugin = new PluginConfiguration("myPlugin");
plugin.afterTrack(null, event -> System.out.printf("Tracked event with %d entities%n", event.getEntities().size()));
plugin.afterTrack(null, (event) -> {
System.out.printf("Tracked event with %d entities%n", event.getEntities().size());
return null;
});

Snowplow.createTracker(getApplicationContext(),
namespace,
Expand Down
4 changes: 0 additions & 4 deletions snowplow-tracker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ android {
}

compileOptions {
coreLibraryDesugaringEnabled true

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand All @@ -92,8 +90,6 @@ dependencies {
compileOnly "androidx.lifecycle:lifecycle-extensions:$project.archLifecycleVersion"
compileOnly "com.android.installreferrer:installreferrer:2.2"

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.9'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
// test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ class PluginStateMachine(
}

override fun entities(event: InspectableEvent, state: State?): List<SelfDescribingJson> {
return entitiesConfiguration?.closure?.apply(event) ?: emptyList()
return entitiesConfiguration?.closure?.invoke(event) ?: emptyList()
}

override fun payloadValues(event: InspectableEvent, state: State?): Map<String, Any>? {
return null
}

override fun afterTrack(event: InspectableEvent) {
afterTrackConfiguration?.closure?.accept(event)
afterTrackConfiguration?.closure?.invoke(event)
}

override fun filter(event: InspectableEvent, state: State?): Boolean? {
return filterConfiguration?.closure?.apply(event)
return filterConfiguration?.closure?.invoke(event)
}

override fun eventsBefore(event: Event): List<Event>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.snowplowanalytics.snowplow.entity.ClientSessionEntity
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException
import java.util.function.Function

/**
* This configuration tells the tracker to send requests with the user ID in session context entity
Expand All @@ -31,7 +30,7 @@ import java.util.function.Function
*/
class FocalMeterConfiguration(
val kantarEndpoint: String,
val processUserId: Function<String, String>? = null,
val processUserId: ((String) -> String)? = null,
) : Configuration, PluginAfterTrackCallable, PluginIdentifiable {
private val TAG = FocalMeterConfiguration::class.java.simpleName

Expand All @@ -45,7 +44,7 @@ class FocalMeterConfiguration(
val session = event.entities.find { it is ClientSessionEntity } as? ClientSessionEntity
session?.userId?.let { newUserId ->
if (shouldUpdate(newUserId)) {
val processedUserId = processUserId?.apply(newUserId) ?: newUserId
val processedUserId = processUserId?.invoke(newUserId) ?: newUserId
makeRequest(processedUserId)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ package com.snowplowanalytics.snowplow.configuration
import com.snowplowanalytics.core.statemachine.PluginStateMachine
import com.snowplowanalytics.snowplow.payload.SelfDescribingJson
import com.snowplowanalytics.snowplow.tracker.InspectableEvent
import java.util.function.Consumer
import java.util.function.Function

/**
* Provides a block closure to be called after events are tracked.
Expand All @@ -27,7 +25,7 @@ import java.util.function.Function
*/
class PluginAfterTrackConfiguration(
val schemas: List<String>? = null,
val closure: Consumer<InspectableEvent>
val closure: (InspectableEvent) -> Unit?
)

/**
Expand All @@ -38,7 +36,7 @@ class PluginAfterTrackConfiguration(
*/
class PluginFilterConfiguration(
val schemas: List<String>? = null,
val closure: Function<InspectableEvent, Boolean>
val closure: (InspectableEvent) -> Boolean
)

/**
Expand All @@ -50,7 +48,7 @@ class PluginFilterConfiguration(
*/
class PluginEntitiesConfiguration(
val schemas: List<String>? = null,
val closure: Function<InspectableEvent, List<SelfDescribingJson>>
val closure: (InspectableEvent) -> List<SelfDescribingJson>
)

/**
Expand Down Expand Up @@ -121,7 +119,7 @@ interface PluginConfigurationInterface : PluginIdentifiable, PluginEntitiesCalla
/**
* Configuration for a custom tracker plugin.
* Enables you to add closures to be called when and after events are tracked in the tracker.
*
*
* @property identifier Unique identifier of the plugin within the tracker.
*/
class PluginConfiguration(
Expand All @@ -139,7 +137,7 @@ class PluginConfiguration(
*/
fun entities(
schemas: List<String>? = null,
closure: Function<InspectableEvent, List<SelfDescribingJson>>
closure: (InspectableEvent) -> List<SelfDescribingJson>
) {
entitiesConfiguration = PluginEntitiesConfiguration(
schemas = schemas,
Expand All @@ -156,7 +154,7 @@ class PluginConfiguration(
*/
fun afterTrack(
schemas: List<String>? = null,
closure: Consumer<InspectableEvent>
closure: (InspectableEvent) -> Unit?
): PluginConfiguration {
afterTrackConfiguration = PluginAfterTrackConfiguration(
schemas = schemas,
Expand All @@ -173,7 +171,7 @@ class PluginConfiguration(
*/
fun filter(
schemas: List<String>? = null,
closure: Function<InspectableEvent, Boolean>
closure: (InspectableEvent) -> Boolean
): PluginConfiguration {
filterConfiguration = PluginFilterConfiguration(
schemas = schemas,
Expand Down