Skip to content

Commit

Permalink
Release/1.5.0 (#193)
Browse files Browse the repository at this point in the history
* [MT-1116] Add support for default mappings - all_events/all_views (#188)

* Mt 1107 (#181)

* Bug fix: sessionCounting + logical resolution

* Cleanup imports

* Minor fix for app_uuid

* Updates per code review

Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>

* [MT-1112] - moved profile override init earlier (#183)

Co-authored-by: Karen Tamayo <[email protected]>

* [MT-960] - added missing proguard rules for new classes (#184)

Co-authored-by: Karen Tamayo <[email protected]>

* Update TealiumTests + AppCollectorTests

* Add support for default mappings - all_events/all_views

* Update commandList to use List

* Edit RemoteCommandDispatcher to version 1.2.0

Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: James Keith <[email protected]>

* [MT-1083] - Visitor Switching (#191)

* visitor switching

* Datalayer update notifications + tests/fixes

* Edge case fixes, and single hash

* [MT-1047] QueryParameterProvider + WebView loading (#185)

* QuerParamProvider + Updates to TagManagementDispatcher

* Clean up tests

* Move provideParameters call off main thread

* WebView init synchronization (#187)

Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: James Keith <[email protected]>

* Release version and dependency updates (#192)

* Slight increment to delay on test

* [MT-1149] - Visitor Switching  (#194)

* Visitor switching enhancements + param providers timeout

* WebViewLoader Tests

Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>

* gradle wrapper + test update

Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: Karen Tamayo <[email protected]>
Co-authored-by: James Keith <[email protected]>
  • Loading branch information
5 people authored Oct 19, 2022
1 parent 2305fb5 commit ac5255f
Show file tree
Hide file tree
Showing 42 changed files with 2,210 additions and 212 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Change Log

- 1.5.0 Oct 2022
- Visitor Switching
- Additional TealiumConfig option `visitorIdentityKey` to configure where to find a known identity in the DataLayer
- Known identities are hashed and linked to the `tealium_visitor_id` to allow better switching between returning identities
- Additional listeners
- `VisitorIdUpdatedListener` - notifies when the visitor id has been updated, either as a result of switching identities or of resetting the visitor id
- `DataLayerUpdatedListener`
- `onDataUpdated(String, Any)` - notifies that a value has been updated in the DataLayer
- `onDataRemoved(Set<String>)` - notifies that the given keys have been removed from the DataLayer, either by user interaction or data expiration
- RemoteCommandDispatcher 1.2.0
- Support for default mapping `all_events` and `all_views` in the JSON mappings file to enable triggering specified commands in response to every view/event
- TagManagement 1.2.0
- `QueryParameterProvider` - allows additional parameters to be added to the URL used for the TagManagement module
- Improved WebView instantiation and page load management
- Kotlin Dependency updates
- Stdlib: 1.6.21
- Coroutines: 1.6.2
- 1.4.3 Sep 2022
- Core 1.4.3
- DeviceCollector Bug fix - Correct calculation for tealium_logical_resolution
- TagManagement 1.1.3
- Bug fix - Relocate sessionCountingEnabled to fix miscount on fresh launch
- VisitorService 1.1.1
- Bug fix - Move VisitorService profile override to earlier initialization
- Location: Add missing Proguard rules for new classes
- 1.4.2 Jun 2022
- Core 1.4.2
- Add `overrideConsentCategoriesKey` to `TealiumConfig` to allow for a custom consent categories key
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.32'
ext.coroutines_core_version = '1.4.3'
ext.coroutines_android_version = '1.4.3'
ext.coroutines_test_version = '1.4.3'
ext.kotlin_version = '1.6.21'
ext.coroutines_core_version = '1.6.2'
ext.coroutines_android_version = '1.6.2'
ext.coroutines_test_version = '1.6.2'
ext.mockk_version = '1.12.0'
ext.robolectric_version = '4.6.1'

Expand All @@ -13,7 +13,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Wed Jan 06 10:42:50 PST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
1 change: 1 addition & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
versionName "1.0"
buildConfigField 'String', 'TAG', "\"App\""
buildConfigField 'String', 'TEALIUM_INSTANCE', "\"main\""
buildConfigField 'String', 'IDENTITY_KEY', "\"identity\""
buildConfigField 'Boolean', 'AUTO_TRACKING', "true"
buildConfigField 'Boolean', 'AUTO_TRACKING_PUSH_ENABLED', "false"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.tealium.fragments

import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.UiThread
import androidx.fragment.app.Fragment
import com.tealium.core.Tealium
import com.tealium.core.messaging.VisitorIdUpdatedListener
import com.tealium.mobile.BuildConfig
import com.tealium.mobile.databinding.FragmentVisitorServiceBinding
import com.tealium.visitorservice.visitorService
Expand All @@ -15,8 +19,20 @@ import kotlinx.coroutines.launch
class VisitorServiceFragment : Fragment() {

private lateinit var binding: FragmentVisitorServiceBinding
private var existingIdentity: String = ""
private val visitorIdListener = object : VisitorIdUpdatedListener {
override fun onVisitorIdUpdated(visitorId: String) {
activity?.runOnUiThread {
setVisitorId(visitorId)
}
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = FragmentVisitorServiceBinding.inflate(inflater, container, false)
return binding.root
}
Expand All @@ -26,11 +42,63 @@ class VisitorServiceFragment : Fragment() {
binding.fetchProfileButton.setOnClickListener {
onFetchProfile()
}

binding.btnIdentifyUser.setOnClickListener {
val identity = binding.editCurrentIdentity.text.toString()
if (identity.isNotBlank()) {
onSetIdentity(identity)
}
}

binding.editCurrentIdentity.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}

override fun afterTextChanged(s: Editable?) {
binding.btnIdentifyUser.isEnabled = s.toString() != existingIdentity
}
})

setVisitorId(Tealium[BuildConfig.TEALIUM_INSTANCE]?.visitorId ?: "")
}

override fun onResume() {
super.onResume()

existingIdentity =
Tealium[BuildConfig.TEALIUM_INSTANCE]?.dataLayer?.getString(
BuildConfig.IDENTITY_KEY,
) ?: ""
binding.editCurrentIdentity.setText(existingIdentity)

Tealium[BuildConfig.TEALIUM_INSTANCE]?.events?.subscribe(visitorIdListener)
}

override fun onDestroy() {
super.onDestroy()

Tealium[BuildConfig.TEALIUM_INSTANCE]?.events?.unsubscribe(visitorIdListener)
}

@UiThread
private fun setVisitorId(visitorId: String) {
binding.txtVisitorIdPlaceholder.text = visitorId
}

private fun onFetchProfile() {
GlobalScope.launch {
Tealium[BuildConfig.TEALIUM_INSTANCE]?.visitorService?.requestVisitorProfile()
}
}

private fun onSetIdentity(identity: String) {
existingIdentity = identity
GlobalScope.launch {
Tealium[BuildConfig.TEALIUM_INSTANCE]?.dataLayer?.putString(
BuildConfig.IDENTITY_KEY,
identity
)
}
}
}
91 changes: 66 additions & 25 deletions mobile/src/main/java/com/tealium/mobile/TealiumHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.tealium.mobile

import android.app.Application
import com.android.billingclient.api.Purchase
import android.util.Log
import com.tealium.adidentifier.AdIdentifier
import com.tealium.autotracking.*
import com.tealium.collectdispatcher.Collect
Expand Down Expand Up @@ -36,20 +35,27 @@ import java.util.concurrent.TimeUnit
object TealiumHelper : ActivityDataCollector {

fun init(application: Application) {
val config = TealiumConfig(application,
"tealiummobile",
"android",
Environment.DEV,
modules = mutableSetOf(
Modules.Lifecycle,
Modules.VisitorService,
Modules.HostedDataLayer,
Modules.CrashReporter,
Modules.AdIdentifier,
Modules.InAppPurchaseManager,
Modules.AutoTracking,
Modules.Media),
dispatchers = mutableSetOf(Dispatchers.Collect, Dispatchers.TagManagement, Dispatchers.RemoteCommands)
val config = TealiumConfig(
application,
"tealiummobile",
"android",
Environment.DEV,
modules = mutableSetOf(
Modules.Lifecycle,
Modules.VisitorService,
Modules.HostedDataLayer,
Modules.CrashReporter,
Modules.AdIdentifier,
Modules.InAppPurchaseManager,
Modules.AutoTracking,
Modules.Media,
QueryParamProviderModule
),
dispatchers = mutableSetOf(
Dispatchers.Collect,
Dispatchers.TagManagement,
Dispatchers.RemoteCommands
)
).apply {
useRemoteLibrarySettings = true
// sessionCountingEnabled = false
Expand All @@ -61,23 +67,28 @@ object TealiumHelper : ActivityDataCollector {
consentExpiry = ConsentExpiry(1, TimeUnit.DAYS)

timedEventTriggers = mutableListOf(
EventTrigger.forEventName("start_event", "end_event")
EventTrigger.forEventName("start_event", "end_event")
)

mediaBackgroundSessionEnabled = false
mediaBackgroundSessionEndInterval = 5000L // end session after 5 seconds

autoTrackingMode = if (BuildConfig.AUTO_TRACKING) AutoTrackingMode.FULL else AutoTrackingMode.NONE
autoTrackingMode =
if (BuildConfig.AUTO_TRACKING) AutoTrackingMode.FULL else AutoTrackingMode.NONE
// autoTrackingBlocklistFilename = "autotracking-blocklist.json"
// autoTrackingBlocklistUrl = "https://tags.tiqcdn.com/dle/tealiummobile/android/autotracking-blocklist.json"
autoTrackingCollectorDelegate = TealiumHelper
// overrideConsentCategoriesKey = "my_consent_categories_key"

visitorIdentityKey = BuildConfig.IDENTITY_KEY
}

Tealium.create(BuildConfig.TEALIUM_INSTANCE, config) {
events.subscribe(object : UserConsentPreferencesUpdatedListener {
override fun onUserConsentPreferencesUpdated(userConsentPreferences: UserConsentPreferences,
policy: ConsentManagementPolicy) {
override fun onUserConsentPreferencesUpdated(
userConsentPreferences: UserConsentPreferences,
policy: ConsentManagementPolicy
) {
if (userConsentPreferences.consentStatus == ConsentStatus.UNKNOWN) {
Logger.dev(BuildConfig.TAG, "Re-prompt for consent")
}
Expand All @@ -97,22 +108,31 @@ object TealiumHelper : ActivityDataCollector {

val webViewRemoteCommand = object : RemoteCommand("bgcolor", "testing Webview RCs") {
override fun onInvoke(response: Response) {
Logger.dev(BuildConfig.TAG, "ResponsePayload for webView RemoteCommand ${response.requestPayload}")
Logger.dev(
BuildConfig.TAG,
"ResponsePayload for webView RemoteCommand ${response.requestPayload}"
)
}
}

val localJsonCommand = object : RemoteCommand("localJsonCommand", "testingRCs") {
override fun onInvoke(response: Response) {
Logger.dev(BuildConfig.TAG, "ResponsePayload for local JSON RemoteCommand ${response.requestPayload}")
Logger.dev(
BuildConfig.TAG,
"ResponsePayload for local JSON RemoteCommand ${response.requestPayload}"
)
}
}

fun fetchConsentCategories(): String? {
return Tealium[BuildConfig.TEALIUM_INSTANCE]?.consentManager?.userConsentCategories?.joinToString(",")
return Tealium[BuildConfig.TEALIUM_INSTANCE]?.consentManager?.userConsentCategories?.joinToString(
","
)
}

fun setConsentCategories(categories: Set<String>) {
Tealium[BuildConfig.TEALIUM_INSTANCE]?.consentManager?.userConsentCategories = ConsentCategory.consentCategories(categories)
Tealium[BuildConfig.TEALIUM_INSTANCE]?.consentManager?.userConsentCategories =
ConsentCategory.consentCategories(categories)
}

fun trackView(name: String, data: Map<String, Any>?) {
Expand All @@ -126,10 +146,13 @@ object TealiumHelper : ActivityDataCollector {
}

fun trackPurchase(purchase: Purchase, data: Map<String, Any>?) {
Tealium[BuildConfig.TEALIUM_INSTANCE]?.inAppPurchaseManager?.trackInAppPurchase(purchase, data)
Tealium[BuildConfig.TEALIUM_INSTANCE]?.inAppPurchaseManager?.trackInAppPurchase(
purchase,
data
)
}

fun retrieveDatalayer() : Map<String, Any>? {
fun retrieveDatalayer(): Map<String, Any>? {
return Tealium[BuildConfig.TEALIUM_INSTANCE]?.gatherTrackData()
}

Expand All @@ -154,3 +177,21 @@ object TealiumHelper : ActivityDataCollector {
return mapOf("global_data" to "value")
}
}

class QueryParamProviderModule : Module, QueryParameterProvider {
override val name: String = "SampleQueryParamProvider"
override var enabled: Boolean = true

override suspend fun provideParameters(): Map<String, List<String>> {
return mapOf(
"query_param1" to listOf("QueryParamProvider_value1"),
"query_param2" to listOf("QueryParamProvider_value2"),
)
}

companion object : ModuleFactory {
override fun create(context: TealiumContext): Module {
return QueryParamProviderModule()
}
}
}
50 changes: 50 additions & 0 deletions mobile/src/main/res/layout/fragment_visitor_service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,54 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/edit_current_identity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="16dp"
android:hint="@string/hint_identity"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fetchProfileButton" />


<Button
android:id="@+id/btn_identify_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="@string/btn_identify"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/edit_current_identity" />

<TextView
android:id="@+id/txt_visitor_id_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/visitor_id_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.045"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_identify_user" />

<TextView
android:id="@+id/txt_visitor_id_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/visitor_id_placeholder"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.485"
app:layout_constraintStart_toEndOf="@+id/txt_visitor_id_label"
app:layout_constraintTop_toBottomOf="@+id/btn_identify_user" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 4 additions & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
<string name="second_activity_text_view">Second Activity</string>
<string name="third_activity">Third Activity</string>
<string name="third_activity_text_view">Third Activity</string>
<string name="hint_identity">Identity</string>
<string name="btn_identify">Identify</string>
<string name="visitor_id_label">Visitor Id:</string>
<string name="visitor_id_placeholder"><![CDATA[<visitor id>]]></string>
</resources>
Loading

0 comments on commit ac5255f

Please sign in to comment.