Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pause media upload when internet connection unavailable #19878

Merged
merged 19 commits into from
Jan 10, 2024

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jan 3, 2024

Related

Description

Pause media upload when internet connection is unavailable.

Testing Instructions

See WordPress/gutenberg#56937.

Regression Notes

  1. Potential unintended areas of impact
    Disrupting successful media uploads, breaking other media block types.
  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Uploaded media to various block types.
  3. What automated tests I added (or what prevented me from doing so)
    No, opted to test the JavaScript logic instead.

PR Submission Checklist

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes Testing Checklist

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

This is an exploration. The approach taken, namely using the error type
string, is not fully tested.
@dcalhoun dcalhoun added the Gutenberg Editing and display of Gutenberg blocks. label Jan 3, 2024
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 3, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr19878-e3ad26b
Commite3ad26b
Direct Downloadwordpress-prototype-build-pr19878-e3ad26b.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jan 3, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr19878-e3ad26b
Commite3ad26b
Direct Downloadjetpack-prototype-build-pr19878-e3ad26b.apk
Note: Google Login is not supported on these builds.

@dcalhoun dcalhoun requested a review from derekblank January 3, 2024 20:26
Copy link
Contributor

@derekblank derekblank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcalhoun Thanks for adding this change! I have tested and it is working quite well to update the Image block visuals when offline, as intended. 👍 🙇

I've proposed taking it a step further in #19884 to add a truly discrete onMediaUploadPaused handler. That PR augments this one, and is in the spirit of what I was initially trying to accomplish in #19867.

Let me know your thoughts on using a more discrete paused handler -- if it's valuable, feel free to have full agency to merge or modify that PR here in the interest of optimizing time, or just take any parts that are useful. If not, I feel this PR itself is enough to approve and merge after the next release cut on Jan 8.

Ensure the implementation adheres to the relevant interface.
With the addition of a discrete paused method, we no longer utilize this
parameter in the failed method.
We do not plan to add paused media support to the Aztec editor.
Therefore, it likely makes more sense for the `onMediaUploadPaused`
implementation to merely invoke the existing `onMediaUploadFailed`
method.
Without checking for an error, there may be a possibility that
successfully uploaded media is marked as "paused."
Even though we communicate a nuanced paused state to the user, we likely
need to continue tracking this event as a failure, or consider adding a
discrete pause analytic event.
Based upon existing code, we should consider completed uploads lacking
remote URLs to be failures. Therefore, we should apply the new pause
state to this context.
…ck-upload-visuals__discrete-paused-state

Add discrete onMediaUploadPaused handler to media uploads when offline
@dcalhoun dcalhoun marked this pull request as ready for review January 4, 2024 21:18
@dcalhoun dcalhoun requested a review from derekblank January 4, 2024 21:18
it["error_type"] = error.type.name
}
}
analyticsTrackerWrapper.track(EDITOR_UPLOAD_MEDIA_FAILED, properties)
Copy link
Contributor

@derekblank derekblank Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still send an EDITOR_UPLOAD_MEDIA_FAILED event to analytics when the upload is paused. I believe we'd want to remove these lines, but wanted to double check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought is that we should still track these as errors (or, at least, track something). I referenced this in #19884 (comment). I imagine knowing the rate of this event is still useful for analysis.

Will you expand on why you think we should not?

Copy link
Contributor

@derekblank derekblank Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you expand on why you think we should not?

My reasoning was that it might incorrectly affect the metrics outlined in the pitch, which were aiming to reduce instances of media_service_upload_failed and media_service_upload_response_error. I haven't yet checked to see if media_service_upload_failed results are actually affected by analyticsTrackerWrapper.track(EDITOR_UPLOAD_MEDIA_FAILED, properties), but it seems like it might be.

When the media upload is paused, I think we would expect it to retry and continue when the connection is resumed. If the upload then reached a legitimate failure, it would be captured by onMediaUploadFailed, which would fire the analytics failed event. Does that sound correct?

Either way, I don't think it should be a blocker for this PR. I've created an issue on the project board to discuss adding a paused analytics event.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for elaborating. Your rationale makes complete sense. I had not considered the impact on the planned project metrics.

I agree that we should follow up to remove or change this analytic event. We should also verify that the iOS implementation is correctly set up as well. I'll update your newly created issue to note this.

@derekblank derekblank self-requested a review January 5, 2024 01:11
Copy link
Contributor

@derekblank derekblank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #19878 (comment) about potentially removing the analytics event when the upload is paused. Otherwise, LGTM. 🚀

@wpmobilebot

This comment was marked as off-topic.

@dcalhoun dcalhoun merged commit d1ff96e into trunk Jan 10, 2024
19 checks passed
@dcalhoun dcalhoun deleted the feat/update-image-block-upload-visuals branch January 10, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. Media
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify Image block visuals during offline uploads
3 participants