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

Add new feature flag for lock screen widgets in Jetpack #20309

Conversation

tzef
Copy link
Contributor

@tzef tzef commented Mar 13, 2023

Related to: #19411

This is the first PR for adding the stats widget to the lock screen

  1. Add new feature flag for lock screen widgets in Jetpack  #20309 (✅ Approved) 👈 you're here!
  • Update compilation flag to AppConfiguration.isJetpack
  1. Implement lock screen widgets UI #20312 (✅ Approved)
  2. Add dynamic type support #20342 (TBD)
  3. Add localizable string for "Views Today" title #20353 (✅ Approved)
  4. [BugFix] Fix widget of home screen for WordPress disappeared #20371 (✅ Approved)
  5. Extract content logic to config from lock screen widget #20317 (✅ Approved)
  6. Create a standalone TimeLineProvider and TimelineEntry for the lock screen  #20368 (✅ Approved)
  7. Implement view for logged-out, no-site, and no-data status #20399 (✅ Approved)
  8. Notify to reload the timelines for lock screen widget #20405 (✅ Approved)
    (Confirm the data display on UI correctly in this phase)
  9. Implement event tracking for the new lock screen widget  #20422 (✅ Approved)
  10. Disable lockScreenWidget feature flag #20427 (In Reviewing)

Description

  1. Add a new feature flag lockScreenWidget to protect the following change from being released before it is verified.
    Set the canOverride to false because the widget list updates along with the app installation.
    Dynamic changes of the flag do not work.

  2. Add JETPACK_STATS_WIDGETS compilation condition Update to AppConfiguration.isJetpack to allow the lock screen widget to be added only for the Jetpack target.

  3. Add a new widget kind "WordPressLockScreenWidgetTodayViews" for the first style widget

  4. Add a new empty widget for testing

Images & Videos

Jetpack in add widgets New widget in selection page
JetpackInLockScreen JetpackWidgetSelection

Testing instructions

  • When the feature flag on, should be able to see Jetpack and add the new widget to lock screen.
  • When the feature flag on, shouldn't see the WordPress in widget selection
  • When the feature flag off, shouldn't see the Jetpack and WordPress in widget selection

Regression Notes

  1. Potential unintended areas of impact
    Existing widgets in WordPress/Jetpack

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  • Added existing home screen widgets first, it works well after setting up new widgets.
  • After setting up new widgets, adding existing home screen widgets flow won't be impacted
  1. What automated tests I added (or what prevented me from doing so)
    N/A

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • 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.

@tzef tzef marked this pull request as draft March 13, 2023 06:37
@tzef tzef changed the base branch from trunk to feature/19411-add-lock-screen-stats-widgets March 13, 2023 09:57
@tzef tzef marked this pull request as ready for review March 13, 2023 10:05
@staskus staskus self-requested a review March 13, 2023 11:53
@peril-wordpress-mobile
Copy link

Warnings
⚠️ PR is not assigned to a milestone.

Generated by 🚫 dangerJS

@staskus
Copy link
Contributor

staskus commented Mar 14, 2023

@tzef thank you for making this PR! I will review it soon today.

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Thanks! Congrats on the first PR! 🚀

The widget appears on the lock screen, and the PR description is clear. 👍

I proposed a change to simplify the solution and introduce the usage of the feature flag. Let me know what you think 👍.

@@ -25394,7 +25422,7 @@
PROVISIONING_PROFILE_SPECIFIER = "Jetpack iOS Development Stats Widget";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Jetpack iOS Development Stats Widget";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG JETPACK_STATS_WIDGETS";
Copy link
Contributor

Choose a reason for hiding this comment

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

Although I think such solution would be generally fine, I think for now it's better to add the flag to AppConfiguration, there are 2 for both Jetpack and WordPress apps. It's also not a perfect solution what we want to improve but it's better to keep consistency for now.

Does it sound okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! using AppConfiguration is absolutely better than the compilation flag.
The IDE setup is implicit, not a good solution for toggling the feature.

I didn't notice that AppConfiguration could be used, thanks for the suggestions.

@@ -7,5 +7,10 @@ struct WordPressStatsWidgets: WidgetBundle {
WordPressHomeWidgetToday()
WordPressHomeWidgetThisWeek()
WordPressHomeWidgetAllTime()
#if JETPACK_STATS_WIDGETS
if #available(iOS 16.0, *) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above, something like this could be used to avoid creating a configuration

Suggested change
if #available(iOS 16.0, *) {
if AppConfiguration.isJetpack, #available(iOS 16.0, *) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's great, better than my existing solution 👍.

}
.configurationDisplayName(LocalizableStrings.todayWidgetTitle)
.description(LocalizableStrings.todayPreviewDescription)
.supportedFamilies(FeatureFlag.lockScreenWidget.enabled ? [.accessoryRectangular] : [])
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, is this [.accessoryRectangular] the line that enables the widget to appear on the lock screen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, accessoryRectangular, accessoryInline, and accessoryCircular can appear in watchOS or on the Lock Screen in iOS.

So another solution is we can just extend existing widget support by adding accessoryRectangular,
and provide the view based on the currently family, but that's not good for scalable when more widgets in the future :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for explaining!

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, looks good to me! 🚀

@staskus staskus merged commit 3076db8 into wordpress-mobile:feature/19411-add-lock-screen-stats-widgets Mar 15, 2023
staskus added a commit that referenced this pull request Sep 4, 2023
* Add new feature flag for lock screen widgets in Jetpack  (#20309)

* Add new feature flag for widget in lock screen

* Add new widget kind to widget configuration

* Add empty lock screen widget

* Add JETPACK_STATS_WIDGETS compilation condition

To prevent lock screen widgets from displaying on WordPress target

* Move LockScreenStatsWidgetsView to views folder group

* Revert compilation condition, change to isJetpack of AppCondiguration

* Implement lock screen widgets UI (#20312)

* Extract statsUrl from private to extension for reusable with lock screen widget

* Implement single stat view for today views widget

Add view provider for handling building view for site selected status
Add ViewModelMapper for converting viewModel from home widget data

* Update LockScreenStatsWidgetsView body to get the view from view provider

* Add mapper test to verify the viewModel converting from widget data correctly

Add mapper and viewModel to WordPress target because app extension is not able to run unitTest

* Fix getStatsURL typo

* Add localizable string for "Views Today" title (#20353)

* Add views in today localizable string for footer label

* Remove dateRange and footer, only title is enough for existing feature

* Fix home screen widget for WordPress target disappeared. (#20371)

The root cause is the WidgetBundleBuilder body doesn't allow control flow statements, move it to supportedFamilies with feature flag to keep all control logic in the same place

* Extract content logic to config from lock screen widget (#20317)

* Update title of view provider from hardcoded to pass from config

* Add lock screen stats widget config and implementation to include required information

* Pass config to LockScreenStatsWidget

Replaced the hardcoded data with config properties

* Add associated type view for other status and TODO comments

* Extract app configuration and feature flag check into config

* Create a standalone TimeLineProvider and TimelineEntry for the lock screen  (#20368)

* Add widget data and timeline entry for lock screen to separate concerns

* Add lock screen time line provider for lock screen stats widget entry

Update stats widgets service result type to consist of home widget and lock screen widget for reusable

* Update to use LockScreenSiteListProvider in LockScreenStatsWidget

Update associated type widget data to conform `LockScreenStatsWidgetData` more

Update model mapper and view provider to based on lock screen widget data

Remove unnecessary `disabled` status from `LockScreenStatsWidgetsView`

Remove unnecessary `widgetKind` parameter from `LockScreenStatsWidget`

Remove unused statsURL converter from the view model mapper

Add home widget data conform lock screen widget data extension to WordPress target for unitTest

* Extract widget load data to loader for sharing with lock screen time line provider

* Update widget reader to extract the cache read from getSnapshot

* Extract noData, noSite, loggedOut, disabled status checking logic to data reader with status callback

* Add unitTest for widget data reader

Extract cache reading to `HomeWidgetDataFileReader` for mocking the testing object

Extract app configuration is jetpack to parameter for mocking the config

* Remove multiple space lines

* Update multiple callback to Result and enum Error

* Implement view for logged-out, no-site, and no-data status (#20399)

* Add unconfigured view for lockscreen widget

* Add unconfigured view model to view provider and model mapper

* Add unconfigured view model unit test

* Add background to unconfigured view align with success status widget appearance

* Remove todo comments

* Add reload timelines for lock screen widget (#20405)

* Implement event tracking for the new lock screen widget  (#20422)

* Add event key to configuration and pass to trackers in lockscreen widget

Expand tracks for lockscreen stats entry

Add rectangular widgets count and widgets update of the new widget

* Add lockscreen_widget source to deeplink tracked

Update statsUrl to widgetUrl for separating the url from homescreen widgets

* Update unitTests

* Remove separate widget url, move widget source from widget data extension

Add widget source type, assign the type in widgetURL in the view

* Add widget url source test to verify the converting with DeepLinkSource

* Disable the feature flag (#20427)

---------

Co-authored-by: Beemo Lee <tzef8220@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants