Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/gradle/actions-bb0…
Browse files Browse the repository at this point in the history
…c460cbf5354b0cddd15bacdf0d6aaa3e5a32b
  • Loading branch information
stefanosiano authored Oct 17, 2024
2 parents 9dccc0b + 2a8b4fe commit 6a8b496
Show file tree
Hide file tree
Showing 39 changed files with 91 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/agp-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:

# We tried to use the cache action to cache gradle stuff, but it made tests slower and timeout
- name: Run instrumentation tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # pin@v2
with:
api-level: 30
force-avd-creation: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: make preMerge

- name: Upload coverage to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v4
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # pin@v4
with:
name: sentry-java
fail_ci_if_error: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
gradle-home-cache-cleanup: true

- name: Initialize CodeQL
uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # pin@v2
uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b # pin@v2
with:
languages: ${{ matrix.language }}

Expand All @@ -55,4 +55,4 @@ jobs:
./gradlew buildForCodeQL
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # pin@v2
uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b # pin@v2
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- Vendor `java.util.Random` and replace `java.security.SecureRandom` usages ([#3783](https://github.com/getsentry/sentry-java/pull/3783))
- Fix potential ANRs due to NDK scope sync ([#3754](https://github.com/getsentry/sentry-java/pull/3754))
- Fix potential ANRs due to NDK System.loadLibrary calls ([#3670](https://github.com/getsentry/sentry-java/pull/3670))
- Fix slow `Log` calls on app startup ([#3793](https://github.com/getsentry/sentry-java/pull/3793))
- Fix slow Integration name parsing ([#3794](https://github.com/getsentry/sentry-java/pull/3794))
- Session Replay: Reduce startup and capture overhead ([#3799](https://github.com/getsentry/sentry-java/pull/3799))

## 7.15.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
if (enabled) {
application.registerActivityLifecycleCallbacks(this);
options.getLogger().log(SentryLevel.DEBUG, "ActivityBreadcrumbIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ActivityBreadcrumbs");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio

application.registerActivityLifecycleCallbacks(this);
this.options.getLogger().log(SentryLevel.DEBUG, "ActivityLifecycleIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ActivityLifecycle");
}

private boolean isPerformanceEnabled(final @NotNull SentryAndroidOptions options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public void log(
final @NotNull SentryLevel level,
final @NotNull String message,
final @Nullable Object... args) {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
if (args == null || args.length == 0) {
Log.println(toLogcatLevel(level), tag, message);
} else {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
}
}

@SuppressWarnings("AnnotateFormatMethod")
Expand All @@ -36,7 +40,11 @@ public void log(
final @Nullable Throwable throwable,
final @NotNull String message,
final @Nullable Object... args) {
log(level, String.format(message, args), throwable);
if (args == null || args.length == 0) {
log(level, message, throwable);
} else {
log(level, String.format(message, args), throwable);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void register(final @NotNull IHub hub, final @NotNull SentryAndroidOptio
.log(SentryLevel.DEBUG, "AnrIntegration enabled: %s", options.isAnrEnabled());

if (options.isAnrEnabled()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Anr");
try {
options
.getExecutorService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
options.getLogger().log(SentryLevel.DEBUG, "Failed to start AnrProcessor.", e);
}
options.getLogger().log(SentryLevel.DEBUG, "AnrV2Integration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AnrV2");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
options
.getLogger()
.log(SentryLevel.DEBUG, "AppComponentsBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AppComponentsBreadcrumbs");
} catch (Throwable e) {
this.options.setEnableAppComponentBreadcrumbs(false);
options.getLogger().log(SentryLevel.INFO, e, "ComponentCallbacks2 is not available.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void addObserver(final @NotNull IHub hub) {
try {
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);
options.getLogger().log(SentryLevel.DEBUG, "AppLifecycleIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("AppLifecycle");
} catch (Throwable e) {
// This is to handle a potential 'AbstractMethodError' gracefully. The error is triggered in
// connection with conflicting dependencies of the androidx.lifecycle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private static boolean readBool(
final @NotNull String key,
final boolean defaultValue) {
final boolean value = metadata.getBoolean(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -450,10 +450,10 @@ private static boolean readBool(
if (metadata.getSerializable(key) != null) {
final boolean nonNullDefault = defaultValue == null ? false : true;
final boolean bool = metadata.getBoolean(key, nonNullDefault);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, bool);
logger.log(SentryLevel.DEBUG, key + " read: " + bool);
return bool;
} else {
logger.log(SentryLevel.DEBUG, "%s used default %s", key, defaultValue);
logger.log(SentryLevel.DEBUG, key + " used default " + defaultValue);
return defaultValue;
}
}
Expand All @@ -464,7 +464,7 @@ private static boolean readBool(
final @NotNull String key,
final @Nullable String defaultValue) {
final String value = metadata.getString(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -474,14 +474,14 @@ private static boolean readBool(
final @NotNull String key,
final @NotNull String defaultValue) {
final String value = metadata.getString(key, defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

private static @Nullable List<String> readList(
final @NotNull Bundle metadata, final @NotNull ILogger logger, final @NotNull String key) {
final String value = metadata.getString(key);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
if (value != null) {
return Arrays.asList(value.split(",", -1));
} else {
Expand All @@ -493,7 +493,7 @@ private static boolean readBool(
final @NotNull Bundle metadata, final @NotNull ILogger logger, final @NotNull String key) {
// manifest meta-data only reads float
final Double value = ((Float) metadata.getFloat(key, -1)).doubleValue();
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -504,7 +504,7 @@ private static long readLong(
final long defaultValue) {
// manifest meta-data only reads int if the value is not big enough
final long value = metadata.getInt(key, (int) defaultValue);
logger.log(SentryLevel.DEBUG, "%s read: %s", key, value);
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}

Expand All @@ -524,7 +524,6 @@ static boolean isAutoInit(final @NotNull Context context, final @NotNull ILogger
if (metadata != null) {
autoInit = readBool(metadata, logger, AUTO_INIT, true);
}
logger.log(SentryLevel.INFO, "Retrieving auto-init from AndroidManifest.xml");
} catch (Throwable e) {
logger.log(SentryLevel.ERROR, "Failed to read auto-init from android manifest metadata.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final void register(final @NotNull IHub hub, final @NotNull SentryOptions
method.invoke(null, args);

this.options.getLogger().log(SentryLevel.DEBUG, "NdkIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Ndk");
} catch (NoSuchMethodException e) {
disableNdkIntegration(this.options);
this.options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void run() {
context, logger, buildInfoProvider, networkCallback);
if (registered) {
logger.log(SentryLevel.DEBUG, "NetworkBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("NetworkBreadcrumbs");
} else {
logger.log(
SentryLevel.DEBUG, "NetworkBreadcrumbsIntegration not installed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void startTelephonyListener(
telephonyManager.listen(listener, android.telephony.PhoneStateListener.LISTEN_CALL_STATE);

options.getLogger().log(SentryLevel.DEBUG, "PhoneStateBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("PhoneStateBreadcrumbs");
} catch (Throwable e) {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ScreenshotEventProcessor(
DEBOUNCE_MAX_EXECUTIONS);

if (options.isAttachScreenshot()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("Screenshot");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.sentry.android.core;

import static io.sentry.util.IntegrationUtils.addIntegrationToSdkVersion;

import io.sentry.DataCategory;
import io.sentry.IConnectionStatusProvider;
import io.sentry.IHub;
Expand Down Expand Up @@ -54,6 +56,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
options.getLogger().log(SentryLevel.ERROR, "No cache dir path is defined in options.");
return;
}
addIntegrationToSdkVersion("SendCachedEnvelope");

sendCachedEnvelopes(hub, this.options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void startSystemEventsReceiver(
// registerReceiver can throw SecurityException but it's not documented in the official docs
ContextUtils.registerReceiver(context, options, receiver, filter);
options.getLogger().log(SentryLevel.DEBUG, "SystemEventsBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("SystemEventsBreadcrumbs");
} catch (Throwable e) {
options.setEnableSystemEventBreadcrumbs(false);
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void startSensorListener(final @NotNull SentryOptions options) {
sensorManager.registerListener(this, defaultSensor, SensorManager.SENSOR_DELAY_NORMAL);

options.getLogger().log(SentryLevel.DEBUG, "TempSensorBreadcrumbsIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("TempSensorBreadcrumbs");
} else {
options.getLogger().log(SentryLevel.INFO, "TYPE_AMBIENT_TEMPERATURE is not available.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void register(@NotNull IHub hub, @NotNull SentryOptions options) {
if (isAndroidXAvailable) {
application.registerActivityLifecycleCallbacks(this);
this.options.getLogger().log(SentryLevel.DEBUG, "UserInteractionIntegration installed.");
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("UserInteraction");
} else {
options
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ViewHierarchyEventProcessor(final @NotNull SentryAndroidOptions options)
DEBOUNCE_MAX_EXECUTIONS);

if (options.isAttachViewHierarchy()) {
addIntegrationToSdkVersion(getClass());
addIntegrationToSdkVersion("ViewHierarchy");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.app.ApplicationExitInfo
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.os.Looper
import android.os.SystemClock
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -55,6 +56,7 @@ import org.mockito.kotlin.spy
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.robolectric.Shadows
import org.robolectric.annotation.Config
import org.robolectric.shadow.api.Shadow
import org.robolectric.shadows.ShadowActivityManager
Expand Down Expand Up @@ -439,8 +441,10 @@ class SentryAndroidTest {
await.withAlias("Failed because of BeforeSend callback above, but we swallow BeforeSend exceptions, hence the timeout")
.untilTrue(asserted)

// Execute all posted tasks
Shadows.shadowOf(Looper.getMainLooper()).idle()

// assert that persisted values have changed
options.executorService.close(10000L) // finalizes all enqueued persisting tasks
assertEquals(
"TestActivity",
PersistingScopeObserver.read(options, TRANSACTION_FILENAME, String::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FragmentLifecycleIntegration(

application.registerActivityLifecycleCallbacks(this)
options.logger.log(DEBUG, "FragmentLifecycleIntegration installed.")
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("FragmentLifecycle")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SentryNavigationListener @JvmOverloads constructor(
private var activeTransaction: ITransaction? = null

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("NavigationListener")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SentryOkHttpInterceptor(
constructor(beforeSpan: BeforeSpanCallback) : this(HubAdapter.getInstance(), beforeSpan)

init {
addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("OkHttp")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-okhttp", BuildConfig.VERSION_NAME)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import kotlin.LazyThreadSafetyMode.NONE
public open class DefaultReplayBreadcrumbConverter : ReplayBreadcrumbConverter {
internal companion object {
private val snakecasePattern by lazy(NONE) { "_[a-z]".toRegex() }
private val supportedNetworkData = setOf(
"status_code",
"method",
"response_content_length",
"request_content_length",
"http.response_content_length",
"http.request_content_length"
)
private val supportedNetworkData by lazy(NONE) {
setOf(
"status_code",
"method",
"response_content_length",
"request_content_length",
"http.response_content_length",
"http.request_content_length"
)
}
}

private var lastConnectivityState: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public class ReplayIntegration(
options.logger.log(INFO, "ComponentCallbacks is not available, orientation changes won't be handled by Session replay", e)
}

addIntegrationToSdkVersion(javaClass)
addIntegrationToSdkVersion("Replay")
SentryIntegrationPackageStorage.getInstance()
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)

Expand Down
Loading

0 comments on commit 6a8b496

Please sign in to comment.