Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Android: `SentryUserFeedbackDialog`: use `SentryUserFeedbackForm` instead
- Android: the `SentryUserFeedbackButton` view and composable: call `Sentry.feedback().show()` from your own button instead
- Remove deprecated Hub compatibility APIs in favor of `IScopes` and `Scopes` ([#6223](https://github.com/getsentry/sentry-java/pull/6223))
- Remove the deprecated `IEnvelopeCache.store(...)` methods. Custom `IEnvelopeCache` implementations must implement `storeEnvelope(envelope, hint)` instead and return whether the envelope was stored ([#6468](https://github.com/getsentry/sentry-java/pull/6468))
- Remove the aggregate Sentry Logs and Metrics enable options from all configuration surfaces:
- Java API: `options.getLogs().setEnabled(...)` and `options.getMetrics().setEnabled(...)`
- Properties files: `logs.enabled` and `metrics.enabled`
Expand Down
1 change: 0 additions & 1 deletion sentry-android-core/api/sentry-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ public final class io/sentry/android/core/cache/AndroidEnvelopeCache : io/sentry
public static fun markAnrReported (Lio/sentry/SentryOptions;J)V
public static fun markMemoryLimiterReported (Lio/sentry/SentryOptions;J)V
public static fun markTombstoneReported (Lio/sentry/SentryOptions;J)V
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,8 @@ public AndroidEnvelopeCache(final @NotNull SentryAndroidOptions options) {
this.currentDateProvider = currentDateProvider;
}

@SuppressWarnings("deprecation")
@Override
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
storeInternalAndroid(envelope, hint);
}

@Override
public boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
return storeInternalAndroid(envelope, hint);
}

private boolean storeInternalAndroid(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
final boolean didStore = super.storeEnvelope(envelope, hint);

final SentryAndroidOptions options = (SentryAndroidOptions) this.options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class SentryAndroidTest {
private class CustomEnvelopCache : IEnvelopeCache {
override fun iterator(): MutableIterator<SentryEnvelope> = TODO()

override fun store(envelope: SentryEnvelope, hint: Hint) = Unit
override fun storeEnvelope(envelope: SentryEnvelope, hint: Hint) = true

override fun discard(envelope: SentryEnvelope) = Unit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.sentry.android.core.cache

import com.google.common.truth.Truth.assertThat
import io.sentry.DateUtils
import io.sentry.Hint
import io.sentry.ISerializer
import io.sentry.NoOpLogger
import io.sentry.SentryEnvelope
Expand Down Expand Up @@ -90,7 +91,7 @@ class AndroidEnvelopeCacheTest {
fun `when no uncaught hint exists, does not write startup crash file`() {
val cache = fixture.getSut(tmpDir)

cache.store(fixture.envelope)
cache.storeEnvelope(fixture.envelope, Hint())

assertFalse(fixture.startupCrashMarkerFile.exists())
}
Expand Down Expand Up @@ -155,7 +156,7 @@ class AndroidEnvelopeCacheTest {
fun `when no AnrV2 hint exists, does not write last anr report file`() {
val cache = fixture.getSut(tmpDir)

cache.store(fixture.envelope)
cache.storeEnvelope(fixture.envelope, Hint())

assertFalse(fixture.lastReportedAnrFile.exists())
}
Expand Down
6 changes: 1 addition & 5 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -4682,16 +4682,13 @@ public class io/sentry/cache/EnvelopeCache : io/sentry/cache/IEnvelopeCache {
public fun iterator ()Ljava/util/Iterator;
public fun movePreviousSession (Ljava/io/File;Ljava/io/File;)V
public fun persistCurrentSession (Lio/sentry/Session;)V
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
public fun waitPreviousSessionFlush ()Z
}

public abstract interface class io/sentry/cache/IEnvelopeCache : java/lang/Iterable {
public abstract fun discard (Lio/sentry/SentryEnvelope;)V
public fun store (Lio/sentry/SentryEnvelope;)V
public abstract fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
public abstract fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
}

public final class io/sentry/cache/PersistingOptionsObserver : io/sentry/IOptionsObserver {
Expand Down Expand Up @@ -7450,7 +7447,6 @@ public final class io/sentry/transport/NoOpEnvelopeCache : io/sentry/cache/IEnve
public fun discard (Lio/sentry/SentryEnvelope;)V
public static fun getInstance ()Lio/sentry/transport/NoOpEnvelopeCache;
public fun iterator ()Ljava/util/Iterator;
public fun store (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)V
public fun storeEnvelope (Lio/sentry/SentryEnvelope;Lio/sentry/Hint;)Z
}

Expand Down
12 changes: 1 addition & 11 deletions sentry/src/main/java/io/sentry/cache/EnvelopeCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,8 @@ public EnvelopeCache(
previousSessionLatch = new CountDownLatch(1);
}

@SuppressWarnings("deprecation")
@Override
public void store(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
storeInternal(envelope, hint);
}

@Override
public boolean storeEnvelope(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
return storeInternal(envelope, hint);
}

private boolean storeInternal(final @NotNull SentryEnvelope envelope, final @NotNull Hint hint) {
Objects.requireNonNull(envelope, "Envelope is required.");

// Create the cache dir lazily on the first write so Sentry.init doesn't block on the mkdirs.
Expand Down Expand Up @@ -421,7 +411,7 @@ public void discard(final @NotNull SentryEnvelope envelope) {
*
* <p>This only computes a path and never creates the directory, so that {@link
* #discard(SentryEnvelope)} doesn't resurrect a cache dir it is only deleting from. Writers go
* through {@link #storeInternal}, which creates the directory up front.
* through {@link #storeEnvelope}, which creates the directory up front.
*
* @param envelope the SentryEnvelope object
* @return the file
Expand Down
18 changes: 6 additions & 12 deletions sentry/src/main/java/io/sentry/cache/IEnvelopeCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@

public interface IEnvelopeCache extends Iterable<SentryEnvelope> {

@Deprecated
void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint);

default boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
store(envelope, hint);
return true;
}

@Deprecated
default void store(@NotNull SentryEnvelope envelope) {
storeEnvelope(envelope, new Hint());
}
/**
* Stores an envelope.
*
* @return whether the envelope was stored
*/
boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint);

void discard(@NotNull SentryEnvelope envelope);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ public static NoOpEnvelopeCache getInstance() {
return instance;
}

@SuppressWarnings("deprecation")
@Override
public void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {}

@Override
public boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/test/java/io/sentry/SentryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ class SentryTest {
private class CustomEnvelopCache : IEnvelopeCache {
override fun iterator(): MutableIterator<SentryEnvelope> = TODO()

override fun store(envelope: SentryEnvelope, hint: Hint) = Unit
override fun storeEnvelope(envelope: SentryEnvelope, hint: Hint) = true

override fun discard(envelope: SentryEnvelope) = Unit
}
Expand Down
20 changes: 13 additions & 7 deletions sentry/src/test/java/io/sentry/cache/EnvelopeCacheTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class EnvelopeCacheTest {

assertEquals(0, nofFiles())

cache.store(SentryEnvelope.from(fixture.options.serializer, createSession(), null))
cache.storeEnvelope(
SentryEnvelope.from(fixture.options.serializer, createSession(), null),
Hint(),
)

assertEquals(1, nofFiles())

Expand All @@ -91,7 +94,10 @@ class EnvelopeCacheTest {
assertTrue(file.deleteRecursively())
assertFalse(file.exists())

cache.store(SentryEnvelope.from(fixture.options.serializer, createSession(), null))
cache.storeEnvelope(
SentryEnvelope.from(fixture.options.serializer, createSession(), null),
Hint(),
)

assertTrue(file.exists())
assertEquals(1, file.list()?.size)
Expand Down Expand Up @@ -157,7 +163,7 @@ class EnvelopeCacheTest {
assertTrue(currentFile.exists())

HintUtils.setTypeCheckHint(hints, SessionEndHint())
cache.store(envelope, hints)
cache.storeEnvelope(envelope, hints)
assertFalse(currentFile.exists())

file.deleteRecursively()
Expand Down Expand Up @@ -394,7 +400,7 @@ class EnvelopeCacheTest {
// since the first store call would set as readCrashedLastRun=true
SentryCrashLastRunState.getInstance().reset()

cache.store(newEnvelope, hints)
cache.storeEnvelope(newEnvelope, hints)
file.deleteRecursively()

// passing empty string since readCrashedLastRun is already set
Expand Down Expand Up @@ -719,8 +725,8 @@ class EnvelopeCacheTest {
null,
)

cache.store(envelopeA, Hint())
cache.store(envelopeB, Hint())
cache.storeEnvelope(envelopeA, Hint())
cache.storeEnvelope(envelopeB, Hint())

assertEquals(2, cache.directory.file.list()?.size)
}
Expand Down Expand Up @@ -789,7 +795,7 @@ class EnvelopeCacheTest {

// Second call should be idempotent: previous_session.json should be preserved
// This simulates the race where both MovePreviousSession runnable and
// storeInternal (SessionStart) both call movePreviousSession
// storeEnvelope (SessionStart) both call movePreviousSession
cache.movePreviousSession(currentSessionFile, previousSessionFile)

// previous_session.json should still exist with original content
Expand Down
Loading