Skip to content

Commit 2666804

Browse files
Merge branch 'main' into Remove_Date
2 parents 099a569 + 57c30dd commit 2666804

File tree

146 files changed

+804
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+804
-785
lines changed

app/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
applicationId 'org.wikipedia'
3838
minSdk 21
3939
targetSdk 34
40-
versionCode 50466
40+
versionCode 50467
4141
testApplicationId 'org.wikipedia.test'
4242
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4343
testInstrumentationRunnerArguments clearPackageData: 'true'
@@ -168,18 +168,18 @@ dependencies {
168168
// use http://gradleplease.appspot.com/ or http://search.maven.org/.
169169
// Debug with ./gradlew -q app:dependencies --configuration compile
170170

171-
String okHttpVersion = '4.10.0'
171+
String okHttpVersion = '4.12.0'
172172
String retrofitVersion = '2.9.0'
173-
String glideVersion = '4.15.1'
173+
String glideVersion = '4.16.0'
174174
String mockitoVersion = '5.2.0'
175-
String leakCanaryVersion = '2.12'
175+
String leakCanaryVersion = '2.13'
176176
String kotlinCoroutinesVersion = '1.7.3'
177177
String firebaseMessagingVersion = '23.4.0'
178178
String mlKitVersion = '17.0.4'
179179
String roomVersion = "2.6.1"
180180
String espressoVersion = '3.5.1'
181-
String serialization_version = '1.5.1'
182-
String metricsVersion = '2.0'
181+
String serialization_version = '1.6.2'
182+
String metricsVersion = '2.1'
183183

184184
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
185185

@@ -219,9 +219,9 @@ dependencies {
219219
implementation "io.reactivex.rxjava3:rxjava:3.1.8"
220220
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
221221
implementation 'org.apache.commons:commons-lang3:3.14.0'
222-
implementation 'org.jsoup:jsoup:1.17.1'
222+
implementation 'org.jsoup:jsoup:1.17.2'
223223
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
224-
implementation 'com.github.skydoves:balloon:1.6.3'
224+
implementation 'com.github.skydoves:balloon:1.6.4'
225225
implementation "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0"
226226

227227
implementation("androidx.room:room-runtime:$roomVersion")

app/src/main/java/org/wikipedia/LongPressHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class LongPressHandler(
8585
(view.rootView as ViewGroup).addView(tempView)
8686
anchorView = tempView
8787
}
88-
LongPressMenu(anchorView, true, callback).show(entry)
88+
LongPressMenu(anchorView, callback = callback).show(entry)
8989
}
9090
}
9191
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package org.wikipedia.analytics.eventplatform
22

3+
import kotlinx.serialization.EncodeDefault
4+
import kotlinx.serialization.ExperimentalSerializationApi
35
import kotlinx.serialization.SerialName
46
import kotlinx.serialization.Serializable
7+
import kotlinx.serialization.Transient
58

69
@Suppress("unused")
710
@Serializable
11+
@OptIn(ExperimentalSerializationApi::class)
812
@SerialName("/analytics/mobile_apps/app_interaction/1.0.0")
913
class AppInteractionEvent(
1014
private val action: String,
1115
private val active_interface: String,
1216
private val action_data: String,
1317
private val primary_language: String,
1418
private val wiki_id: String,
15-
private var platform: String,
16-
) : MobileAppsEvent(STREAM_NAME) {
17-
companion object {
18-
var STREAM_NAME = "app_donor_experience"
19-
}
20-
}
19+
@Transient private val streamName: String = "",
20+
@EncodeDefault(EncodeDefault.Mode.ALWAYS) private val platform: String = "android",
21+
) : MobileAppsEvent(streamName)

app/src/main/java/org/wikipedia/analytics/eventplatform/BreadCrumbLogEvent.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wikipedia.analytics.eventplatform
22

3+
import android.app.Activity
34
import android.content.Context
45
import android.view.MenuItem
56
import android.view.View
@@ -8,6 +9,7 @@ import android.widget.TextView
89
import androidx.fragment.app.Fragment
910
import kotlinx.serialization.SerialName
1011
import kotlinx.serialization.Serializable
12+
import org.wikipedia.Constants
1113
import org.wikipedia.WikipediaApp
1214
import org.wikipedia.settings.SettingsActivity
1315
import org.wikipedia.util.log.L
@@ -54,7 +56,9 @@ class BreadCrumbLogEvent(
5456
}
5557

5658
fun logScreenShown(context: Context, fragment: Fragment? = null) {
57-
EventPlatformClient.submit(BreadCrumbLogEvent(BreadCrumbViewUtil.getReadableScreenName(context, fragment), "show"))
59+
val invokeSource = (fragment?.activity?.intent ?: (context as? Activity)?.intent)?.getSerializableExtra(Constants.INTENT_EXTRA_INVOKE_SOURCE) as? Constants.InvokeSource
60+
EventPlatformClient.submit(BreadCrumbLogEvent(BreadCrumbViewUtil.getReadableScreenName(context, fragment),
61+
"show" + invokeSource?.let { ".from." + it.value }.orEmpty()))
5862
}
5963

6064
fun logBackPress(context: Context) {

app/src/main/java/org/wikipedia/analytics/eventplatform/DonorExperienceEvent.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import org.wikipedia.WikipediaApp
55
class DonorExperienceEvent {
66

77
companion object {
8-
private const val STREAM_NAME = "app_donor_experience"
9-
108
fun logImpression(activeInterface: String, campaignId: String? = null, wikiId: String = "") {
119
submitDonorExperienceEvent("impression", activeInterface, getActionDataString(campaignId), wikiId)
1210
}
@@ -35,15 +33,14 @@ class DonorExperienceEvent {
3533
actionData: String,
3634
wikiId: String
3735
) {
38-
AppInteractionEvent.STREAM_NAME = STREAM_NAME
3936
EventPlatformClient.submit(
4037
AppInteractionEvent(
4138
action,
4239
activeInterface,
4340
actionData,
4441
WikipediaApp.instance.languageState.appLanguageCode,
4542
wikiId,
46-
"android"
43+
"app_donor_experience"
4744
)
4845
)
4946
}

app/src/main/java/org/wikipedia/analytics/eventplatform/EventPlatformClient.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ object EventPlatformClient {
151151
* can contain events of different streams
152152
*/
153153
private fun send() {
154-
if (!Prefs.isEventLoggingEnabled) {
155-
return
156-
}
157154
QUEUE.groupBy { it.stream }.forEach { (stream, events) ->
158155
sendEventsForStream(STREAM_CONFIGS[stream]!!, events)
159156
}

app/src/main/java/org/wikipedia/analytics/eventplatform/PatrollerExperienceEvent.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import org.wikipedia.settings.Prefs
66
class PatrollerExperienceEvent {
77

88
companion object {
9-
private const val STREAM_NAME = "app_patroller_experience"
10-
119
fun logImpression(activeInterface: String) {
1210
submitPatrollerActivityEvent("impression", activeInterface)
1311
}
@@ -44,15 +42,14 @@ class PatrollerExperienceEvent {
4442
}
4543

4644
private fun submitPatrollerActivityEvent(action: String, activeInterface: String, actionData: String = "") {
47-
AppInteractionEvent.STREAM_NAME = STREAM_NAME
4845
EventPlatformClient.submit(
4946
AppInteractionEvent(
5047
action,
5148
activeInterface,
5249
actionData,
5350
WikipediaApp.instance.languageState.appLanguageCode,
5451
Prefs.recentEditsWikiCode,
55-
"android"
52+
"app_patroller_experience"
5653
)
5754
)
5855
}

app/src/main/java/org/wikipedia/analytics/metricsplatform/ArticleEvent.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.wikipedia.analytics.metricsplatform
22

33
import org.wikimedia.metrics_platform.context.PageData
4+
import org.wikipedia.dataclient.page.PageSummary
45
import org.wikipedia.page.PageFragment
56
import org.wikipedia.page.PageTitle
67
import org.wikipedia.settings.Prefs
@@ -22,6 +23,7 @@ class ArticleFindInPageInteraction(private val fragment: PageFragment) : TimedMe
2223

2324
fun logDone() {
2425
submitEvent(
26+
"android.product_metrics.find_in_page_interaction",
2527
"/analytics/mobile_apps/product_metrics/android_find_in_page_interaction/1.0.0",
2628
"find_in_page_interaction",
2729
mapOf(
@@ -142,6 +144,7 @@ class ArticleToolbarInteraction(private val fragment: PageFragment) : TimedMetri
142144
private fun submitEvent(action: String) {
143145

144146
submitEvent(
147+
"android.product_metrics.article_toolbar_interaction",
145148
"article_toolbar_interaction",
146149
getInteractionData(
147150
"article_toolbar_interaction",
@@ -183,6 +186,7 @@ class ArticleTocInteraction(private val fragment: PageFragment, private val numS
183186
return
184187
}
185188
submitEvent(
189+
"android.product_metrics.article_toc_interaction",
186190
"/analytics/mobile_apps/product_metrics/android_article_toc_interaction/1.0.0",
187191
"article_toc_interaction",
188192
mapOf(
@@ -211,6 +215,11 @@ class ArticleLinkPreviewInteraction : TimedMetricsEvent {
211215
pageData = getPageData(pageTitle, pageId)
212216
}
213217

218+
constructor(pageTitle: PageTitle, summary: PageSummary, source: Int) {
219+
this.source = source
220+
pageData = getPageData(pageTitle, summary)
221+
}
222+
214223
fun logLinkClick() {
215224
submitEvent("linkclick")
216225
}
@@ -225,6 +234,7 @@ class ArticleLinkPreviewInteraction : TimedMetricsEvent {
225234

226235
private fun submitEvent(action: String) {
227236
submitEvent(
237+
"android.product_metrics.article_link_preview_interaction",
228238
"article_link_preview_interaction",
229239
getInteractionData(
230240
"article_link_preview_interaction",

app/src/main/java/org/wikipedia/analytics/metricsplatform/MetricsEvent.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,31 @@ import org.wikimedia.metrics_platform.context.PerformerData
77
import org.wikipedia.WikipediaApp
88
import org.wikipedia.analytics.eventplatform.EventPlatformClient
99
import org.wikipedia.auth.AccountUtil
10+
import org.wikipedia.dataclient.page.PageSummary
1011
import org.wikipedia.page.Namespace
1112
import org.wikipedia.page.PageFragment
1213
import org.wikipedia.page.PageTitle
13-
import org.wikipedia.settings.Prefs
1414
import org.wikipedia.util.ReleaseUtil
1515

1616
open class MetricsEvent {
1717

1818
/**
1919
* Submit an event to the Metrics Platform using a base interaction schema
2020
*
21+
* @param streamName the name of the stream
2122
* @param eventName the name of the event
2223
* @param interactionData a data object that conforms to core interactions
2324
* @param pageData dynamic page data that should be added to the ClientData object
2425
*/
2526
protected fun submitEvent(
27+
streamName: String,
2628
eventName: String,
2729
interactionData: InteractionData?,
2830
pageData: PageData? = null
2931
) {
30-
if (ReleaseUtil.isPreProdRelease && Prefs.isEventLoggingEnabled) {
32+
if (ReleaseUtil.isPreProdRelease) {
3133
MetricsPlatform.client.submitInteraction(
34+
streamName,
3235
EVENT_NAME_BASE + eventName,
3336
getClientData(pageData),
3437
interactionData)
@@ -38,21 +41,24 @@ open class MetricsEvent {
3841
/**
3942
* Submit an event to the Metrics Platform using a custom schema
4043
*
44+
* @param streamName the name of the stream
4145
* @param schemaId the custom schema ID
4246
* @param eventName the name of the event
4347
* @param customData the custom data key-value pairs that are top-level properties
4448
* @param interactionData a data object that conforms to core interactions
4549
* @param pageData dynamic page data that should be added to the ClientData object
4650
*/
4751
protected fun submitEvent(
52+
streamName: String,
4853
schemaId: String,
4954
eventName: String,
5055
customData: Map<String, Any>,
5156
interactionData: InteractionData?,
5257
pageData: PageData? = null
5358
) {
54-
if (ReleaseUtil.isPreProdRelease && Prefs.isEventLoggingEnabled) {
59+
if (ReleaseUtil.isPreProdRelease) {
5560
MetricsPlatform.client.submitInteraction(
61+
streamName,
5662
schemaId,
5763
EVENT_NAME_BASE + eventName,
5864
getClientData(pageData),
@@ -62,7 +68,7 @@ open class MetricsEvent {
6268
}
6369
}
6470

65-
protected fun getClientData(pageData: PageData?): ClientData {
71+
private fun getClientData(pageData: PageData?): ClientData {
6672
return ClientData(
6773
MetricsPlatform.agentData,
6874
pageData,
@@ -98,6 +104,19 @@ open class MetricsEvent {
98104
)
99105
}
100106

107+
protected fun getPageData(pageTitle: PageTitle?, pageSummary: PageSummary?): PageData? {
108+
if (pageTitle == null) return null
109+
return PageData(
110+
pageSummary?.pageId,
111+
pageTitle.prefixedText,
112+
pageTitle.namespace().code(),
113+
Namespace.of(pageTitle.namespace().code()).toString(),
114+
pageSummary?.revision,
115+
pageSummary?.wikiBaseItem,
116+
pageTitle.wikiSite.languageCode
117+
)
118+
}
119+
101120
private fun getPerformerData(): PerformerData {
102121
return PerformerData(
103122
AccountUtil.hashCode(),

app/src/main/java/org/wikipedia/dataclient/okhttp/CommonHeaderRequestInterceptor.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import okhttp3.Interceptor
44
import okhttp3.Response
55
import org.wikipedia.WikipediaApp
66
import org.wikipedia.dataclient.RestService
7-
import org.wikipedia.settings.Prefs.isEventLoggingEnabled
87
import java.io.IOException
98

109
internal class CommonHeaderRequestInterceptor : Interceptor {
@@ -13,8 +12,7 @@ internal class CommonHeaderRequestInterceptor : Interceptor {
1312
val app = WikipediaApp.instance
1413
val builder = chain.request().newBuilder()
1514
.header("User-Agent", app.userAgent)
16-
.header(if (isEventLoggingEnabled) "X-WMF-UUID" else "DNT",
17-
if (isEventLoggingEnabled) app.appInstallID else "1")
15+
.header("X-WMF-UUID", app.appInstallID)
1816
if (chain.request().url.encodedPath.contains(RestService.PAGE_HTML_ENDPOINT)) {
1917
builder.header("Accept", RestService.ACCEPT_HEADER_MOBILE_HTML)
2018
}

0 commit comments

Comments
 (0)