Skip to content

Commit

Permalink
Merge branch 'release/5.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Jun 2, 2023
2 parents 16d2536 + 7dfe286 commit 2ff558d
Show file tree
Hide file tree
Showing 32 changed files with 873 additions and 483 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version 5.2.0 (2023-06-02)
--------------------------
Track install referrer details entity along with the application install event if available (#249)
Add a filter API to plugins to decide whether to track an event or not (#608)
Add version to default remote configuration and don't update unless remote configuration is newer (#603)

Version 5.1.0 (2023-05-11)
--------------------------
Track new properties in platform context version 1-0-3 and make it configurable which properties to track (#598)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.2.0
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {

subprojects {
group = 'com.snowplowanalytics'
version = '5.1.0'
version = '5.2.0'
repositories {
google()
maven {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=5.1.0
VERSION_NAME=5.2.0

POM_NAME=snowplow-android-tracker
POM_PACKAGING=aar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ private boolean setupWithRemoteConfig(@NonNull Consumer<Boolean> callbackTracker
updateLogger("Configuration retrieved from cache");
case FETCHED:
updateLogger("Configuration fetched from remote endpoint");
case DEFAULT:
updateLogger("Default configuration used");
}
Snowplow.getDefaultTracker().getEmitter().setRequestCallback(getRequestCallback());
callbackTrackerReady.accept(true);
Expand Down
1 change: 1 addition & 0 deletions snowplow-demo-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ dependencies {
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.browser:browser:1.5.0'
implementation 'com.google.android.gms:play-services-appset:16.0.2'
implementation "com.android.installreferrer:installreferrer:2.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class Demo : Activity(), LoggerDelegate {
updateLogger("Configuration fetched from remote endpoint")
}
ConfigurationState.FETCHED -> updateLogger("Configuration fetched from remote endpoint")
ConfigurationState.DEFAULT -> updateLogger("Default configuration used")
else -> updateLogger("Configuration was not found")
}
defaultTracker!!.emitter.requestCallback = requestCallback
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2015-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package com.snowplowanalytics.snowplow.event

import android.content.Context
import androidx.preference.PreferenceManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.snowplowanalytics.snowplow.Snowplow.createTracker
import com.snowplowanalytics.snowplow.configuration.*
import com.snowplowanalytics.snowplow.controller.TrackerController
import com.snowplowanalytics.snowplow.network.HttpMethod
import com.snowplowanalytics.snowplow.tracker.MockNetworkConnection
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ApplicationInstallEventTest {

@Before
fun setUp() {
cleanSharedPreferences()
}

// Tests
@Test
fun testTracksInstallEventOnFirstLaunch() {
// plugin to check if event was tracked
var eventTracked = false
val plugin = PluginConfiguration("testPlugin")
plugin.afterTrack { eventTracked = true }

// create tracker with install autotracking
val trackerConfiguration = TrackerConfiguration("appId")
.installAutotracking(true)
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(500)

// check if event was tracked
Assert.assertTrue(eventTracked)
}

@Test
fun testDoesntTrackInstallEventIfPreviouslyTracked() {
// plugin to check if event was tracked
var eventTracked = false
val plugin = PluginConfiguration("testPlugin")
plugin.afterTrack { eventTracked = true }

// create tracker with install autotracking
val trackerConfiguration = TrackerConfiguration("appId")
.installAutotracking(true)
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(500)

// check if event was tracked
Assert.assertTrue(eventTracked)

// reset flag
eventTracked = false

// create tracker again
createTracker(listOf(trackerConfiguration, plugin))

Thread.sleep(500)

// check if event was tracked
Assert.assertFalse(eventTracked)
}

private fun cleanSharedPreferences() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
sharedPreferences.edit().clear().commit()
}

private fun createTracker(configurations: List<Configuration>): TrackerController {
val networkConfig = NetworkConfiguration(MockNetworkConnection(HttpMethod.POST, 200))
return createTracker(
context,
namespace = "ns" + Math.random().toString(),
network = networkConfig,
configurations = configurations.toTypedArray()
)
}

private val context: Context
get() = InstrumentationRegistry.getInstrumentation().targetContext
}

This file was deleted.

Loading

0 comments on commit 2ff558d

Please sign in to comment.