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

feat: replay #1736

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,19 @@ Expected to exist:
<Error Condition="!Exists('$(SentryAndroidRoot)')" Text="Couldn't find the Android root at $(SentryAndroidRoot)." />
<Message Importance="High" Text="Building Sentry Android SDK." />

<Exec WorkingDirectory="$(SentryAndroidRoot)" EnvironmentVariables="JAVA_HOME=$(JAVA_HOME_17_X64)" Command="./gradlew -PsentryAndroidSdkName=sentry.native.android.unity :sentry-android-core:assembleRelease :sentry-android-ndk:assembleRelease :sentry:jar --no-daemon --stacktrace --warning-mode none" />
<Exec WorkingDirectory="$(SentryAndroidRoot)" EnvironmentVariables="JAVA_HOME=$(JAVA_HOME_17_X64)" Command="./gradlew -PsentryAndroidSdkName=sentry.native.android.unity :sentry-android-core:assembleRelease :sentry-android-ndk:assembleRelease :sentry-android-replay:assembleRelease :sentry:jar --no-daemon --stacktrace --warning-mode none" />

<ItemGroup>
<AndroidSdkArtifacts Include="$(SentryAndroidRoot)sentry-android-ndk/build/outputs/aar/sentry-android-ndk-release.aar" />
<AndroidSdkArtifacts Include="$(SentryAndroidRoot)sentry-android-core/build/outputs/aar/sentry-android-core-release.aar" />
<AndroidSdkArtifacts Include="$(SentryAndroidRoot)sentry-android-replay/build/outputs/aar/sentry-android-replay-release.aar" />
</ItemGroup>

<Copy SourceFiles="@(AndroidSdkArtifacts)" DestinationFiles="@(AndroidSdkArtifacts->'$(SentryAndroidArtifactsDestination)%(RecursiveDir)%(Filename)%(Extension)')" />
<Exec WorkingDirectory="$(SentryAndroidRoot)" Command="cp sentry/build/libs/sentry*.jar $(SentryAndroidArtifactsDestination)sentry.jar" />

<ItemGroup>
<SentryJarArtifact Include="$(SentryAndroidRoot)/sentry/build/libs/sentry*.jar" />
</ItemGroup>
<Copy SourceFiles="@(SentryJarArtifact)" DestinationFiles="@(SentryJarArtifact->'$(SentryAndroidArtifactsDestination)sentry.jar')" />
Comment on lines +199 to +202
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<exec> with cp didn't work on Windows


<Error Condition="!Exists('$(SentryAndroidArtifactsDestination)')" Text="Failed to build the Android SDK." />
</Target>
Expand Down
3 changes: 3 additions & 0 deletions package-dev/Plugins/Android/proguard-sentry-unity.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
-keep class io.sentry.Scope { *; }
-keep class io.sentry.ScopeCallback { *; }
-keep class io.sentry.protocol.** { *; }

# TODO Copy proguard rules from sentry-android-* in msbuild
-keep class io.sentry.** { *; }
16 changes: 16 additions & 0 deletions src/Sentry.Unity.Editor/Android/AndroidManifestConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ internal void ModifyManifest(string basePath)
androidManifest.SetAutoAppLifecycleBreadcrumbs(false);
androidManifest.SetAnr(false);
androidManifest.SetPersistentScopeObserver(false);
androidManifest.SetReplay(1.0, 1.0);

// TODO: All SentryOptions and create specific Android options

Expand Down Expand Up @@ -444,6 +445,21 @@ internal void SetNdkScopeSync(bool enableNdkScopeSync)

internal void SetDebug(bool debug) => SetMetaData($"{SentryPrefix}.debug", debug ? "true" : "false");

internal void SetReplay(double? sessionSampleRate, double? errorSampleRate)
{
if (sessionSampleRate != null)
{
// https://github.com/getsentry/sentry-java/issues/3603
// SetMetaData($"{SentryPrefix}.session-replay.session-sample-rate", sessionSampleRate.ToString());
SetMetaData($"{SentryPrefix}.session-replay.session-sample-rate", "1.0");
}
if (errorSampleRate != null)
{
// SetMetaData($"{SentryPrefix}.session-replay.error-sample-rate", errorSampleRate.ToString());
SetMetaData($"{SentryPrefix}.session-replay.error-sample-rate", "1.0");
}
}

// https://github.com/getsentry/sentry-java/blob/db4dfc92f202b1cefc48d019fdabe24d487db923/sentry/src/main/java/io/sentry/SentryLevel.java#L4-L9
internal void SetLevel(SentryLevel level) =>
SetMetaData($"{SentryPrefix}.debug.level", level switch
Expand Down
3 changes: 2 additions & 1 deletion src/Sentry.Unity.Editor/Android/GradleSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ internal class GradleSetup

public const string SdkDependencies = @"dependencies {
implementation(name: 'sentry-android-ndk-release', ext:'aar')
implementation(name: 'sentry-android-core-release', ext:'aar')";
implementation(name: 'sentry-android-core-release', ext:'aar')
implementation(name: 'sentry-android-replay-release', ext:'aar')";
public const string DependenciesAddedMessage = "The Sentry Gradle dependencies have already been added.";
private readonly string _unityLibraryGradle;

Expand Down
1 change: 1 addition & 0 deletions test/Scripts.Tests/package-release.zip.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Plugins/Android/proguard-sentry-unity.pro
Plugins/Android/proguard-sentry-unity.pro.meta
Plugins/Android/Sentry~/sentry-android-core-release.aar
Plugins/Android/Sentry~/sentry-android-ndk-release.aar
Plugins/Android/Sentry~/sentry-android-replay-release.aar
Plugins/Android/Sentry~/sentry.jar
Plugins/Windows/Sentry.meta
Plugins/Windows/Sentry/crashpad_handler.exe
Expand Down
Loading