From a811ad9c4c2ed73a08d7ce280a90f7ceedec7b0b Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Thu, 30 May 2024 17:31:40 +0100 Subject: [PATCH 1/3] Set serverAnonymisation more quickly (close #689) * Make OkHttpNetworkConnection serverAnon property public * Remove outdated docstring * Fix assignment * Update java version and runner in build action --- .github/workflows/build.yml | 15 ++++++++------- .../snowplowdemocompose/data/Tracking.kt | 2 +- .../snowplowanalytics/core/emitter/Emitter.kt | 19 +++---------------- .../network/OkHttpNetworkConnection.kt | 2 +- 4 files changed, 13 insertions(+), 25 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 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..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 @@ -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()) { @@ -303,19 +301,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 = serverAnonymisation } } 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 7eda874a4f82f7003788a9695aa60bf13583b17d Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 4 Jun 2024 17:13:19 +0100 Subject: [PATCH 2/3] Send correct install referrer timestamps (close #687) For PR #690 * Correct timestamp units * Add docstring in Utils --- .../snowplowanalytics/core/tracker/InstallReferrerDetails.kt | 4 ++-- .../src/main/java/com/snowplowanalytics/core/utils/Util.kt | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/tracker/InstallReferrerDetails.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/tracker/InstallReferrerDetails.kt index 96e2d878a..99a41bbd9 100644 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/tracker/InstallReferrerDetails.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/tracker/InstallReferrerDetails.kt @@ -42,8 +42,8 @@ class InstallReferrerDetails( "iglu:com.android.installreferrer.api/referrer_details/jsonschema/1-0-0", mapOf( "installReferrer" to installReferrer, - "referrerClickTimestamp" to if (referrerClickTimestamp > 0) { Util.getDateTimeFromTimestamp(referrerClickTimestamp) } else { null }, - "installBeginTimestamp" to if (installBeginTimestamp > 0) { Util.getDateTimeFromTimestamp(installBeginTimestamp) } else { null }, + "referrerClickTimestamp" to if (referrerClickTimestamp > 0) { Util.getDateTimeFromTimestamp(referrerClickTimestamp * 1000) } else { null }, + "installBeginTimestamp" to if (installBeginTimestamp > 0) { Util.getDateTimeFromTimestamp(installBeginTimestamp * 1000) } else { null }, "googlePlayInstantParam" to googlePlayInstantParam, ) ) { diff --git a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/utils/Util.kt b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/utils/Util.kt index 12ca32945..df72763e3 100755 --- a/snowplow-tracker/src/main/java/com/snowplowanalytics/core/utils/Util.kt +++ b/snowplow-tracker/src/main/java/com/snowplowanalytics/core/utils/Util.kt @@ -44,6 +44,9 @@ object Util { return System.currentTimeMillis().toString() } + /** + * Converts a timestamp in milliseconds to a DateTime. + */ @JvmStatic fun getDateTimeFromTimestamp(timestamp: Long): String { val date = Date(timestamp) From 1e15289bf26b335bbded28de3c43356d730cf5d8 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 4 Jun 2024 17:19:48 +0100 Subject: [PATCH 3/3] Prepare for v6.0.4 release --- CHANGELOG | 5 +++++ VERSION | 2 +- build.gradle | 2 +- gradle.properties | 2 +- .../snowplowdemocompose/data/Tracking.kt | 9 +++++++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c9f34bdf3..1d5078856 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Version 6.0.4 (2024-06-05) +-------------------------- +Send correct install referrer timestamps (#687) +Set serverAnonymisation more quickly (#689) + Version 6.0.3 (2024-04-18) -------------------------- Add Subject config flag to avoid WindowManager bug (#657) diff --git a/VERSION b/VERSION index 090ea9dad..1aa5e414f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.0.3 +6.0.4 diff --git a/build.gradle b/build.gradle index aed28ce6b..c350e94a8 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { subprojects { group = 'com.snowplowanalytics' - version = '6.0.3' + version = '6.0.4' repositories { google() maven { diff --git a/gradle.properties b/gradle.properties index e01a26e65..458100ca4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,7 +31,7 @@ systemProp.org.gradle.internal.http.socketTimeout=120000 SONATYPE_STAGING_PROFILE=comsnowplowanalytics GROUP=com.snowplowanalytics POM_ARTIFACT_ID=snowplow-android-tracker -VERSION_NAME=6.0.3 +VERSION_NAME=6.0.4 POM_NAME=snowplow-android-tracker POM_PACKAGING=aar 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 5826dc451..774354ffa 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 @@ -17,10 +17,15 @@ import com.snowplowanalytics.snowplow.payload.SelfDescribingJson import com.snowplowanalytics.snowplow.tracker.LogLevel object Tracking { + /** + * Replace this with the URI of your Snowplow collector + * (e.g., Micro, Mini, or BDP). + */ + private const val collectorEndpoint = "placeholder" + @Composable fun setup(namespace: String) : TrackerController { - // Replace this collector endpoint with your own - val networkConfig = NetworkConfiguration("http://192.168.0.20:9090", HttpMethod.POST) + val networkConfig = NetworkConfiguration(collectorEndpoint, HttpMethod.POST) val trackerConfig = TrackerConfiguration("appID") .logLevel(LogLevel.DEBUG) .screenViewAutotracking(false)