feat: Track low power mode in device context#7777
Conversation
Add `low_power_mode` boolean to the device context so it's available on all event types including crashes and watchdog terminations. The value is kept in sync via the NSProcessInfoPowerStateDidChange notification on the scope, and also read at capture time in SentryExtraContextProvider.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
|
📲 Install BuildsiOS
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7777 +/- ##
=============================================
- Coverage 85.437% 85.150% -0.287%
=============================================
Files 487 487
Lines 29226 29261 +35
Branches 12645 12650 +5
=============================================
- Hits 24970 24916 -54
- Misses 4206 4294 +88
- Partials 50 51 +1
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0e4b033 | 1203.74 ms | 1249.71 ms | 45.97 ms |
| bbee1ba | 1197.79 ms | 1215.42 ms | 17.63 ms |
| 59981b9 | 1207.25 ms | 1240.71 ms | 33.46 ms |
| 64a365a | 1225.60 ms | 1255.49 ms | 29.89 ms |
| 93d7fdf | 1225.77 ms | 1259.79 ms | 34.02 ms |
| e03f459 | 1222.56 ms | 1255.94 ms | 33.37 ms |
| ffac605 | 1217.10 ms | 1256.91 ms | 39.81 ms |
| 2f4ddaa | 1227.26 ms | 1260.04 ms | 32.78 ms |
| 778dadf | 1207.69 ms | 1246.09 ms | 38.40 ms |
| daf8b80 | 1233.78 ms | 1259.44 ms | 25.66 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 0e4b033 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| bbee1ba | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| 59981b9 | 24.14 KiB | 1.09 MiB | 1.06 MiB |
| 64a365a | 24.14 KiB | 1.09 MiB | 1.06 MiB |
| 93d7fdf | 24.14 KiB | 1.11 MiB | 1.08 MiB |
| e03f459 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| ffac605 | 24.14 KiB | 1.13 MiB | 1.10 MiB |
| 2f4ddaa | 24.14 KiB | 1.04 MiB | 1.02 MiB |
| 778dadf | 24.14 KiB | 1.04 MiB | 1.02 MiB |
| daf8b80 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
philprime
left a comment
There was a problem hiding this comment.
LGTM with some additional comments to consider
Summary
low_power_modeboolean to the device context, available on all event typesNSProcessInfoPowerStateDidChangeNotificationinSentryCrashIntegrationto keep the scope's device context in sync, ensuring the value is persisted for crashes and watchdog terminationsSentryExtraContextProviderfor non-crash events@available(macOS 12.0, *)since the macOS deployment target is 10.14; available unconditionally on iOS, tvOS, watchOS, and visionOSTest plan
testLowPowerModeandtestLowPowerModeDisabledtests forSentryExtraContextProviderSentryExtraContextProviderTestspassSentryCrashIntegrationTestspass (31 tests)Fixes: #5322