-
-
Notifications
You must be signed in to change notification settings - Fork 363
fix(session-tracker): add session start for SDK start after didBecomeActive #5121
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
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.
@philprime it would be great if we could first have a PR to only fix the problem that the SDK doesn't start a session when it's started after didBecomeActive to keep the change small. I think that's a standalone improvement that has nothing to do with SR.
@philipphofmann I agree, it seems like somehow other changes leaked into the PR during rebasing |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5121 +/- ##
=============================================
+ Coverage 86.179% 86.291% +0.112%
=============================================
Files 399 399
Lines 34616 34819 +203
Branches 14972 15111 +139
=============================================
+ Hits 29832 30046 +214
+ Misses 4739 4733 -6
+ Partials 45 40 -5
... and 21 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
c21082a | 1215.02 ms | 1243.19 ms | 28.17 ms |
02e1163 | 1199.86 ms | 1211.78 ms | 11.92 ms |
ed49f0c | 1215.94 ms | 1245.63 ms | 29.69 ms |
742d4b6 | 1204.00 ms | 1217.90 ms | 13.90 ms |
39f4c2a | 1222.19 ms | 1230.60 ms | 8.42 ms |
66922ca | 1221.68 ms | 1235.98 ms | 14.30 ms |
1bbcb9c | 1214.25 ms | 1230.04 ms | 15.79 ms |
1a4da1b | 1222.14 ms | 1239.50 ms | 17.36 ms |
f938d24 | 1223.26 ms | 1242.12 ms | 18.86 ms |
3bf3c92 | 1236.94 ms | 1253.00 ms | 16.06 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
c21082a | 22.30 KiB | 846.15 KiB | 823.84 KiB |
02e1163 | 21.58 KiB | 418.82 KiB | 397.24 KiB |
ed49f0c | 21.58 KiB | 632.13 KiB | 610.55 KiB |
742d4b6 | 21.58 KiB | 546.20 KiB | 524.61 KiB |
39f4c2a | 23.75 KiB | 846.88 KiB | 823.13 KiB |
66922ca | 20.76 KiB | 425.80 KiB | 405.04 KiB |
1bbcb9c | 20.76 KiB | 426.10 KiB | 405.34 KiB |
1a4da1b | 21.58 KiB | 418.33 KiB | 396.75 KiB |
f938d24 | 20.76 KiB | 434.88 KiB | 414.12 KiB |
3bf3c92 | 21.58 KiB | 706.06 KiB | 684.48 KiB |
Previous results on branch: philprime/issue-5069
Startup times
Revision | Plain | With Sentry | Diff |
---|---|---|---|
927261d | 1210.24 ms | 1238.59 ms | 28.35 ms |
b5d1c3d | 1231.00 ms | 1255.47 ms | 24.47 ms |
bc06793 | 1231.04 ms | 1247.98 ms | 16.94 ms |
4deddc5 | 1220.81 ms | 1234.41 ms | 13.60 ms |
6996d49 | 1213.72 ms | 1231.27 ms | 17.55 ms |
334d6f2 | 1202.65 ms | 1232.21 ms | 29.56 ms |
5be643e | 1217.51 ms | 1246.15 ms | 28.64 ms |
7ba9cd4 | 1227.26 ms | 1258.63 ms | 31.37 ms |
825200b | 1200.16 ms | 1227.76 ms | 27.59 ms |
9c7c623 | 1231.18 ms | 1249.28 ms | 18.09 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
927261d | 23.75 KiB | 843.32 KiB | 819.57 KiB |
b5d1c3d | 23.75 KiB | 841.30 KiB | 817.55 KiB |
bc06793 | 23.75 KiB | 847.75 KiB | 824.00 KiB |
4deddc5 | 23.76 KiB | 822.08 KiB | 798.32 KiB |
6996d49 | 23.75 KiB | 847.75 KiB | 824.00 KiB |
334d6f2 | 23.75 KiB | 838.54 KiB | 814.79 KiB |
5be643e | 23.76 KiB | 820.06 KiB | 796.30 KiB |
7ba9cd4 | 23.75 KiB | 847.86 KiB | 824.12 KiB |
825200b | 23.75 KiB | 847.90 KiB | 824.15 KiB |
9c7c623 | 23.76 KiB | 822.00 KiB | 798.24 KiB |
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.
There are a few tests failing. Either something is wrong with the test setup or the session logic is broken.
…5343) Co-authored-by: Philipp Hofmann <philipp.hofmann@sentry.io> Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io>
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.
Thanks for doing this work, some nice improvements in here. There are a couple test cases I wanted to understand better but these are the rest of the comments I have.
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.
Thanks for doing this. I found one potential major problem for the hybrid SDKs and another potential problem creating abnormal sessions. This is close to LGTM.
Tests/SentryTests/Integrations/Session/SentrySessionTrackerTests.swift
Outdated
Show resolved
Hide resolved
Tests/SentryTests/Integrations/Session/SentrySessionTrackerTests.swift
Outdated
Show resolved
Hide resolved
Tests/SentryTests/Integrations/Session/SentrySessionTrackerTests.swift
Outdated
Show resolved
Hide resolved
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.
Almost LGTM. There are still two unresolved comments. Once we fix these, we should be goog do merge.
Tests/SentryTests/Integrations/Session/SentrySessionTrackerTests.swift
Outdated
Show resolved
Hide resolved
- Changed `stop` method to `stopWithGracefully:` in `SentrySessionTracker` to allow for graceful session termination. - Updated related logic in `SentryAutoSessionTrackingIntegration` and tests to reflect the new method signature and behavior. - Renamed internal flag from `wasDidBecomeActiveCalled` to `wasStartSessionCalled` for clarity.
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.
Almost LGTM. Just one open comment #5121 (comment).
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.
LGTM, thanks for the multiple rounds of feedback.
📜 Description
On SDK startup we check if the app is already in foreground and manually trigger the logic of
didBecomeActive
.💡 Motivation and Context
Currently the session tracker expects the
didBecomeActive
notification from the application life cycle after the SDK start. If we start the SDK after the app is opened, e.g. after fetching a remote config and initializing the SDK again, or if the user is asked for consent first, session tracking will not start until the app is in background for a while again.Please see this comment for further details.
Closes #5069
💚 How did you test it?
start
andclose
buttons in the sample apps📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.