-
Notifications
You must be signed in to change notification settings - Fork 142
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
✨[RUMF-430] new session strategy #343
Conversation
session automatically expires after 4h
do not rely on browser expiration mechanism allow to test this logic
8a64820
to
3ac7581
Compare
add missing monitor
Codecov Report
@@ Coverage Diff @@
## master #343 +/- ##
==========================================
+ Coverage 86.79% 87.26% +0.46%
==========================================
Files 29 29
Lines 1621 1672 +51
Branches 333 344 +11
==========================================
+ Hits 1407 1459 +52
+ Misses 214 213 -1
Continue to review full report at Codecov.
|
) | ||
} | ||
|
||
function trackVisibility(expandSession: () => void, visibilityStateProvider: () => VisibilityState) { |
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.
IMO
trackVisibility
should expose anObservable
instead of a callback function- be self contained: no
visibilityStateProvider
, usedocument.visibilityState
directly. We can mockdocument.visibilityState
in tests
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.
trackVisibility should expose an Observable instead of a callback function
what advantage do you see with it?
We can mock document.visibilityState in tests
How would you do that?
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 advantage do you see with it?
I think having a common strategy to pass data streams around would make things more future-proof. For now, our Observable implementation is quite limited, but in the future it could be extendend with a "destructor" when unused (example), and we would have a common way to remove listeners and stuff. This would make functions like this more self-contained and easier to test.
But if you feel that this is thinking too far ahead, I'm okay to keep a callback for now :)
How would you do that?
Object.defineProperty(document, 'visibilityState', { get() { return "zog" }, configurable: true })
// then
delete document.visibilityState
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 observable instead of callbacks, I am not sure that observable pattern should be enforce in every situation.
I think it:
- allow us to easily reuse a data source in another part of the code
- can help us to decouple some of the browser API to the domain logic
But it also adds an extra layer of abstraction.
About future-proof arguments, let's see when we will have the need to do more complicated stuff with our observable and address it at this time.
In this case, I am not sure to see much benefit to switch to observable.
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.
OK
Motivations
Changes
Behind the 'new-session' flag: