-
Notifications
You must be signed in to change notification settings - Fork 134
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
RUMM-1455 Add Session Start Callback #590
Conversation
This PR also surface API from recent PRs. Let me know if I should revert that! |
c19a626
to
840ba8d
Compare
@@ -254,6 +254,11 @@ public class DDConfigurationBuilder: NSObject { | |||
_ = sdkBuilder.set(rumSessionsSamplingRate: rumSessionsSamplingRate) | |||
} | |||
|
|||
@objc | |||
public func set(onSessionStart handler: @escaping (String, Bool) -> Void) { |
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.
Nice 👌, let's also add smoke test for this new API here.
@@ -87,6 +92,7 @@ internal class RUMApplicationScope: RUMScope, RUMContextProvider { | |||
private func refresh(expiredSession: RUMSessionScope, on command: RUMCommand) { | |||
let refreshedSession = RUMSessionScope(from: expiredSession, startTime: command.time) | |||
sessionScope = refreshedSession | |||
sessionScopeDidUpdate(refreshedSession) |
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.
We have no test coverage for this case - test added in RUMMonitorTests
only checks the callback for initial session. Both "initial" and "refreshed" sessions are already tested in RUMApplicationScopeTests
and I think we could add tests for both callback situations there as well, WDYT?
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.
Yes, I agree 👍
/// (when `true` it means no event in this session will be kept). | ||
/// | ||
/// - Parameter handler: the callback handler to notify whenever a new Session starts. | ||
public func onSessionStart(_ handler: @escaping (String, Bool) -> Void) -> Builder { |
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.
- About the naming - as this is a RUM feature, I think it's worth expressing it from the name as we do for other RUM options. How about
onRUMSessionStart
? - About testing - it also requires updating tests in
DatadogConfigurationBuilderTests
(we cover all public options in there)
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.
🏅
What and why?
Adds an optional
onSessionStart
callback toRUMApplicationScope
to be called when a new session starts. The callback takes 2 arguments: the newly started Session ID and a boolean indicating whether or not the session is discarded by the sampling rate (whentrue
it means no event in this session will be kept).Fix #526
Review checklist