Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed reportFullDisplayed to reportFullyDisplayed #2585

Merged
merged 5 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Improve versatility of exception resolver component for Spring with more flexible API for consumers. ([#2577](https://github.com/getsentry/sentry-java/pull/2577))

### Fixes

- Deprecate reportFullDisplayed in favor of reportFullyDisplayed ([#2585](https://github.com/getsentry/sentry-java/pull/2585))

## 6.15.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import android.view.View;
import androidx.annotation.NonNull;
import io.sentry.Breadcrumb;
import io.sentry.FullDisplayedReporter;
import io.sentry.FullyDisplayedReporter;
import io.sentry.Hint;
import io.sentry.IHub;
import io.sentry.ISpan;
Expand Down Expand Up @@ -64,7 +64,7 @@ public final class ActivityLifecycleIntegration
private boolean firstActivityCreated = false;
private final boolean foregroundImportance;

private @Nullable FullDisplayedReporter fullDisplayedReporter = null;
private @Nullable FullyDisplayedReporter fullyDisplayedReporter = null;
private @Nullable ISpan appStartSpan;
private final @NotNull WeakHashMap<Activity, ISpan> ttidSpanMap = new WeakHashMap<>();
private @NotNull SentryDate lastPausedTime = AndroidDateUtils.getCurrentSentryDateTime();
Expand Down Expand Up @@ -115,7 +115,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
this.options.isEnableActivityLifecycleBreadcrumbs());

performanceEnabled = isPerformanceEnabled(this.options);
fullDisplayedReporter = this.options.getFullDisplayedReporter();
fullyDisplayedReporter = this.options.getFullyDisplayedReporter();
timeToFullDisplaySpanEnabled = this.options.isEnableTimeToFullDisplayTracing();

if (this.options.isEnableActivityLifecycleBreadcrumbs() || performanceEnabled) {
Expand Down Expand Up @@ -239,7 +239,7 @@ private void startTracing(final @NotNull Activity activity) {
transaction.startChild(
TTID_OP, getTtidDesc(activityName), ttidStartTime, Instrumenter.SENTRY));

if (timeToFullDisplaySpanEnabled && fullDisplayedReporter != null && options != null) {
if (timeToFullDisplaySpanEnabled && fullyDisplayedReporter != null && options != null) {
ttfdSpan =
transaction.startChild(
TTFD_OP, getTtfdDesc(activityName), ttidStartTime, Instrumenter.SENTRY);
Expand Down Expand Up @@ -344,8 +344,8 @@ public synchronized void onActivityCreated(

firstActivityCreated = true;

if (fullDisplayedReporter != null) {
fullDisplayedReporter.registerFullyDrawnListener(
if (fullyDisplayedReporter != null) {
fullyDisplayedReporter.registerFullyDrawnListener(
() -> {
finishSpan(ttfdSpan);
cancelTtfdAutoClose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.Breadcrumb
import io.sentry.DateUtils
import io.sentry.FullDisplayedReporter
import io.sentry.FullyDisplayedReporter
import io.sentry.Hub
import io.sentry.ISentryExecutorService
import io.sentry.Scope
Expand Down Expand Up @@ -66,7 +66,7 @@ class ActivityLifecycleIntegrationTest {
val bundle = mock<Bundle>()
val context = TransactionContext("name", "op")
val activityFramesTracker = mock<ActivityFramesTracker>()
val fullDisplayedReporter = FullDisplayedReporter.getInstance()
val fullyDisplayedReporter = FullyDisplayedReporter.getInstance()
val transactionFinishedCallback = mock<TransactionFinishedCallback>()
lateinit var transaction: SentryTracer
val buildInfo = mock<BuildInfoProvider>()
Expand Down Expand Up @@ -729,7 +729,7 @@ class ActivityLifecycleIntegrationTest {
val activity = mock<Activity>()
sut.onActivityCreated(activity, mock())
sut.ttidSpanMap.values.first().finish()
fixture.fullDisplayedReporter.reportFullyDrawn()
fixture.fullyDisplayedReporter.reportFullyDrawn()
assertTrue(sut.ttfdSpan!!.isFinished)
assertNotEquals(SpanStatus.CANCELLED, sut.ttfdSpan?.status)
}
Expand Down Expand Up @@ -1103,7 +1103,7 @@ class ActivityLifecycleIntegrationTest {
assertNotNull(autoCloseFuture)

// ReportFullyDrawn should finish the ttfd span and cancel the future
fixture.options.fullDisplayedReporter.reportFullyDrawn()
fixture.options.fullyDisplayedReporter.reportFullyDrawn()
assertTrue(ttfdSpan.isFinished)
assertNotEquals(SpanStatus.DEADLINE_EXCEEDED, ttfdSpan.status)
assertTrue(autoCloseFuture.isCancelled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ protected void onResume() {
if (span != null) {
span.setMeasurement("screen_load_count", screenLoadCount, new MeasurementUnit.Custom("test"));
}
Sentry.reportFullDisplayed();
Sentry.reportFullyDisplayed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ class PermissionsActivity : AppCompatActivity() {
}

setContentView(binding.root)
Sentry.reportFullDisplayed()
Sentry.reportFullyDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ProfilingActivity : AppCompatActivity() {
}.start()
}
setContentView(binding.root)
Sentry.reportFullDisplayed()
Sentry.reportFullyDisplayed()
}

private fun finishTransactionAndPrintResults(t: ITransaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SecondActivity : AppCompatActivity() {

showText(true, "error: ${t.message}")

Sentry.reportFullDisplayed()
Sentry.reportFullyDisplayed()
}

override fun onResponse(call: Call<List<Repo>>, response: Response<List<Repo>>) {
Expand All @@ -86,7 +86,7 @@ class SecondActivity : AppCompatActivity() {

showText(text = "items: ${repos.size}")

Sentry.reportFullDisplayed()
Sentry.reportFullyDisplayed()
}
})
}
Expand Down
20 changes: 11 additions & 9 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ public final class io/sentry/ExternalOptions {
public fun setTracesSampleRate (Ljava/lang/Double;)V
}

public final class io/sentry/FullDisplayedReporter {
public static fun getInstance ()Lio/sentry/FullDisplayedReporter;
public fun registerFullyDrawnListener (Lio/sentry/FullDisplayedReporter$FullDisplayedReporterListener;)V
public final class io/sentry/FullyDisplayedReporter {
public static fun getInstance ()Lio/sentry/FullyDisplayedReporter;
public fun registerFullyDrawnListener (Lio/sentry/FullyDisplayedReporter$FullyDisplayedReporterListener;)V
public fun reportFullyDrawn ()V
}

public abstract interface class io/sentry/FullDisplayedReporter$FullDisplayedReporterListener {
public abstract interface class io/sentry/FullyDisplayedReporter$FullyDisplayedReporterListener {
public abstract fun onFullyDrawn ()V
}

Expand Down Expand Up @@ -344,7 +344,7 @@ public final class io/sentry/Hub : io/sentry/IHub {
public fun pushScope ()V
public fun removeExtra (Ljava/lang/String;)V
public fun removeTag (Ljava/lang/String;)V
public fun reportFullDisplayed ()V
public fun reportFullyDisplayed ()V
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public fun setFingerprint (Ljava/util/List;)V
public fun setLevel (Lio/sentry/SentryLevel;)V
Expand Down Expand Up @@ -388,7 +388,7 @@ public final class io/sentry/HubAdapter : io/sentry/IHub {
public fun pushScope ()V
public fun removeExtra (Ljava/lang/String;)V
public fun removeTag (Ljava/lang/String;)V
public fun reportFullDisplayed ()V
public fun reportFullyDisplayed ()V
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public fun setFingerprint (Ljava/util/List;)V
public fun setLevel (Lio/sentry/SentryLevel;)V
Expand Down Expand Up @@ -457,7 +457,8 @@ public abstract interface class io/sentry/IHub {
public abstract fun pushScope ()V
public abstract fun removeExtra (Ljava/lang/String;)V
public abstract fun removeTag (Ljava/lang/String;)V
public abstract fun reportFullDisplayed ()V
public fun reportFullDisplayed ()V
public abstract fun reportFullyDisplayed ()V
public abstract fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public abstract fun setFingerprint (Ljava/util/List;)V
public abstract fun setLevel (Lio/sentry/SentryLevel;)V
Expand Down Expand Up @@ -784,7 +785,7 @@ public final class io/sentry/NoOpHub : io/sentry/IHub {
public fun pushScope ()V
public fun removeExtra (Ljava/lang/String;)V
public fun removeTag (Ljava/lang/String;)V
public fun reportFullDisplayed ()V
public fun reportFullyDisplayed ()V
public fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public fun setFingerprint (Ljava/util/List;)V
public fun setLevel (Lio/sentry/SentryLevel;)V
Expand Down Expand Up @@ -1183,6 +1184,7 @@ public final class io/sentry/Sentry {
public static fun removeExtra (Ljava/lang/String;)V
public static fun removeTag (Ljava/lang/String;)V
public static fun reportFullDisplayed ()V
public static fun reportFullyDisplayed ()V
public static fun setCurrentHub (Lio/sentry/IHub;)V
public static fun setExtra (Ljava/lang/String;Ljava/lang/String;)V
public static fun setFingerprint (Ljava/util/List;)V
Expand Down Expand Up @@ -1546,7 +1548,7 @@ public class io/sentry/SentryOptions {
public fun getEventProcessors ()Ljava/util/List;
public fun getExecutorService ()Lio/sentry/ISentryExecutorService;
public fun getFlushTimeoutMillis ()J
public fun getFullDisplayedReporter ()Lio/sentry/FullDisplayedReporter;
public fun getFullyDisplayedReporter ()Lio/sentry/FullyDisplayedReporter;
public fun getGestureTargetLocators ()Ljava/util/List;
public fun getHostnameVerifier ()Ljavax/net/ssl/HostnameVerifier;
public fun getIdleTimeout ()Ljava/lang/Long;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
import org.jetbrains.annotations.NotNull;

@ApiStatus.Internal
public final class FullDisplayedReporter {
public final class FullyDisplayedReporter {

private static final @NotNull FullDisplayedReporter instance = new FullDisplayedReporter();
private static final @NotNull FullyDisplayedReporter instance = new FullyDisplayedReporter();

private final @NotNull List<FullDisplayedReporterListener> listeners =
private final @NotNull List<FullyDisplayedReporterListener> listeners =
new CopyOnWriteArrayList<>();

private FullDisplayedReporter() {}
private FullyDisplayedReporter() {}

public static @NotNull FullDisplayedReporter getInstance() {
public static @NotNull FullyDisplayedReporter getInstance() {
return instance;
}

public void registerFullyDrawnListener(
final @NotNull FullDisplayedReporter.FullDisplayedReporterListener listener) {
final @NotNull FullyDisplayedReporter.FullyDisplayedReporterListener listener) {
listeners.add(listener);
}

public void reportFullyDrawn() {
final @NotNull Iterator<FullDisplayedReporterListener> listenerIterator = listeners.iterator();
final @NotNull Iterator<FullyDisplayedReporterListener> listenerIterator = listeners.iterator();
listeners.clear();
while (listenerIterator.hasNext()) {
listenerIterator.next().onFullyDrawn();
}
}

@ApiStatus.Internal
public interface FullDisplayedReporterListener {
public interface FullyDisplayedReporterListener {
void onFullyDrawn();
}
}
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/Hub.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ public void pushScope() {
}

@Override
public void reportFullDisplayed() {
public void reportFullyDisplayed() {
if (options.isEnableTimeToFullDisplayTracing()) {
options.getFullDisplayedReporter().reportFullyDrawn();
options.getFullyDisplayedReporter().reportFullyDrawn();
}
}

Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/HubAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void setSpanContext(
}

@Override
public void reportFullDisplayed() {
Sentry.reportFullDisplayed();
public void reportFullyDisplayed() {
Sentry.reportFullyDisplayed();
}
}
10 changes: 9 additions & 1 deletion sentry/src/main/java/io/sentry/IHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,5 +572,13 @@ void setSpanContext(
* <p>This method is safe to be called multiple times. If the time-to-full-display span is already
* finished, this call will be ignored.
*/
void reportFullDisplayed();
void reportFullyDisplayed();

/**
* @deprecated See {@link IHub#reportFullyDisplayed()}.
*/
@Deprecated
default void reportFullDisplayed() {
reportFullyDisplayed();
}
}
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/NoOpHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,5 @@ public void setSpanContext(
}

@Override
public void reportFullDisplayed() {}
public void reportFullyDisplayed() {}
}
11 changes: 10 additions & 1 deletion sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,17 @@ public static void endSession() {
* <p>This method is safe to be called multiple times. If the time-to-full-display span is already
* finished, this call will be ignored.
*/
public static void reportFullyDisplayed() {
getCurrentHub().reportFullyDisplayed();
}

/**
* @deprecated See {@link Sentry#reportFullyDisplayed()}.
*/
@Deprecated
@SuppressWarnings("InlineMeSuggester")
public static void reportFullDisplayed() {
getCurrentHub().reportFullDisplayed();
reportFullyDisplayed();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ public class SentryOptions {
private boolean enableTimeToFullDisplayTracing = false;

/** Screen fully displayed reporter, used for time-to-full-display spans. */
private final @NotNull FullDisplayedReporter fullDisplayedReporter =
FullDisplayedReporter.getInstance();
private final @NotNull FullyDisplayedReporter fullyDisplayedReporter =
FullyDisplayedReporter.getInstance();

/**
* Adds an event processor
Expand Down Expand Up @@ -1967,8 +1967,8 @@ public void setEnableTimeToFullDisplayTracing(final boolean enableTimeToFullDisp
* @return The reporter to call when a screen is fully loaded.
*/
@ApiStatus.Internal
public @NotNull FullDisplayedReporter getFullDisplayedReporter() {
return fullDisplayedReporter;
public @NotNull FullyDisplayedReporter getFullyDisplayedReporter() {
return fullyDisplayedReporter;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.sentry

import io.sentry.FullDisplayedReporter.FullDisplayedReporterListener
import io.sentry.FullyDisplayedReporter.FullyDisplayedReporterListener
import io.sentry.test.getProperty
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
Expand All @@ -9,14 +9,14 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class FullDisplayedReporterTest {
class FullyDisplayedReporterTest {

private val reporter = FullDisplayedReporter.getInstance()
private val listeners = reporter.getProperty<MutableList<FullDisplayedReporterListener>>("listeners")
private val listener1 = FullDisplayedReporterListener {}
private val listener2 = FullDisplayedReporterListener {}
private val mockListener1 = mock<FullDisplayedReporterListener>()
private val mockListener2 = mock<FullDisplayedReporterListener>()
private val reporter = FullyDisplayedReporter.getInstance()
private val listeners = reporter.getProperty<MutableList<FullyDisplayedReporterListener>>("listeners")
private val listener1 = FullyDisplayedReporterListener {}
private val listener2 = FullyDisplayedReporterListener {}
private val mockListener1 = mock<FullyDisplayedReporterListener>()
private val mockListener2 = mock<FullyDisplayedReporterListener>()

@AfterTest
fun shutdown() {
Expand Down