Skip to content

Commit

Permalink
feat: Prefix editor feedback with tag
Browse files Browse the repository at this point in the history
Indicate the context for feedback submissions originating from the
editor.
  • Loading branch information
dcalhoun committed Jan 15, 2025
1 parent 4e105e1 commit f4bde50
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,13 @@ public static void viewHelp(@NonNull Context context, @NonNull Origin origin, @N
}

public static void viewFeedbackForm(@NonNull Context context) {
viewFeedbackForm(context, null);
}

public static void viewFeedbackForm(@NonNull Context context, @Nullable String feedbackPrefix) {
AnalyticsTracker.track(Stat.APP_REVIEWS_FEEDBACK_SCREEN_OPENED);
Intent intent = new Intent(context, FeedbackFormActivity.class);
intent.putExtra(FeedbackFormActivity.EXTRA_FEEDBACK_PREFIX, feedbackPrefix);
context.startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class FeedbackFormActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val feedbackPrefix = intent.getStringExtra(EXTRA_FEEDBACK_PREFIX)
viewModel.feedbackPrefix = feedbackPrefix

setContentView(
ComposeView(this).apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Expand Down Expand Up @@ -71,4 +74,8 @@ class FeedbackFormActivity : AppCompatActivity() {
}
}
}

companion object {
const val EXTRA_FEEDBACK_PREFIX = "extra_feedback_prefix"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class FeedbackFormViewModel @Inject constructor(
private val _progressDialogState = MutableStateFlow<ProgressDialogState?>(null)
val progressDialogState = _progressDialogState.asStateFlow()

var feedbackPrefix: String? = null

fun updateMessageText(message: String) {
if (message != _messageText.value) {
_messageText.value = message
Expand Down Expand Up @@ -138,12 +140,13 @@ class FeedbackFormViewModel @Inject constructor(
attachmentTokens: List<String> = emptyList()
) {
showProgressDialog(R.string.sending)
val descriptionPrefix = feedbackPrefix?.let { "[$it] " } ?: ""
zendeskHelper.createRequest(
context = context,
origin = HelpActivity.Origin.FEEDBACK_FORM,
selectedSite = selectedSiteRepository.getSelectedSite(),
extraTags = listOf("in_app_feedback"),
requestDescription = _messageText.value,
requestDescription = descriptionPrefix + _messageText.value,
attachmentTokens = attachmentTokens,
callback = object : ZendeskHelper.CreateRequestCallback() {
override fun onSuccess() {
Expand Down Expand Up @@ -303,4 +306,3 @@ class FeedbackFormViewModel @Inject constructor(
private const val MAX_ATTACHMENTS = 5
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ class EditPostActivity : AppCompatActivity(), EditorFragmentActivity, EditorImag
(editorFragment as GutenbergEditorFragment).showEditorHelp()
}
} else if (itemId == R.id.menu_editor_send_feedback) {
ActivityLauncher.viewFeedbackForm(this@EditPostActivity)
ActivityLauncher.viewFeedbackForm(this@EditPostActivity, "Editor")
} else if (itemId == R.id.menu_undo_action) {
if (editorFragment is GutenbergEditorFragment) {
(editorFragment as GutenbergEditorFragment).onUndoPressed()
Expand Down

0 comments on commit f4bde50

Please sign in to comment.