Skip to content

feat: Track low power mode in device context#7777

Open
itaybre wants to merge 3 commits intomainfrom
feat/low-power-mode-context
Open

feat: Track low power mode in device context#7777
itaybre wants to merge 3 commits intomainfrom
feat/low-power-mode-context

Conversation

@itaybre
Copy link
Copy Markdown
Contributor

@itaybre itaybre commented Apr 6, 2026

Summary

  • Adds low_power_mode boolean to the device context, available on all event types
  • Observes NSProcessInfoPowerStateDidChangeNotification in SentryCrashIntegration to keep the scope's device context in sync, ensuring the value is persisted for crashes and watchdog terminations
  • Also reads the value at capture time in SentryExtraContextProvider for non-crash events
  • Gated with @available(macOS 12.0, *) since the macOS deployment target is 10.14; available unconditionally on iOS, tvOS, watchOS, and visionOS

Test plan

  • Added testLowPowerMode and testLowPowerModeDisabled tests for SentryExtraContextProvider
  • All existing SentryExtraContextProviderTests pass
  • All existing SentryCrashIntegrationTests pass (31 tests)
  • Builds successfully on iOS and macOS

Fixes: #5322

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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Track low power mode in device context by itaybre in #7777

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 977efdf

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Apr 6, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 6, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK-Size io.sentry.sample.SDK-Size 9.10.0 (1) Release Install Build

Configure sentry-cocoa build distribution settings

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.126%. Comparing base (0bff410) to head (977efdf).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...egrations/SentryCrash/SentryCrashIntegration.swift 88.888% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7777       +/-   ##
=============================================
+ Coverage   85.135%   86.126%   +0.991%     
=============================================
  Files          487       487               
  Lines        29183     29214       +31     
  Branches     12612     12637       +25     
=============================================
+ Hits         24845     25161      +316     
+ Misses        4286      4002      -284     
+ Partials        52        51        -1     
Files with missing lines Coverage Δ
...Utils/Sources/TestSentryNSProcessInfoWrapper.swift 90.000% <100.000%> (+1.111%) ⬆️
...rces/Swift/Helper/SentryExtraContextProvider.swift 100.000% <100.000%> (ø)
Sources/Swift/Helper/SentryProcessInfo.swift 92.307% <ø> (+57.692%) ⬆️
...egrations/SentryCrash/SentryCrashIntegration.swift 95.783% <88.888%> (-1.340%) ⬇️

... and 21 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bff410...977efdf. Read the comment docs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1228.71 ms 1262.20 ms 33.50 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
8d9e501 1233.04 ms 1260.40 ms 27.35 ms
d0b4402 1218.62 ms 1241.80 ms 23.18 ms
e06cf5f 1222.96 ms 1254.66 ms 31.70 ms
09a80f2 1214.78 ms 1237.85 ms 23.07 ms
17fe3fd 1224.77 ms 1259.00 ms 34.23 ms
dbfeb41 1215.17 ms 1237.41 ms 22.23 ms
0e4a9dc 1222.92 ms 1255.78 ms 32.86 ms
b882255 1216.49 ms 1253.66 ms 37.17 ms
4883c74 1224.80 ms 1258.65 ms 33.85 ms
5fff6ba 1206.13 ms 1232.49 ms 26.36 ms

App size

Revision Plain With Sentry Diff
8d9e501 24.14 KiB 1.12 MiB 1.10 MiB
d0b4402 24.14 KiB 1.11 MiB 1.08 MiB
e06cf5f 24.14 KiB 1.13 MiB 1.10 MiB
09a80f2 24.14 KiB 1.10 MiB 1.08 MiB
17fe3fd 24.14 KiB 1.12 MiB 1.10 MiB
dbfeb41 24.14 KiB 1.04 MiB 1.02 MiB
0e4a9dc 24.14 KiB 1.11 MiB 1.09 MiB
b882255 24.14 KiB 1.12 MiB 1.09 MiB
4883c74 24.14 KiB 1.12 MiB 1.10 MiB
5fff6ba 24.14 KiB 1.13 MiB 1.10 MiB

Previous results on branch: feat/low-power-mode-context

Startup times

Revision Plain With Sentry Diff
bda24a3 1228.45 ms 1258.63 ms 30.18 ms

App size

Revision Plain With Sentry Diff
bda24a3 24.14 KiB 1.13 MiB 1.11 MiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect low power mode

1 participant