Skip to content

Commit 639e47c

Browse files
authored
Merge cfc52d9 into 75bfb8b
2 parents 75bfb8b + cfc52d9 commit 639e47c

File tree

186 files changed

+11047
-419
lines changed

Some content is hidden

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

186 files changed

+11047
-419
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

3-
## Unreleased
3+
## 7.11.0-alpha.2
4+
5+
- Session Replay for Android ([#3339](https://github.com/getsentry/sentry-java/pull/3339))
6+
7+
We released our third Alpha version of the SDK with support. To get access, it requires adding your Sentry org to our feature flag. Please let us know on the [waitlist](https://sentry.io/lp/mobile-replay-beta/) if you're interested
48

59
### Fixes
610

build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ subprojects {
112112
"sentry-android-ndk",
113113
"sentry-android-okhttp",
114114
"sentry-android-sqlite",
115+
"sentry-android-replay",
115116
"sentry-android-timber"
116117
)
117118
if (jacocoAndroidModules.contains(name)) {
@@ -296,7 +297,9 @@ private val androidLibs = setOf(
296297
"sentry-android-navigation",
297298
"sentry-android-okhttp",
298299
"sentry-android-timber",
299-
"sentry-compose-android"
300+
"sentry-compose-android",
301+
"sentry-android-sqlite",
302+
"sentry-android-replay"
300303
)
301304

302305
private val androidXLibs = listOf(

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ object Config {
3434

3535
val minSdkVersion = 19
3636
val minSdkVersionOkHttp = 21
37+
val minSdkVersionReplay = 19
3738
val minSdkVersionNdk = 19
3839
val minSdkVersionCompose = 21
3940
val targetSdkVersion = sdkVersion
@@ -194,6 +195,7 @@ object Config {
194195
val jsonUnit = "net.javacrumbs.json-unit:json-unit:2.32.0"
195196
val hsqldb = "org.hsqldb:hsqldb:2.6.1"
196197
val javaFaker = "com.github.javafaker:javafaker:1.0.2"
198+
val msgpack = "org.msgpack:msgpack-core:0.9.8"
197199
}
198200

199201
object QualityPlugins {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android.useAndroidX=true
1010
android.defaults.buildfeatures.buildconfig=true
1111

1212
# Release information
13-
versionName=7.10.0
13+
versionName=7.11.0-alpha.2
1414

1515
# Override the SDK name on native crashes on Android
1616
sentryAndroidSdkName=sentry.native.android

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ public final class io/sentry/android/core/CurrentActivityIntegration : android/a
184184
public final class io/sentry/android/core/DeviceInfoUtil {
185185
public fun <init> (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)V
186186
public fun collectDeviceInformation (ZZ)Lio/sentry/protocol/Device;
187+
public static fun getBatteryLevel (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Float;
187188
public static fun getInstance (Landroid/content/Context;Lio/sentry/android/core/SentryAndroidOptions;)Lio/sentry/android/core/DeviceInfoUtil;
188189
public fun getOperatingSystem ()Lio/sentry/protocol/OperatingSystem;
189190
public fun getSideLoadedInfo ()Lio/sentry/android/core/ContextUtils$SideLoadedInfo;
191+
public static fun isCharging (Landroid/content/Intent;Lio/sentry/SentryOptions;)Ljava/lang/Boolean;
190192
public static fun resetInstance ()V
191193
}
192194

sentry-android-core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ dependencies {
7676
api(projects.sentry)
7777
compileOnly(projects.sentryAndroidFragment)
7878
compileOnly(projects.sentryAndroidTimber)
79+
compileOnly(projects.sentryAndroidReplay)
7980
compileOnly(projects.sentryCompose)
8081
compileOnly(projects.sentryComposeHelper)
8182

@@ -104,6 +105,7 @@ dependencies {
104105
testImplementation(projects.sentryTestSupport)
105106
testImplementation(projects.sentryAndroidFragment)
106107
testImplementation(projects.sentryAndroidTimber)
108+
testImplementation(projects.sentryAndroidReplay)
107109
testImplementation(projects.sentryComposeHelper)
108110
testImplementation(projects.sentryAndroidNdk)
109111
testRuntimeOnly(Config.Libs.composeUi)

sentry-android-core/proguard-rules.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,9 @@
7272
-keepnames class io.sentry.exception.SentryHttpClientException
7373

7474
##---------------End: proguard configuration for sentry-okhttp ----------
75+
76+
##---------------Begin: proguard configuration for sentry-android-replay ----------
77+
-dontwarn io.sentry.android.replay.ReplayIntegration
78+
-dontwarn io.sentry.android.replay.DefaultReplayBreadcrumbConverter
79+
-keepnames class io.sentry.android.replay.ReplayIntegration
80+
##---------------End: proguard configuration for sentry-android-replay ----------

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
import io.sentry.android.core.internal.util.SentryFrameMetricsCollector;
2323
import io.sentry.android.core.performance.AppStartMetrics;
2424
import io.sentry.android.fragment.FragmentLifecycleIntegration;
25+
import io.sentry.android.replay.DefaultReplayBreadcrumbConverter;
26+
import io.sentry.android.replay.ReplayIntegration;
2527
import io.sentry.android.timber.SentryTimberIntegration;
2628
import io.sentry.cache.PersistingOptionsObserver;
2729
import io.sentry.cache.PersistingScopeObserver;
2830
import io.sentry.compose.gestures.ComposeGestureTargetLocator;
2931
import io.sentry.compose.viewhierarchy.ComposeViewHierarchyExporter;
3032
import io.sentry.internal.gestures.GestureTargetLocator;
3133
import io.sentry.internal.viewhierarchy.ViewHierarchyExporter;
34+
import io.sentry.transport.CurrentDateProvider;
3235
import io.sentry.transport.NoOpEnvelopeCache;
3336
import io.sentry.util.LazyEvaluator;
3437
import io.sentry.util.Objects;
@@ -237,7 +240,8 @@ static void installDefaultIntegrations(
237240
final @NotNull LoadClass loadClass,
238241
final @NotNull ActivityFramesTracker activityFramesTracker,
239242
final boolean isFragmentAvailable,
240-
final boolean isTimberAvailable) {
243+
final boolean isTimberAvailable,
244+
final boolean isReplayAvailable) {
241245

242246
// Integration MUST NOT cache option values in ctor, as they will be configured later by the
243247
// user
@@ -302,6 +306,13 @@ static void installDefaultIntegrations(
302306
new NetworkBreadcrumbsIntegration(context, buildInfoProvider, options.getLogger()));
303307
options.addIntegration(new TempSensorBreadcrumbsIntegration(context));
304308
options.addIntegration(new PhoneStateBreadcrumbsIntegration(context));
309+
if (isReplayAvailable) {
310+
final ReplayIntegration replay =
311+
new ReplayIntegration(context, CurrentDateProvider.getInstance());
312+
replay.setBreadcrumbConverter(new DefaultReplayBreadcrumbConverter());
313+
options.addIntegration(replay);
314+
options.setReplayController(replay);
315+
}
305316
}
306317

307318
/**

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.sentry.SentryBaseEvent;
1111
import io.sentry.SentryEvent;
1212
import io.sentry.SentryLevel;
13+
import io.sentry.SentryReplayEvent;
1314
import io.sentry.android.core.internal.util.AndroidMainThreadChecker;
1415
import io.sentry.android.core.performance.AppStartMetrics;
1516
import io.sentry.android.core.performance.TimeSpan;
@@ -303,4 +304,17 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {
303304

304305
return transaction;
305306
}
307+
308+
@Override
309+
public @NotNull SentryReplayEvent process(
310+
final @NotNull SentryReplayEvent event, final @NotNull Hint hint) {
311+
final boolean applyScopeData = shouldApplyScopeData(event, hint);
312+
if (applyScopeData) {
313+
processNonCachedEvent(event, hint);
314+
}
315+
316+
setCommons(event, false, applyScopeData);
317+
318+
return event;
319+
}
306320
}

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import android.util.DisplayMetrics;
1717
import io.sentry.DateUtils;
1818
import io.sentry.SentryLevel;
19+
import io.sentry.SentryOptions;
1920
import io.sentry.android.core.internal.util.CpuInfoUtils;
2021
import io.sentry.android.core.internal.util.DeviceOrientations;
2122
import io.sentry.android.core.internal.util.RootChecker;
@@ -184,8 +185,8 @@ public ContextUtils.SideLoadedInfo getSideLoadedInfo() {
184185
private void setDeviceIO(final @NotNull Device device, final boolean includeDynamicData) {
185186
final Intent batteryIntent = getBatteryIntent();
186187
if (batteryIntent != null) {
187-
device.setBatteryLevel(getBatteryLevel(batteryIntent));
188-
device.setCharging(isCharging(batteryIntent));
188+
device.setBatteryLevel(getBatteryLevel(batteryIntent, options));
189+
device.setCharging(isCharging(batteryIntent, options));
189190
device.setBatteryTemperature(getBatteryTemperature(batteryIntent));
190191
}
191192

@@ -270,7 +271,8 @@ private Intent getBatteryIntent() {
270271
* @return the device's current battery level (as a percentage of total), or null if unknown
271272
*/
272273
@Nullable
273-
private Float getBatteryLevel(final @NotNull Intent batteryIntent) {
274+
public static Float getBatteryLevel(
275+
final @NotNull Intent batteryIntent, final @NotNull SentryOptions options) {
274276
try {
275277
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
276278
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
@@ -294,7 +296,8 @@ private Float getBatteryLevel(final @NotNull Intent batteryIntent) {
294296
* @return whether or not the device is currently plugged in and charging, or null if unknown
295297
*/
296298
@Nullable
297-
private Boolean isCharging(final @NotNull Intent batteryIntent) {
299+
public static Boolean isCharging(
300+
final @NotNull Intent batteryIntent, final @NotNull SentryOptions options) {
298301
try {
299302
int plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
300303
return plugged == BatteryManager.BATTERY_PLUGGED_AC

0 commit comments

Comments
 (0)