From 707dfa71769045a76784071890c26967b92580b6 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Thu, 9 May 2024 16:33:43 +0100 Subject: [PATCH 1/4] Make OkHttpNetworkConnection serverAnon property public --- .../snowplowdemocompose/data/Tracking.kt | 2 +- .../com/snowplowanalytics/core/emitter/Emitter.kt | 15 ++------------- .../snowplow/network/OkHttpNetworkConnection.kt | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/snowplow-demo-compose/src/main/java/com/snowplowanalytics/snowplowdemocompose/data/Tracking.kt b/snowplow-demo-compose/src/main/java/com/snowplowanalytics/snowplowdemocompose/data/Tracking.kt index da8dd4b1e..5826dc451 100644 --- a/snowplow-demo-compose/src/main/java/com/snowplowanalytics/snowplowdemocompose/data/Tracking.kt +++ b/snowplow-demo-compose/src/main/java/com/snowplowanalytics/snowplowdemocompose/data/Tracking.kt @@ -20,7 +20,7 @@ object Tracking { @Composable fun setup(namespace: String) : TrackerController { // Replace this collector endpoint with your own - val networkConfig = NetworkConfiguration("https://23a6-82-26-43-253.ngrok.io", HttpMethod.POST) + val networkConfig = NetworkConfiguration("http://192.168.0.20:9090", HttpMethod.POST) val trackerConfig = TrackerConfiguration("appID") .logLevel(LogLevel.DEBUG) .screenViewAutotracking(false) diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt index 220acef7a..04d518150 100755 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt @@ -303,19 +303,8 @@ class Emitter( */ set(serverAnonymisation) { field = serverAnonymisation - if (!isCustomNetworkConnection && builderFinished) { - networkConnection = emitTimeout?.let { - OkHttpNetworkConnectionBuilder(uri, context) - .method(httpMethod) - .tls(tlsVersions) - .emitTimeout(it) - .customPostPath(customPostPath) - .client(client) - .cookieJar(cookieJar) - .serverAnonymisation(serverAnonymisation) - .requestHeaders(requestHeaders) - .build() - } + if (!isCustomNetworkConnection && builderFinished && networkConnection is OkHttpNetworkConnection) { + (networkConnection as OkHttpNetworkConnection).serverAnonymisation = true } } diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/snowplow/network/OkHttpNetworkConnection.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/snowplow/network/OkHttpNetworkConnection.kt index 4b5631300..4092cc254 100644 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/snowplow/network/OkHttpNetworkConnection.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/snowplow/network/OkHttpNetworkConnection.kt @@ -48,7 +48,7 @@ class OkHttpNetworkConnection private constructor(builder: OkHttpNetworkConnecti override val httpMethod: HttpMethod private val emitTimeout: Int private val customPostPath: String? - private val serverAnonymisation: Boolean + var serverAnonymisation: Boolean private val requestHeaders: Map? private var client: OkHttpClient? = null private val uriBuilder: Uri.Builder From 18b5fd0bfa1bd8748af36f8480c4208664e8c801 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Thu, 9 May 2024 16:42:27 +0100 Subject: [PATCH 2/4] Remove outdated docstring --- .../main/java/com/snowplowanalytics/core/emitter/Emitter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt index 04d518150..5bbdf44e9 100755 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt @@ -197,9 +197,7 @@ class Emitter( var bufferOption: BufferOption = EmitterDefaults.bufferOption /** * Whether the buffer should send events instantly or after the buffer has reached - * its limit. By default, this is set to BufferOption Default. - * - * @param option Set the BufferOption enum to Instant to send events upon creation. + * its limit. */ set(option) { if (!isRunning.get()) { From c81db9019d36f083d1274065d75a08ceb92f71d7 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Fri, 10 May 2024 10:33:30 +0100 Subject: [PATCH 3/4] Fix assignment --- .../src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt index 5bbdf44e9..985a637a8 100755 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/emitter/Emitter.kt @@ -302,7 +302,7 @@ class Emitter( set(serverAnonymisation) { field = serverAnonymisation if (!isCustomNetworkConnection && builderFinished && networkConnection is OkHttpNetworkConnection) { - (networkConnection as OkHttpNetworkConnection).serverAnonymisation = true + (networkConnection as OkHttpNetworkConnection).serverAnonymisation = serverAnonymisation } } From 8971c5e368dbe43fa106f89d0bc462b793334cff Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Fri, 10 May 2024 11:16:01 +0100 Subject: [PATCH 4/4] Update java version and runner in build action --- .github/workflows/build.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e95b48ae..505ffcd9e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: [push] jobs: test: - runs-on: macos-latest + runs-on: ubuntu-latest strategy: fail-fast: false @@ -17,11 +17,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '11' + + - name: Enable KVM group perms + 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 - name: Validate Gradle Wrapper uses: gradle/wrapper-validation-action@v1 @@ -30,7 +31,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: "temurin" - java-version: "11" + java-version: "17" - name: Run Tests uses: reactivecircus/android-emulator-runner@v2