Skip to content

feat: Track low power mode in device context#7777

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

feat: Track low power mode in device context#7777
itaybre wants to merge 2 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

Internal Changes 🔧

Deps

  • Bump mikepenz/action-junit-report from 6.3.1 to 6.4.0 by dependabot in #7773
  • Bump ruby/setup-ruby from 1.298.0 to 1.299.0 by dependabot in #7772
  • Bump fastlane-plugin-sentry from 2.5.0 to 2.5.1 by dependabot in #7771

🤖 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 8d1b7a1

@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.9.0 (1) Release Install Build

@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 85.410%. Comparing base (a47ad66) to head (8d1b7a1).
✅ 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.401%   85.410%   +0.008%     
=============================================
  Files          487       487               
  Lines        29086     29117       +31     
  Branches     12602     12604        +2     
=============================================
+ Hits         24840     24869       +29     
  Misses        4196      4196               
- Partials        50        52        +2     
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% <ø> (ø)
...egrations/SentryCrash/SentryCrashIntegration.swift 95.783% <88.888%> (-1.340%) ⬇️

... and 5 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 a47ad66...8d1b7a1. 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.45 ms 1258.63 ms 30.18 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
bc00c87 1214.34 ms 1245.67 ms 31.33 ms
b590539 1220.42 ms 1239.82 ms 19.40 ms
3950d78 1212.52 ms 1243.20 ms 30.68 ms
a47ad66 1221.94 ms 1249.59 ms 27.66 ms
1a887e2 1212.46 ms 1241.33 ms 28.87 ms
eaeb9bc 1216.22 ms 1250.78 ms 34.56 ms
554a67d 1225.85 ms 1254.71 ms 28.86 ms
6515f11 1214.72 ms 1244.82 ms 30.10 ms
d68691e 1221.48 ms 1248.13 ms 26.65 ms
21cd5ba 1218.68 ms 1255.54 ms 36.86 ms

App size

Revision Plain With Sentry Diff
bc00c87 24.14 KiB 1.13 MiB 1.10 MiB
b590539 24.14 KiB 1.12 MiB 1.09 MiB
3950d78 24.14 KiB 1.11 MiB 1.09 MiB
a47ad66 24.14 KiB 1.13 MiB 1.10 MiB
1a887e2 24.14 KiB 1.09 MiB 1.07 MiB
eaeb9bc 24.14 KiB 1.12 MiB 1.10 MiB
554a67d 24.14 KiB 1.13 MiB 1.10 MiB
6515f11 24.14 KiB 1.11 MiB 1.09 MiB
d68691e 24.14 KiB 1.12 MiB 1.09 MiB
21cd5ba 24.14 KiB 1.04 MiB 1.02 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