-
Notifications
You must be signed in to change notification settings - Fork 53
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
Conversation
No New Or Fixed Issues Found |
Codecov ReportAttention: Patch coverage is
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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
BitwardenShared/Core/Platform/Services/API/E
8000
ventAPIService.swift
Outdated
Show resolved
Hide resolved
BitwardenShared/Core/Platform/Services/API/Requests/EventRequest.swift
Outdated
Show resolved
Hide resolved
The thing is, I'm doing that and it's not getting picked up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this 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.
🎟️ 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 theMockNotificationCenterService
uses aCurrentValueSubject
for its mock, when theTask
objects inAppProcessor.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 exampledidEnterBackgroundSubject
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 aPassthroughSubject
, and various incarnations ofTask
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
🦮 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