Skip to content

Commit 69ee931

Browse files
antonisclaude
andcommitted
fix(feedback): pass real logger to SentryShakeDetector on init
The detector was constructed with NoOpLogger and the logger field was final, so all diagnostic messages (sensor unavailable warnings) were silently swallowed. Now init(context, logger) updates the logger from SentryOptions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 59cfc0a commit 69ee931

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/FeedbackShakeIntegration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
4242
return;
4343
}
4444

45-
// Re-assign a properly configured detector logger now that options are available
46-
shakeDetector.init(application);
45+
shakeDetector.init(application, options.getLogger());
4746

4847
addIntegrationToSdkVersion("FeedbackShake");
4948
application.registerActivityLifecycleCallbacks(this);

sentry-android-core/src/main/java/io/sentry/android/core/SentryShakeDetector.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class SentryShakeDetector implements SensorEventListener {
4040
private @Nullable HandlerThread handlerThread;
4141
private final @NotNull AtomicLong lastShakeTimestamp = new AtomicLong(0);
4242
private volatile @Nullable Listener listener;
43-
private final @NotNull ILogger logger;
43+
private @NotNull ILogger logger;
4444

4545
private int shakeCount = 0;
4646
private long firstShakeTimestamp = 0;
@@ -57,7 +57,12 @@ public SentryShakeDetector(final @NotNull ILogger logger) {
5757
* Initializes the sensor manager and accelerometer sensor. This is separated from start() so the
5858
* values can be resolved once and reused across activity transitions.
5959
*/
60-
void init(final @NotNull Context context) {
60+
void init(final @NotNull Context context, final @NotNull ILogger logger) {
61+
this.logger = logger;
62+
init(context);
63+
}
64+
65+
private void init(final @NotNull Context context) {
6166
if (sensorManager == null) {
6267
sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
6368
}

0 commit comments

Comments
 (0)