8000 BIT-2415: Send org events by KatherineInCode · Pull Request #739 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BIT-2415: Send org events #739

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 19 commits into from
Jul 19, 2024
Merged

BIT-2415: Send org events #739

merged 19 commits into from
Jul 19, 2024

Conversation

KatherineInCode
Copy link
Contributor
@KatherineInCode KatherineInCode commented Jul 16, 2024

🎟️ Tracking

https://livefront.atlassian.net/browse/BIT-2415

📔 Objective

This adds a five-minute timer to the AppProcessor that regularly sends accumulated organization events (if there are any to send). As well, if the app is backgrounded, events are sent immediately and the timer is stopped, then restarted on foregrounding.

There were issues with testing AppProcessor particularly. As near as I can tell, because the MockNotificationCenterService uses a CurrentValueSubject for its mock, when the Task objects in AppProcessor.init() are created and subscribe, the current value (Void) is emitted, triggering the foreground and background blocks to run.

This means firstly that any tests that rely on e.g. notificationCenterService.didEnterBackgroundSubject.send() can have that line taken out and have the test still pass, because in this example didEnterBackgroundSubject is getting triggered on initialization. And secondly, that tests that rely on validating a series of events—namely, backgrounding then foregrounding the app—have nondeterministic results.

I attempted several solutions to this—adding a dropFirst to the subject, turning the subject into a PassthroughSubject, and various incarnations of Task manipulation in the tests—to no avail. At best I could get nondeterministic results.

As a result, I only have a test for the init currently, and not other scenarios. Given that this is an effective singleton object, I'm not especially concerned, but it would be nice to find a way to test the app background/foregrounding in the future.

The missing lines in the CodeCov report are, as near as I can tell, an issue with Xcode.

⏰ 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 Jul 16, 2024

Logo
Checkmarx One – Scan Summary & Details1e27ed97-fd6e-4e51-bce1-1f83aeeae890

No New Or Fixed Issues Found

Copy link
codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 83.92857% with 9 lines in your changes missing coverage. Please review.

Project coverage is 88.17%. Comparing base (890880b) to head (2efd02a).

Files Patch % Lines
...nShared/UI/Platform/Application/AppProcessor.swift 73.07% 7 Missing ⚠️
.../Platform/Services/API/Requests/EventRequest.swift 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
- Coverage   88.18%   88.17%   -0.01%     
==========================================
  Files         575      577       +2     
  Lines       28734    28789      +55     
==========================================
+ Hits        25339    25385      +46     
- Misses       3395     3404       +9     

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

@KatherineInCode KatherineInCode marked this pull request as ready for review July 16, 2024 21:18
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.

Great work! About the two lines in the EventRequest missing tests by Codecov you can find an example here


/// Starts timer to send organization events regularly
private func startEventTimer() {
sendEventTimer = Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { _ in
Copy link
Member

Choose a reason for hiding this comment

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

🤔 In MAUI this is configured to happen every 60seconds for iOS, 5min is for Android. Was this changed to unify the platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ticket I was going off of indicated that it was five minutes, so I was going off of that. The Slack discussions I've been able to dig up don't provide any more illumination for me.

Copy link
Member

Choose a reason for hiding this comment

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

Just asked in Slack to see what's the correct expected value.

@KatherineInCode
Copy link
Contributor Author

Great work! About the two lines in the EventRequest missing tests by Codecov you can find an example here

The thing is, I'm doing that and it's not getting picked up.

matt-livefront
matt-livefront previously approved these changes Jul 18, 2024
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 great!

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.

Looks good! The only caveat is whether the timing is correct. Approving so you don't need to keep merging main into it, we can always adjust the timing in a future PR.

@KatherineInCode KatherineInCode merged commit 90f3513 into main Jul 19, 2024
8 checks passed
@KatherineInCode KatherineInCode deleted the bit-2415/send-org-events branch July 19, 2024 17:15
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.

3 participants
0