Skip to content

feat(ios): Introduce enableMetricKit option - #6540

Merged
alwx merged 4 commits into
mainfrom
alwx/fix/6457
Jul 30, 2026
Merged

feat(ios): Introduce enableMetricKit option#6540
alwx merged 4 commits into
mainfrom
alwx/fix/6457

Conversation

@alwx

@alwx alwx commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds enableMetricKit to the React Native SDK options, forwarding it to the Cocoa SDK.

The option name matches the Cocoa SentryOptions property, so it is decoded by SentryOptionsInternal initWithDict: and needs no mapping in RNSentryStart.m — same as enableAppHangTracking / appHangTimeoutInterval. No production code changes, only the type declaration plus tests.

Sentry.init({
  dsn: '___DSN___',
  enableMetricKit: true,
});

Notes:

  • No JS default, so the key is absent from the options dict unless set and native/sentry.options.json init can still own it.
  • Android ignores it (RNSentryStart.java is per-key hasKey() opt-in).
  • No API report diff — BaseReactNativeOptions isn't exported from the entry point.

💡 Motivation and Context

enableMetricKit could only be enabled through native initialization. This makes it officially configurable from RN.

MetricKit hang diagnostics (MXHangDiagnostic) are reported by the OS and are distinct from App Hangs V2, so this is not a substitute for enableAppHangTracking — enabling both can double-report a hang. Documented in the JSDoc.

Fixes #6457

💚 How did you test it?

  • packages/core/test/wrapper.test.ts — option is forwarded when set, absent when unset.
  • RNSentryTests.m — enabled / disabled / default cases asserting SentryOptions.enableMetricKit. This is what verifies Cocoa's dict decoder actually maps the key.
  • yarn build, yarn test (2073 passing), yarn lint, yarn circularDepCheck, yarn api-report (no diff).
  • xcodebuild test -configuration Release on iPhone 17 / iOS 26.1 — 49 tests, 0 failures.

Not verified end-to-end against Sentry: iOS delivers MetricKit payloads on a ~24h cadence, so that needs a TestFlight build.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

  • Docs PR in getsentry/sentry-docs for the new option.
  • enableMetricKitRawPayload is intentionally out of scope; still native-init only.

Expose `enableMetricKit` in the React Native SDK options so the Cocoa
MetricKit integration can be enabled from `Sentry.init()` instead of only
through native initialization.

The option name matches the Cocoa `SentryOptions` property, so it is
decoded by `SentryOptionsInternal initWithDict:` and needs no additional
mapping in `RNSentryStart.m`.

Fixes #6457
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

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


  • feat(ios): Introduce enableMetricKit option by alwx in #6540

🤖 This preview updates automatically when you update the PR.

@alwx
alwx marked this pull request as ready for review July 30, 2026 09:49
Comment thread CHANGELOG.md Outdated
Co-authored-by: Antonis Lilis <[email protected]>

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the full test suite is 🟢 and the changelog conflict resolved ✅
Let's also enhance the docs 🙇

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1a1187c

@alwx

alwx commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@antonis did the docs PR: getsentry/sentry-docs#18881

Comment thread CHANGELOG.md

### Features

- Add `enableMetricKit` option to enable the iOS MetricKit integration ([#6540](https://github.com/getsentry/sentry-react-native/pull/6540))

@alwx alwx Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@alwx
alwx merged commit 3d31fcf into main Jul 30, 2026
63 of 69 checks passed
@alwx
alwx deleted the alwx/fix/6457 branch July 30, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce enableMetricKit option in React Native SDK

2 participants