Skip to content

Commit 3bb2201

Browse files
committed
Add analytics tracking to EditorLauncher
Tracks editor launches with should_use_gutenberg_kit property to understand feature flag usage patterns.
1 parent 965c2cd commit 3bb2201

File tree

3 files changed

+16
-51
lines changed

3 files changed

+16
-51
lines changed

WordPress/src/main/java/org/wordpress/android/ui/posts/EditorLauncher.kt

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package org.wordpress.android.ui.posts
33
import android.content.Context
44
import android.content.Intent
55
import org.wordpress.android.WordPress.Companion.getContext
6-
import org.wordpress.android.util.AppLog
7-
import org.wordpress.android.util.AppLog.T
86
import org.wordpress.android.ui.prefs.experimentalfeatures.ExperimentalFeatures
97
import org.wordpress.android.ui.prefs.experimentalfeatures.ExperimentalFeatures.Feature
108
import org.wordpress.android.util.config.GutenbergKitFeature
119
import org.wordpress.android.util.analytics.AnalyticsUtils
1210
import org.wordpress.android.WordPress
11+
import org.wordpress.android.analytics.AnalyticsTracker
12+
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
1313
import javax.inject.Inject
1414
import javax.inject.Singleton
1515

@@ -22,9 +22,9 @@ import javax.inject.Singleton
2222
@Singleton
2323
class EditorLauncher @Inject constructor(
2424
private val gutenbergKitFeature: GutenbergKitFeature,
25-
private val experimentalFeatures: ExperimentalFeatures
25+
private val experimentalFeatures: ExperimentalFeatures,
26+
private val analyticsTrackerWrapper: AnalyticsTrackerWrapper
2627
) {
27-
2828
companion object {
2929
/**
3030
* Static accessor for use in static utility classes like ActivityLauncher.
@@ -50,20 +50,16 @@ class EditorLauncher @Inject constructor(
5050
// Will route to EditPostGutenbergKitActivity when it exists
5151
val targetActivity = EditPostActivity::class.java
5252

53-
val editorType = if (shouldUseGutenbergKit) "gutenberg_kit" else "legacy"
54-
val source = getParamsSource(params)
55-
56-
AppLog.d(T.EDITOR, "EditorLauncher: routing to $editorType editor from $source")
57-
58-
// Track launch method for analytics
59-
trackEditorLaunch(editorType, source, "helper")
53+
val properties = mapOf(
54+
"should_use_gutenberg_kit" to shouldUseGutenbergKit
55+
)
56+
analyticsTrackerWrapper.track(stat = AnalyticsTracker.Stat.EDITOR_LAUNCHER, properties)
6057

6158
return Intent(context, targetActivity).apply {
6259
addEditorExtras(params)
6360
}
6461
}
6562

66-
6763
/**
6864
* Determines if GutenbergKit editor should be used based on feature flags.
6965
*/
@@ -74,25 +70,6 @@ class EditorLauncher @Inject constructor(
7470
return isGutenbergEnabled && !isGutenbergDisabled
7571
}
7672

77-
/**
78-
* Identifies the source of the editor launch based on EditorLauncherParams.
79-
*/
80-
private fun getParamsSource(params: EditorLauncherParams): String {
81-
return when {
82-
params.isQuickPress -> "quickpress"
83-
params.reblogPostTitle != null -> "reblog"
84-
params.insertMedia != null -> "media_upload"
85-
params.reblogAction != null -> "reblog_action"
86-
params.isLandingEditor -> "landing_editor"
87-
params.isPromo -> "promo"
88-
params.isPage -> "page"
89-
params.postLocalId != null || params.postRemoteId != null -> "edit_post"
90-
params.source != null -> params.source.toString().lowercase()
91-
else -> "new_post"
92-
}
93-
}
94-
95-
9673
/**
9774
* Adds all editor parameters as Intent extras.
9875
*/
@@ -143,18 +120,4 @@ class EditorLauncher @Inject constructor(
143120
params.promptId?.let { putExtra(EditPostActivityConstants.EXTRA_PROMPT_ID, it) }
144121
params.entryPoint?.let { putExtra(EditPostActivityConstants.EXTRA_ENTRY_POINT, it) }
145122
}
146-
147-
/**
148-
* Track editor launch events for analytics.
149-
*/
150-
private fun trackEditorLaunch(editorType: String, source: String, launchMethod: String) {
151-
val properties = mapOf(
152-
"editor_type" to editorType,
153-
"source" to source,
154-
"launch_method" to launchMethod
155-
)
156-
157-
// Analytics tracking will be implemented with appropriate event name
158-
AppLog.i(T.EDITOR, "Editor launch tracked: $properties")
159-
}
160123
}

WordPress/src/main/java/org/wordpress/android/ui/posts/EditorLauncherParams.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package org.wordpress.android.ui.posts
22

3-
import androidx.annotation.NonNull
43
import org.wordpress.android.ui.PagePostCreationSourcesDetail
54
import org.wordpress.android.fluxc.model.SiteModel
65
import org.wordpress.android.ui.posts.PostUtils.EntryPoint
76

87
/**
98
* Type-safe parameters for launching editor activities.
10-
*
9+
*
1110
* This data class replaces the Bundle-based approach with named parameters in Kotlin
1211
* and provides a builder pattern for Java compatibility.
1312
*/
@@ -35,11 +34,11 @@ data class EditorLauncherParams(
3534
val promptId: Int? = null,
3635
val entryPoint: EntryPoint? = null
3736
) {
38-
37+
3938
/**
4039
* Java-friendly builder pattern for EditorLauncherParams.
4140
*/
42-
class Builder(@NonNull private val site: SiteModel) {
41+
class Builder(private val site: SiteModel) {
4342
private var isPage: Boolean = false
4443
private var isPromo: Boolean = false
4544
private var postLocalId: Int? = null
@@ -61,19 +60,21 @@ data class EditorLauncherParams(
6160
private var source: PagePostCreationSourcesDetail? = null
6261
private var promptId: Int? = null
6362
private var entryPoint: EntryPoint? = null
64-
63+
6564
fun isPage(isPage: Boolean) = apply { this.isPage = isPage }
6665
fun isPromo(isPromo: Boolean) = apply { this.isPromo = isPromo }
6766
fun postLocalId(postLocalId: Int?) = apply { this.postLocalId = postLocalId }
6867
fun postRemoteId(postRemoteId: Long?) = apply { this.postRemoteId = postRemoteId }
6968
fun loadAutoSaveRevision(loadAutoSaveRevision: Boolean) = apply {
7069
this.loadAutoSaveRevision = loadAutoSaveRevision
7170
}
71+
7272
fun isQuickPress(isQuickPress: Boolean) = apply { this.isQuickPress = isQuickPress }
7373
fun isLandingEditor(isLandingEditor: Boolean) = apply { this.isLandingEditor = isLandingEditor }
7474
fun isLandingEditorOpenedForNewSite(isLandingEditorOpenedForNewSite: Boolean) = apply {
7575
this.isLandingEditorOpenedForNewSite = isLandingEditorOpenedForNewSite
7676
}
77+
7778
fun reblogPostTitle(reblogPostTitle: String?) = apply { this.reblogPostTitle = reblogPostTitle }
7879
fun reblogPostQuote(reblogPostQuote: String?) = apply { this.reblogPostQuote = reblogPostQuote }
7980
fun reblogPostImage(reblogPostImage: String?) = apply { this.reblogPostImage = reblogPostImage }
@@ -87,7 +88,7 @@ data class EditorLauncherParams(
8788
fun source(source: PagePostCreationSourcesDetail?) = apply { this.source = source }
8889
fun promptId(promptId: Int?) = apply { this.promptId = promptId }
8990
fun entryPoint(entryPoint: EntryPoint?) = apply { this.entryPoint = entryPoint }
90-
91+
9192
fun build(): EditorLauncherParams {
9293
return EditorLauncherParams(
9394
site = site,

libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ public enum Stat {
209209
POST_LIST_TAB_CHANGED,
210210
POST_LIST_VIEW_LAYOUT_TOGGLED,
211211
POST_LIST_SEARCH_ACCESSED,
212+
EDITOR_LAUNCHER,
212213
EDITOR_CLOSED,
213214
EDITOR_SESSION_START,
214215
EDITOR_SESSION_SWITCH_EDITOR,

0 commit comments

Comments
 (0)