feat(feedback): Show feedback widget on device shake#5729
Draft
feat(feedback): Show feedback widget on device shake#5729
Conversation
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Contributor
|
antonis
commented
Feb 26, 2026
Implement device shake detection to trigger the feedback widget.
No permissions are required on either platform:
- iOS: Uses UIKit's motionEnded:withEvent: via UIWindow swizzle
- Android: Uses SensorManager accelerometer (TYPE_ACCELEROMETER)
Public API:
- showFeedbackOnShake() / hideFeedbackOnShake() imperative APIs
- feedbackIntegration({ enableShakeToReport: true }) declarative option
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
636498e to
9bc0c17
Compare
Contributor
Android (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c7f264b | 434.98 ms | 452.96 ms | 17.98 ms |
| 9f211e3 | 451.50 ms | 500.00 ms | 48.50 ms |
| 9ced351+dirty | 405.40 ms | 419.39 ms | 13.98 ms |
| f70acbf+dirty | 373.39 ms | 382.81 ms | 9.43 ms |
| f234eb4+dirty | 407.62 ms | 429.64 ms | 22.02 ms |
| 2adbd1e+dirty | 433.98 ms | 427.96 ms | -6.02 ms |
| 7886639+dirty | 425.10 ms | 477.73 ms | 52.63 ms |
| a206511+dirty | 424.28 ms | 474.82 ms | 50.54 ms |
| 98f632c | 424.25 ms | 435.48 ms | 11.23 ms |
| 46da307 | 455.92 ms | 443.79 ms | -12.13 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| c7f264b | 17.75 MiB | 19.68 MiB | 1.94 MiB |
| 9f211e3 | 17.75 MiB | 19.68 MiB | 1.94 MiB |
| 9ced351+dirty | 43.75 MiB | 48.41 MiB | 4.66 MiB |
| f70acbf+dirty | 17.75 MiB | 19.68 MiB | 1.94 MiB |
| f234eb4+dirty | 17.75 MiB | 19.74 MiB | 1.99 MiB |
| 2adbd1e+dirty | 17.75 MiB | 19.70 MiB | 1.96 MiB |
| 7886639+dirty | 43.75 MiB | 48.42 MiB | 4.67 MiB |
| a206511+dirty | 43.75 MiB | 48.07 MiB | 4.32 MiB |
| 98f632c | 17.75 MiB | 20.15 MiB | 2.41 MiB |
| 46da307 | 17.75 MiB | 19.68 MiB | 1.93 MiB |
Contributor
iOS (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ea3e26e+dirty | 1229.13 ms | 1228.46 ms | -0.67 ms |
| 80e4616+dirty | 1221.32 ms | 1225.64 ms | 4.32 ms |
| 818a608+dirty | 1205.76 ms | 1208.00 ms | 2.24 ms |
| 77061ed+dirty | 1233.16 ms | 1234.88 ms | 1.71 ms |
| bef3709+dirty | 1222.07 ms | 1220.24 ms | -1.83 ms |
| a206511+dirty | 1185.00 ms | 1186.35 ms | 1.35 ms |
| 74979ac+dirty | 1210.49 ms | 1213.31 ms | 2.82 ms |
| a2bb688+dirty | 1223.53 ms | 1232.90 ms | 9.37 ms |
| 8a868fe+dirty | 1221.50 ms | 1230.78 ms | 9.28 ms |
| d590428+dirty | 1211.77 ms | 1220.51 ms | 8.75 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ea3e26e+dirty | 3.41 MiB | 4.58 MiB | 1.17 MiB |
| 80e4616+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| 818a608+dirty | 2.63 MiB | 3.91 MiB | 1.28 MiB |
| 77061ed+dirty | 2.63 MiB | 3.98 MiB | 1.34 MiB |
| bef3709+dirty | 3.38 MiB | 4.78 MiB | 1.40 MiB |
| a206511+dirty | 3.41 MiB | 4.67 MiB | 1.25 MiB |
| 74979ac+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| a2bb688+dirty | 2.63 MiB | 3.99 MiB | 1.36 MiB |
| 8a868fe+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| d590428+dirty | 3.38 MiB | 4.78 MiB | 1.39 MiB |
Contributor
iOS (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ea3e26e+dirty | 1216.61 ms | 1214.15 ms | -2.47 ms |
| 80e4616+dirty | 1206.90 ms | 1205.94 ms | -0.96 ms |
| 818a608+dirty | 1218.84 ms | 1223.18 ms | 4.34 ms |
| 77061ed+dirty | 1210.77 ms | 1218.45 ms | 7.68 ms |
| bef3709+dirty | 1217.79 ms | 1225.33 ms | 7.54 ms |
| a206511+dirty | 1225.02 ms | 1223.74 ms | -1.28 ms |
| 74979ac+dirty | 1212.33 ms | 1212.54 ms | 0.21 ms |
| a2bb688+dirty | 1244.82 ms | 1238.60 ms | -6.22 ms |
| 8a868fe+dirty | 1206.85 ms | 1215.04 ms | 8.19 ms |
| d590428+dirty | 1221.23 ms | 1225.27 ms | 4.03 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| ea3e26e+dirty | 3.41 MiB | 4.58 MiB | 1.17 MiB |
| 80e4616+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| 818a608+dirty | 3.19 MiB | 4.48 MiB | 1.29 MiB |
| 77061ed+dirty | 3.19 MiB | 4.54 MiB | 1.36 MiB |
| bef3709+dirty | 3.38 MiB | 4.78 MiB | 1.40 MiB |
| a206511+dirty | 3.41 MiB | 4.67 MiB | 1.25 MiB |
| 74979ac+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| a2bb688+dirty | 3.19 MiB | 4.56 MiB | 1.37 MiB |
| 8a868fe+dirty | 3.38 MiB | 4.60 MiB | 1.22 MiB |
| d590428+dirty | 3.38 MiB | 4.78 MiB | 1.39 MiB |
Contributor
Android (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 664c66f+dirty | 376.23 ms | 389.51 ms | 13.28 ms |
| d73150f+dirty | 424.60 ms | 454.35 ms | 29.75 ms |
| 4a17c8f+dirty | 368.54 ms | 381.43 ms | 12.89 ms |
| b3b5b0d+dirty | 361.42 ms | 403.90 ms | 42.48 ms |
| 9ced351+dirty | 361.74 ms | 411.45 ms | 49.70 ms |
| 7886639+dirty | 530.30 ms | 571.34 ms | 41.04 ms |
| c08359e+dirty | 406.04 ms | 428.87 ms | 22.83 ms |
| 3099014+dirty | 344.58 ms | 404.21 ms | 59.63 ms |
| d751a5d+dirty | 341.61 ms | 403.06 ms | 61.45 ms |
| 682f0f5+dirty | 402.33 ms | 440.61 ms | 38.28 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 664c66f+dirty | 43.94 MiB | 49.38 MiB | 5.44 MiB |
| d73150f+dirty | 43.94 MiB | 49.38 MiB | 5.44 MiB |
| 4a17c8f+dirty | 43.94 MiB | 48.82 MiB | 4.88 MiB |
| b3b5b0d+dirty | 7.15 MiB | 8.41 MiB | 1.26 MiB |
| 9ced351+dirty | 43.94 MiB | 49.27 MiB | 5.33 MiB |
| 7886639+dirty | 43.94 MiB | 49.28 MiB | 5.34 MiB |
| c08359e+dirty | 7.15 MiB | 8.42 MiB | 1.27 MiB |
| 3099014+dirty | 7.15 MiB | 8.43 MiB | 1.27 MiB |
| d751a5d+dirty | 7.15 MiB | 8.41 MiB | 1.26 MiB |
| 682f0f5+dirty | 43.94 MiB | 48.91 MiB | 4.97 MiB |
…tion.sendEvent: The previous implementation swizzled UIWindow.motionEnded:withEvent: which was intercepted by React Native's dev menu before our handler could fire. Switching to UIApplication.sendEvent: intercepts events before the responder chain, so shake events are detected even when RN dev menu or another responder consumes the motion event without calling super. Added a 1-second cooldown to prevent double-firing since both motionBegan and motionEnded trigger UIEventSubtypeMotionShake.
…wizzle UIApplication.sendEvent: is not invoked by the iOS simulator for the simulated shake (Cmd+Ctrl+Z); it goes directly through UIWindow.motionEnded:withEvent: instead. React Native's dev menu swizzles UIWindow.motionEnded:withEvent: at bridge load time. Because we swizzle from startObserving (triggered by componentDidMount via NativeEventEmitter.addListener), our swizzle always runs after RN's — making sentry_motionEnded the outermost layer that calls through to RN's dev-menu handler via the stored original IMP. This approach works on both real devices and the iOS simulator.
Without FeedbackWidgetProvider rendered in the tree, componentDidMount never fires, startShakeListener is never called, and the native swizzle is never set up — so shake-to-report has no effect despite enableShakeToReport: true being configured on the integration.
…le app" This reverts commit 6054e19.
Instead of relying on startObserving (which fires for any event type on the module's first listener), mirror the Android approach: override addListener and explicitly call [RNSentryShakeDetector enable] when the shake event is subscribed to. This ensures the UIWindow swizzle is set up reliably regardless of listener ordering or TurboModule event-emitter behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
Implements shake-to-report for the feedback widget (ref: #4735).
UIWindow.motionEnded:withEvent:(UIKit responder chain) — no permissions requiredSensorManager.TYPE_ACCELEROMETER— no permissions requiredshowFeedbackOnShake()/hideFeedbackOnShake()imperative APIs +feedbackIntegration({ enableShakeToReport: true })declarative optionNew files:
src/js/feedback/ShakeToReportBug.ts— JS shake event listener managementios/RNSentryShakeDetector.h/m— iOS native shake detectionandroid/.../RNSentryShakeDetector.java— Android native shake detectiontest/feedback/ShakeToReportBug.test.tsx— tests covering unit + integration behavior💡 Motivation and Context
Users have requested a way to trigger the feedback widget by shaking the device, without the need for a visible button. This is a common UX pattern for in-app feedback (see #4735).
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps