Skip to content

Commit ff784c6

Browse files
authored
Merge ca595ea into 5b8a9a6
2 parents 5b8a9a6 + ca595ea commit ff784c6

File tree

140 files changed

+2874
-832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2874
-832
lines changed

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Features
6+
7+
**Breaking changes:**
8+
- Capture failed HTTP requests by default ([#2794](https://github.com/getsentry/sentry-java/pull/2794))
9+
- Reduce flush timeout to 4s on Android to avoid ANRs ([#2858](https://github.com/getsentry/sentry-java/pull/2858))
10+
- Set ip_address to {{auto}} by default, even if sendDefaultPII is disabled ([#2860](https://github.com/getsentry/sentry-java/pull/2860))
11+
- Instead use the "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io
12+
- Reduce timeout of AsyncHttpTransport to avoid ANR ([#2879](https://github.com/getsentry/sentry-java/pull/2879))
13+
- Add deadline timeout for automatic transactions ([#2865](https://github.com/getsentry/sentry-java/pull/2865))
14+
- This affects all automatically generated transactions on Android (UI, clicks), the default timeout is 30s
15+
- Apollo v2 BeforeSpanCallback now allows returning null ([#2890](https://github.com/getsentry/sentry-java/pull/2890))
16+
- Automatic user interaction tracking: every click now starts a new automatic transaction ([#2891](https://github.com/getsentry/sentry-java/pull/2891))
17+
- Previously performing a click on the same UI widget twice would keep the existing transaction running, the new behavior now better aligns with other SDKs
18+
- Android only: If global hub mode is enabled, Sentry.getSpan() returns the root span instead of the latest span ([#2855](https://github.com/getsentry/sentry-java/pull/2855))
19+
- Observe network state to upload any unsent envelopes ([#2910](https://github.com/getsentry/sentry-java/pull/2910))
20+
- Android: it works out-of-the-box as part of the default `SendCachedEnvelopeIntegration`
21+
- JVM: you'd have to install `SendCachedEnvelopeFireAndForgetIntegration` as mentioned in https://docs.sentry.io/platforms/java/configuration/#configuring-offline-caching and provide your own implementation of `IConnectionStatusProvider` via `SentryOptions`
22+
- Do not try to send and drop cached envelopes when rate-limiting is active ([#2937](https://github.com/getsentry/sentry-java/pull/2937))
23+
24+
### Fixes
25+
26+
- Measure AppStart time till First Draw instead of `onResume` ([#2851](https://github.com/getsentry/sentry-java/pull/2851))
27+
- Do not overwrite UI transaction status if set by the user ([#2852](https://github.com/getsentry/sentry-java/pull/2852))
28+
- Capture unfinished transaction on Scope with status `aborted` in case a crash happens ([#2938](https://github.com/getsentry/sentry-java/pull/2938))
29+
- This will fix the link between transactions and corresponding crashes, you'll be able to see them in a single trace
30+
31+
**Breaking changes:**
32+
- Move enableNdk from SentryOptions to SentryAndroidOptions ([#2793](https://github.com/getsentry/sentry-java/pull/2793))
33+
- Fix Coroutine Context Propagation using CopyableThreadContextElement, requires `kotlinx-coroutines-core` version `1.6.1` or higher ([#2838](https://github.com/getsentry/sentry-java/pull/2838))
34+
- Bump min API to 19 ([#2883](https://github.com/getsentry/sentry-java/pull/2883))
35+
- Fix don't overwrite the span status of unfinished spans ([#2859](https://github.com/getsentry/sentry-java/pull/2859))
36+
- If you're using a self hosted version of sentry, sentry self hosted >= 22.12.0 is required
37+
- Migrate from `default` interface methods to proper implementations in each interface implementor ([#2847](https://github.com/getsentry/sentry-java/pull/2847))
38+
- This prevents issues when using the SDK on older AGP versions (< 4.x.x)
39+
- Make sure to align Sentry dependencies to the same version when bumping the SDK to 7.+, otherwise it will crash at runtime due to binary incompatibility.
40+
(E.g. if you're using `-timber`, `-okhttp` or other packages)
41+
342
## 6.30.0
443

544
### Features

buildSrc/src/main/java/Config.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ object Config {
3232
object Android {
3333
private val sdkVersion = 33
3434

35-
val minSdkVersion = 14
35+
val minSdkVersion = 19
3636
val minSdkVersionOkHttp = 21
37-
val minSdkVersionNdk = 16
37+
val minSdkVersionNdk = 19
3838
val minSdkVersionCompose = 21
3939
val targetSdkVersion = sdkVersion
4040
val compileSdkVersion = sdkVersion
@@ -111,7 +111,7 @@ object Config {
111111
val retrofit2 = "$retrofit2Group:retrofit:$retrofit2Version"
112112
val retrofit2Gson = "$retrofit2Group:converter-gson:$retrofit2Version"
113113

114-
val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3"
114+
val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
115115

116116
val fragment = "androidx.fragment:fragment-ktx:1.3.5"
117117

sentry-android-core/api/sentry-android-core.api

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public final class io/sentry/android/core/AnrIntegrationFactory {
6363
public final class io/sentry/android/core/AnrV2EventProcessor : io/sentry/BackfillingEventProcessor {
6464
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
6565
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
66+
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
6667
}
6768

6869
public class io/sentry/android/core/AnrV2Integration : io/sentry/Integration, java/io/Closeable {
@@ -73,7 +74,10 @@ public class io/sentry/android/core/AnrV2Integration : io/sentry/Integration, ja
7374

7475
public final class io/sentry/android/core/AnrV2Integration$AnrV2Hint : io/sentry/hints/BlockingFlushHint, io/sentry/hints/AbnormalExit, io/sentry/hints/Backfillable {
7576
public fun <init> (JLio/sentry/ILogger;JZZ)V
77+
public fun ignoreCurrentThread ()Z
78+
public fun isFlushable (Lio/sentry/protocol/SentryId;)Z
7679
public fun mechanism ()Ljava/lang/String;
80+
public fun setFlushable (Lio/sentry/protocol/SentryId;)V
7781
public fun shouldEnrich ()Z
7882
public fun timestamp ()Ljava/lang/Long;
7983
}
@@ -205,9 +209,10 @@ public final class io/sentry/android/core/PhoneStateBreadcrumbsIntegration : io/
205209
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
206210
}
207211

208-
public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor, io/sentry/IntegrationName {
212+
public final class io/sentry/android/core/ScreenshotEventProcessor : io/sentry/EventProcessor {
209213
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;Lio/sentry/android/core/BuildInfoProvider;)V
210214
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
215+
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
211216
}
212217

213218
public final class io/sentry/android/core/SentryAndroid {
@@ -245,8 +250,10 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
245250
public fun isEnableAppLifecycleBreadcrumbs ()Z
246251
public fun isEnableAutoActivityLifecycleTracing ()Z
247252
public fun isEnableFramesTracking ()Z
253+
public fun isEnableNdk ()Z
248254
public fun isEnableNetworkEventBreadcrumbs ()Z
249255
public fun isEnableRootCheck ()Z
256+
public fun isEnableScopeSync ()Z
250257
public fun isEnableSystemEventBreadcrumbs ()Z
251258
public fun isReportHistoricalAnrs ()Z
252259
public fun setAnrEnabled (Z)V
@@ -265,8 +272,10 @@ public final class io/sentry/android/core/SentryAndroidOptions : io/sentry/Sentr
265272
public fun setEnableAppLifecycleBreadcrumbs (Z)V
266273
public fun setEnableAutoActivityLifecycleTracing (Z)V
267274
public fun setEnableFramesTracking (Z)V
275+
public fun setEnableNdk (Z)V
268276
public fun setEnableNetworkEventBreadcrumbs (Z)V
269277
public fun setEnableRootCheck (Z)V
278+
public fun setEnableScopeSync (Z)V
270279
public fun setEnableSystemEventBreadcrumbs (Z)V
271280
public fun setNativeSdkName (Ljava/lang/String;)V
272281
public fun setProfilingTracesHz (I)V
@@ -346,9 +355,10 @@ public final class io/sentry/android/core/UserInteractionIntegration : android/a
346355
public fun register (Lio/sentry/IHub;Lio/sentry/SentryOptions;)V
347356
}
348357

349-
public final class io/sentry/android/core/ViewHierarchyEventProcessor : io/sentry/EventProcessor, io/sentry/IntegrationName {
358+
public final class io/sentry/android/core/ViewHierarchyEventProcessor : io/sentry/EventProcessor {
350359
public fun <init> (Lio/sentry/android/core/SentryAndroidOptions;)V
351360
public fun process (Lio/sentry/SentryEvent;Lio/sentry/Hint;)Lio/sentry/SentryEvent;
361+
public fun process (Lio/sentry/protocol/SentryTransaction;Lio/sentry/Hint;)Lio/sentry/protocol/SentryTransaction;
352362
public static fun snapshotViewHierarchy (Landroid/app/Activity;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;
353363
public static fun snapshotViewHierarchy (Landroid/app/Activity;Ljava/util/List;Lio/sentry/util/thread/IMainThreadChecker;Lio/sentry/ILogger;)Lio/sentry/protocol/ViewHierarchy;
354364
public static fun snapshotViewHierarchy (Landroid/view/View;)Lio/sentry/protocol/ViewHierarchy;

sentry-android-core/proguard-rules.pro

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,22 @@
3131
-keepattributes LineNumberTable,SourceFile
3232

3333
# Keep Classnames for integrations
34-
-keepnames class * implements io.sentry.IntegrationName
34+
-keepnames class * implements io.sentry.Integration
35+
36+
-dontwarn io.sentry.apollo.SentryApolloInterceptor
37+
-keepnames class io.sentry.apollo.SentryApolloInterceptor
38+
39+
-dontwarn io.sentry.apollo3.SentryApollo3HttpInterceptor
40+
-keepnames class io.sentry.apollo3.SentryApollo3HttpInterceptor
41+
42+
-dontwarn io.sentry.android.okhttp.SentryOkHttpInterceptor
43+
-keepnames class io.sentry.android.okhttp.SentryOkHttpInterceptor
44+
45+
-dontwarn io.sentry.android.navigation.SentryNavigationListener
46+
-keepnames class io.sentry.android.navigation.SentryNavigationListener
47+
48+
-keepnames class io.sentry.android.core.ScreenshotEventProcessor
49+
-keepnames class io.sentry.android.core.ViewHierarchyEventProcessor
3550

3651
# Keep any custom option classes like SentryAndroidOptions, as they're loaded via reflection
3752
# Also keep method names, as they're e.g. used by native via JNI calls

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import static io.sentry.MeasurementUnit.Duration.MILLISECOND;
44
import static io.sentry.TypeCheckHint.ANDROID_ACTIVITY;
5+
import static io.sentry.util.IntegrationUtils.addIntegrationToSdkVersion;
56

6-
import android.annotation.SuppressLint;
77
import android.app.Activity;
88
import android.app.Application;
99
import android.os.Build;
@@ -127,7 +127,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
127127

128128
application.registerActivityLifecycleCallbacks(this);
129129
this.options.getLogger().log(SentryLevel.DEBUG, "ActivityLifecycleIntegration installed.");
130-
addIntegrationToSdkVersion();
130+
addIntegrationToSdkVersion(getClass());
131131
}
132132

133133
private boolean isPerformanceEnabled(final @NotNull SentryAndroidOptions options) {
@@ -192,6 +192,9 @@ private void startTracing(final @NotNull Activity activity) {
192192
final Boolean coldStart = AppStartState.getInstance().isColdStart();
193193

194194
final TransactionOptions transactionOptions = new TransactionOptions();
195+
transactionOptions.setDeadlineTimeout(
196+
TransactionOptions.DEFAULT_DEADLINE_TIMEOUT_AUTO_TRANSACTION);
197+
195198
if (options.isEnableActivityLifecycleTracingAutoFinish()) {
196199
transactionOptions.setIdleTimeout(options.getIdleTimeout());
197200
transactionOptions.setTrimEnd(true);
@@ -396,26 +399,13 @@ public synchronized void onActivityStarted(final @NotNull Activity activity) {
396399
addBreadcrumb(activity, "started");
397400
}
398401

399-
@SuppressLint("NewApi")
400402
@Override
401403
public synchronized void onActivityResumed(final @NotNull Activity activity) {
402404
if (performanceEnabled) {
403-
// app start span
404-
@Nullable final SentryDate appStartStartTime = AppStartState.getInstance().getAppStartTime();
405-
@Nullable final SentryDate appStartEndTime = AppStartState.getInstance().getAppStartEndTime();
406-
// in case the SentryPerformanceProvider is disabled it does not set the app start times,
407-
// and we need to set the end time manually here,
408-
// the start time gets set manually in SentryAndroid.init()
409-
if (appStartStartTime != null && appStartEndTime == null) {
410-
AppStartState.getInstance().setAppStartEnd();
411-
}
412-
finishAppStartSpan();
413-
414405
final @Nullable ISpan ttidSpan = ttidSpanMap.get(activity);
415406
final @Nullable ISpan ttfdSpan = ttfdSpanMap.get(activity);
416407
final View rootView = activity.findViewById(android.R.id.content);
417-
if (buildInfoProvider.getSdkInfoVersion() >= Build.VERSION_CODES.JELLY_BEAN
418-
&& rootView != null) {
408+
if (rootView != null) {
419409
FirstDrawDoneListener.registerForNextDraw(
420410
rootView, () -> onFirstFrameDrawn(ttfdSpan, ttidSpan), buildInfoProvider);
421411
} else {
@@ -540,6 +530,17 @@ private void cancelTtfdAutoClose() {
540530
}
541531

542532
private void onFirstFrameDrawn(final @Nullable ISpan ttfdSpan, final @Nullable ISpan ttidSpan) {
533+
// app start span
534+
@Nullable final SentryDate appStartStartTime = AppStartState.getInstance().getAppStartTime();
535+
@Nullable final SentryDate appStartEndTime = AppStartState.getInstance().getAppStartEndTime();
536+
// in case the SentryPerformanceProvider is disabled it does not set the app start times,
537+
// and we need to set the end time manually here,
538+
// the start time gets set manually in SentryAndroid.init()
539+
if (appStartStartTime != null && appStartEndTime == null) {
540+
AppStartState.getInstance().setAppStartEnd();
541+
}
542+
finishAppStartSpan();
543+
543544
if (options != null && ttidSpan != null) {
544545
final SentryDate endDate = options.getDateProvider().now();
545546
final long durationNanos = endDate.diff(ttidSpan.getStartDate());

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
import android.app.Application;
66
import android.content.Context;
77
import android.content.pm.PackageInfo;
8-
import android.os.Build;
98
import io.sentry.DeduplicateMultithreadedEventProcessor;
109
import io.sentry.DefaultTransactionPerformanceCollector;
1110
import io.sentry.ILogger;
11+
import io.sentry.NoOpConnectionStatusProvider;
1212
import io.sentry.SendFireAndForgetEnvelopeSender;
1313
import io.sentry.SendFireAndForgetOutboxSender;
1414
import io.sentry.SentryLevel;
1515
import io.sentry.android.core.cache.AndroidEnvelopeCache;
1616
import io.sentry.android.core.internal.debugmeta.AssetsDebugMetaLoader;
1717
import io.sentry.android.core.internal.gestures.AndroidViewGestureTargetLocator;
1818
import io.sentry.android.core.internal.modules.AssetsModulesLoader;
19+
import io.sentry.android.core.internal.util.AndroidConnectionStatusProvider;
1920
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
2021
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
2122
import io.sentry.android.fragment.FragmentLifecycleIntegration;
@@ -42,6 +43,8 @@
4243
@SuppressWarnings("Convert2MethodRef") // older AGP versions do not support method references
4344
final class AndroidOptionsInitializer {
4445

46+
static final long DEFAULT_FLUSH_TIMEOUT_MS = 4000;
47+
4548
static final String SENTRY_COMPOSE_GESTURE_INTEGRATION_CLASS_NAME =
4649
"io.sentry.compose.gestures.ComposeGestureTargetLocator";
4750

@@ -94,6 +97,9 @@ static void loadDefaultAndMetadataOptions(
9497

9598
options.setDateProvider(new SentryAndroidDateProvider());
9699

100+
// set a lower flush timeout on Android to avoid ANRs
101+
options.setFlushTimeoutMillis(DEFAULT_FLUSH_TIMEOUT_MS);
102+
97103
ManifestMetadataReader.applyMetadata(context, options, buildInfoProvider);
98104
initializeCacheDirs(context, options);
99105

@@ -126,14 +132,19 @@ static void initializeIntegrationsAndProcessors(
126132
options.setEnvelopeDiskCache(new AndroidEnvelopeCache(options));
127133
}
128134

135+
if (options.getConnectionStatusProvider() instanceof NoOpConnectionStatusProvider) {
136+
options.setConnectionStatusProvider(
137+
new AndroidConnectionStatusProvider(context, options.getLogger(), buildInfoProvider));
138+
}
139+
129140
options.addEventProcessor(new DeduplicateMultithreadedEventProcessor(options));
130141
options.addEventProcessor(
131142
new DefaultAndroidEventProcessor(context, buildInfoProvider, options));
132143
options.addEventProcessor(new PerformanceAndroidEventProcessor(options, activityFramesTracker));
133144
options.addEventProcessor(new ScreenshotEventProcessor(options, buildInfoProvider));
134145
options.addEventProcessor(new ViewHierarchyEventProcessor(options));
135146
options.addEventProcessor(new AnrV2EventProcessor(context, options, buildInfoProvider));
136-
options.setTransportGate(new AndroidTransportGate(context, options.getLogger()));
147+
options.setTransportGate(new AndroidTransportGate(options));
137148
final SentryFrameMetricsCollector frameMetricsCollector =
138149
new SentryFrameMetricsCollector(context, options, buildInfoProvider);
139150
options.setTransactionProfiler(
@@ -208,10 +219,7 @@ static void installDefaultIntegrations(
208219

209220
// Integrations are registered in the same order. NDK before adding Watch outbox,
210221
// because sentry-native move files around and we don't want to watch that.
211-
final Class<?> sentryNdkClass =
212-
isNdkAvailable(buildInfoProvider)
213-
? loadClass.loadClass(SENTRY_NDK_CLASS_NAME, options.getLogger())
214-
: null;
222+
final Class<?> sentryNdkClass = loadClass.loadClass(SENTRY_NDK_CLASS_NAME, options.getLogger());
215223
options.addIntegration(new NdkIntegration(sentryNdkClass));
216224

217225
// this integration uses android.os.FileObserver, we can't move to sentry
@@ -320,8 +328,4 @@ private static void initializeCacheDirs(
320328
final File cacheDir = new File(context.getCacheDir(), "sentry");
321329
options.setCacheDirPath(cacheDir.getAbsolutePath());
322330
}
323-
324-
private static boolean isNdkAvailable(final @NotNull BuildInfoProvider buildInfoProvider) {
325-
return buildInfoProvider.getSdkInfoVersion() >= Build.VERSION_CODES.JELLY_BEAN;
326-
}
327331
}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
package io.sentry.android.core;
22

3-
import android.content.Context;
4-
import io.sentry.ILogger;
5-
import io.sentry.android.core.internal.util.ConnectivityChecker;
3+
import io.sentry.IConnectionStatusProvider;
4+
import io.sentry.SentryOptions;
65
import io.sentry.transport.ITransportGate;
76
import org.jetbrains.annotations.NotNull;
87
import org.jetbrains.annotations.TestOnly;
98

109
final class AndroidTransportGate implements ITransportGate {
1110

12-
private final Context context;
13-
private final @NotNull ILogger logger;
11+
private final @NotNull SentryOptions options;
1412

15-
AndroidTransportGate(final @NotNull Context context, final @NotNull ILogger logger) {
16-
this.context = context;
17-
this.logger = logger;
13+
AndroidTransportGate(final @NotNull SentryOptions options) {
14+
this.options = options;
1815
}
1916

2017
@Override
2118
public boolean isConnected() {
22-
return isConnected(ConnectivityChecker.getConnectionStatus(context, logger));
19+
return isConnected(options.getConnectionStatusProvider().getConnectionStatus());
2320
}
2421

2522
@TestOnly
26-
boolean isConnected(final @NotNull ConnectivityChecker.Status status) {
23+
boolean isConnected(final @NotNull IConnectionStatusProvider.ConnectionStatus status) {
2724
// let's assume its connected if there's no permission or something as we can't really know
2825
// whether is online or not.
2926
switch (status) {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.sentry.android.core;
22

3+
import static io.sentry.util.IntegrationUtils.addIntegrationToSdkVersion;
4+
35
import android.annotation.SuppressLint;
46
import android.content.Context;
57
import io.sentry.Hint;
@@ -74,7 +76,7 @@ private void register(final @NotNull IHub hub, final @NotNull SentryAndroidOptio
7476
anrWatchDog.start();
7577

7678
options.getLogger().log(SentryLevel.DEBUG, "AnrIntegration installed.");
77-
addIntegrationToSdkVersion();
79+
addIntegrationToSdkVersion(getClass());
7880
}
7981
}
8082
}
@@ -161,5 +163,10 @@ public String mechanism() {
161163
public boolean ignoreCurrentThread() {
162164
return true;
163165
}
166+
167+
@Override
168+
public @Nullable Long timestamp() {
169+
return null;
170+
}
164171
}
165172
}

0 commit comments

Comments
 (0)