8000 PM-11215 - Build Debug Menu by phil-livefront · Pull Request #941 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PM-11215 - Build Debug Menu #941

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

Merged
merged 21 commits into from
Sep 20, 2024
Merged

Conversation

phil-livefront
Copy link
Collaborator
@phil-livefront phil-livefront commented Sep 17, 2024

🎟️ Tracking

PM-11215

📔 Objective

  • Build a debug menu that is only accessible from debug builds when you triple tap any screen with 3 fingers or a shake gesture
  • Currently allows for feature flag toggling but this can be used for other configurations moving forward
  • Allows for the ability to override a boolean feature flag value so you can easily test different flags without them needing to be remotely configured.
  • Also added in a refresh button to go back to the defaults
  • For the demo video below, using the simulator only allows for 2 mutli-taps at a time but we have it set to 3 and made sure this worked on device

📸 Screenshots

Simulator Screenshot - iPhone 15 Pro - 2024-09-17 at 09 27 32

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-17.at.09.26.17.mp4

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor
github-actions bot commented Sep 17, 2024

Logo
Checkmarx One – Scan Summary & Details13093b43-cc01-4a31-8770-fde9f7cab728

No New Or Fixed Issues Found

Copy link
codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 91.56627% with 21 lines in your changes missing coverage. Please review.

Project coverage is 88.74%. Comparing base (a26d0c7) to head (8474fd8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Bitwarden/Application/SceneDelegate.swift 69.69% 10 Missing ⚠️
...rdenShared/UI/Platform/DebugMenu/ShakeWindow.swift 36.36% 7 Missing ⚠️
...Shared/Core/Platform/Models/Enum/FeatureFlag.swift 87.50% 3 Missing ⚠️
...nShared/Core/Platform/Services/ConfigService.swift 97.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   88.72%   88.74%   +0.02%     
==========================================
  Files         631      638       +7     
  Lines       39753    39993     +240     
==========================================
+ Hits        35269    35491     +222     
- Misses       4484     4502      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@KatherineInCode
Copy link
Contributor

🤔 Having the gesture for the debug menu be something that can't be done on the simulator is weird to me. Wouldn't it be better to have something that doesn't require a physical device? Or is the expectation that if we need the debug menu locally we'll go and change the gesture?

Also of note: Debug builds are only built for dev locally with Xcode. Any build in TestFlight is a Release build, so this will only be usable by devs and not QA.

/// - Returns: The value of the feature flag as the specified type `T`, or `nil` if the flag does not exist
/// or cannot be decoded.
///
func featureFlag(name: String) -> Bool?
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ The docs indicate that it's a generic type T, but all we have here is Bool. This also means we don't have overrides for Int or String flags.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch, yeah for now I kept them as booleans but I can add capability for other types. I just didn't want to hold this up for testing the onboarding flow but I can certainly tackle that. Would another ticket be okay with you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Future tickets for the additional types is reasonable to keep this a bit smaller and focused.

/// - value: The boolean value to assign to the feature flag. If `nil`, the feature flag will be removed
/// from the settings store.
///
func setFeatureFlag(name: String, value: Bool?)
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 If we're gating using these functions behind an #if DEBUG, wouldn't it make sense to also gate these functions and attendant code?

(Other discussion about whether we want to #if DEBUG aside)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah that a great call too, no need to have these functions available unless they are needed.

@phil-livefront
Copy link
Collaborator Author

🤔 Having the gesture for the debug menu be something that can't be done on the simulator is weird to me. Wouldn't it be better to have something that doesn't require a physical device? Or is the expectation that if we need the debug menu locally we'll go and change the gesture?

Also of note: Debug builds are only built for dev locally with Xcode. Any build in TestFlight is a Release build, so this will only be usable by devs and not QA.

Yeah I agree, the ticket stated to use the gesture so I went with that but we could add another vessel to open it as well. Do you have any that would be useful? I've done a shake gesture before, which can be used in the simulator, or also triple tapping specific images, etc.

@@ -187,6 +203,10 @@ class DefaultConfigService: ConfigService {
return configuration?.featureStates[flag]?.stringValue ?? defaultValue
}

func getRemoteFeatureFlags() async -> [FeatureFlag: AnyCodable] {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Does it make sense to also gate this behind the DEBUG_MENU flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, good call out. That would make the most sense to me to avoid any issues in release builds

@KatherineInCode
Copy link
Contributor

we could add another vessel to open it as well

I don't have any good ideas for it, unfortunately; the way apps I've worked on in the past handled debug screens and the like was through other means. The three-finger triple tap is probably reasonable enough, and if we need to access the debug menu in the simulator we could just manually update it to five two-finger taps or something like that. In practice, it's probably moot.

@@ -121,4 +131,21 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
private func showSplash() {
splashWindow?.alpha = 1
}

/// Handle the triple-tap gesture and launch the debug menu.
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Can probably gate this behind DEBUG_MENU as well

@@ -1,4 +1,6 @@
#include "./Common.xcconfig"
#include? "./Local.xcconfig"

BITWARDEN_FLAGS = DEBUG_MENU
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 If we have it in Shared, it doesn't need to be in both Debug and Release, and potentially defeats the point of gating it?

@@ -5,6 +5,8 @@ CODE_SIGN_IDENTITY = Apple Development
#include? "./Local.xcconfig"

ASSETCATALOG_COMPILER_APPICON_NAME = $(APPICON_NAME)
BITWARDEN_FLAGS = DEBUG_MENU
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Is the intention that this would be overridden with some other flags locally on some CI builds? How would we, ideally, know whether or not a build on CI should or should not have the debug menu at build time?

Copy link
Member
@fedemkr fedemkr left a comment

Choose a reason for hiding this comment

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

🤔 Are the changes needed in the CI/CD pipeline going to be in a different PR? So that we can modify Configs/Base-Release.xcconfig to introduce the flag for internal release builds.

@phil-livefront
Copy link
Collaborator Author

🤔 Are the changes needed in the CI/CD pipeline going to be in a different PR? So that we can modify Configs/Base-Release.xcconfig to introduce the flag for internal release builds.

Right now the intention is to have builds from the Livefront CI/CD to update the builds with the flag so QA can begin testing the onboarding flow. I wanted to have the structure in place when the Bitwarden CI/CD wants to implement this. Since beta builds go out to users we haven't come to a conclusion on how to handle that just yet but getting the builds with the menu will allow QA to test the new features. Does that make sense or am i being confusing?

@KatherineInCode
Copy link
Contributor

🤔 Are the changes needed in the CI/CD pipeline going to be in a different PR? So that we can modify Configs/Base-Release.xcconfig to introduce the flag for internal release builds.

We wouldn't want to modify that xcconfig file in the pipeline, though. We'd want to add something to Local.xcconfig after we set the variant, which creates that file. We could also theoretically pass whether or not to do it at that point.

The real issue is that if we don't want this shipping to users, then we can't put it in any CI/CD pipeline builds unless we know for sure that particular build isn't going to be promoted, since the builds that "are uploaded to TestFlight" are the same ones we'd pull from to decide what to release.

In past apps I've worked on, we had a separate build variant (parallel to our prod variant) specifically for QA that had these sorts of debugging things turned on, because it's much easier to say "prod has debug menu off, qa has debug menu on". This solves the problem relatively nicely (though QA is then not necessarily actually testing the artifact that's going to be released to the public). However, because both our Prod variant and Beta variant go to users, we can't use them in this manner; we'd either have to stop releasing Beta to users or create a different variant that's only used internally by QA.

Copy link
Collaborator
@matt-livefront matt-livefront left a comment

Choose a reason for hiding this comment

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

Looks good!

@phil-livefront phil-livefront merged commit 72cc8bd into main Sep 20, 2024
9 checks passed
@phil-livefront phil-livefront deleted the phil/PM-11215-build-debug-menu branch September 20, 2024 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0