diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6de20b3e5..da60a46fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: type: string env: - LOWEST_SUPPORTED_UNITY_VERSION: 2019 + LOWEST_SUPPORTED_UNITY_VERSION: 2020 DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_NOLOGO: 1 GITHUB_ACTOR: ${{ github.actor }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a495e083d..56117b6ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: workflow_dispatch: # e.g. to manually trigger on foreign PRs env: - LOWEST_SUPPORTED_UNITY_VERSION: 2019 + LOWEST_SUPPORTED_UNITY_VERSION: 2020 DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_NOLOGO: 1 @@ -54,7 +54,7 @@ jobs: fail-fast: false matrix: # Building the SDK with Unity 2022 and newer requires ns2.1 - skipping for now - unity-version: ["2019", "2020", "2021"] + unity-version: ["2020", "2021"] uses: ./.github/workflows/build.yml with: unity-version: ${{ matrix.unity-version }} @@ -87,7 +87,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] uses: ./.github/workflows/smoke-test-create.yml with: unity-version: ${{ matrix.unity-version }} @@ -101,7 +101,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] platform: ["WebGL", "Linux"] include: - platform: WebGL @@ -140,14 +140,6 @@ jobs: run: ./scripts/ci-docker.sh '${{ matrix.unity-version }}' '${{ matrix.platform }}${{ matrix.image-suffix }}' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}' shell: bash - # Workaround for missing libMonoPosixHelper.so - # See https://github.com/getsentry/sentry-unity/pull/1295 - - name: Install mono-devel - if: ${{ matrix.unity-version == '2019' }} - run: | - docker exec --user root unity apt-get update - docker exec --user root unity apt-get -y -q install mono-devel - - name: Download IntegrationTest project uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: @@ -213,7 +205,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] uses: ./.github/workflows/smoke-test-build-android.yml with: unity-version: ${{ matrix.unity-version }} @@ -232,7 +224,7 @@ jobs: matrix: api-level: [30, 31, 34] # last updated January 2025 init-type: ["runtime", "buildtime"] - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] smoke-test-build-ios: name: Build iOS ${{ matrix.unity-version }} Smoke Test @@ -242,7 +234,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] uses: ./.github/workflows/smoke-test-build-ios.yml with: unity-version: ${{ matrix.unity-version }} @@ -255,7 +247,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] init-type: ["runtime", "buildtime"] uses: ./.github/workflows/smoke-test-compile-ios.yml with: @@ -274,7 +266,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] # Check https://support.apple.com/en-us/HT201222 for the latest minor version for a given major one. # https://developer.apple.com/support/app-store/ shows that of all iOS devices # - `iOS 17`: 86 % @@ -295,7 +287,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] platform: ["WebGL", "Linux"] steps: - name: Checkout @@ -333,7 +325,7 @@ jobs: strategy: fail-fast: false matrix: - unity-version: ["2019", "2022", "6000"] + unity-version: ["2020", "2022", "6000"] # os: ["windows", "macos"] os: ["windows"] include: diff --git a/.github/workflows/smoke-test-build-android.yml b/.github/workflows/smoke-test-build-android.yml index 8a817eaf3..84db570b6 100644 --- a/.github/workflows/smoke-test-build-android.yml +++ b/.github/workflows/smoke-test-build-android.yml @@ -37,14 +37,6 @@ jobs: run: ./scripts/ci-docker.sh "${UNITY_VERSION}" 'android' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}' shell: bash - # Workaround for missing libMonoPosixHelper.so - # See https://github.com/getsentry/sentry-unity/pull/1295 - - name: Install mono-devel - if: ${{ inputs.unity-version == '2019' }} - run: | - docker exec --user root unity apt-get update - docker exec --user root unity apt-get -y -q install mono-devel - - name: Download IntegrationTest project uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: diff --git a/.github/workflows/smoke-test-build-ios.yml b/.github/workflows/smoke-test-build-ios.yml index 3d7ee8c12..a8ea21efb 100644 --- a/.github/workflows/smoke-test-build-ios.yml +++ b/.github/workflows/smoke-test-build-ios.yml @@ -43,14 +43,6 @@ jobs: run: ./scripts/ci-docker.sh "${UNITY_VERSION}" 'iOS' '${{ secrets.UNITY_LICENSE_SERVER_CONFIG }}' shell: bash - # Workaround for missing libMonoPosixHelper.so - # See https://github.com/getsentry/sentry-unity/pull/1295 - - name: Install mono-devel - if: ${{ inputs.unity-version == '2019' }} - run: | - docker exec --user root unity apt-get update - docker exec --user root unity apt-get -y -q install mono-devel - - name: Download IntegrationTest project uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: diff --git a/.github/workflows/update-deps.yml b/.github/workflows/update-deps.yml index 1423b8e66..47e42798c 100644 --- a/.github/workflows/update-deps.yml +++ b/.github/workflows/update-deps.yml @@ -44,7 +44,7 @@ jobs: strategy: fail-fast: false matrix: - unity-prefix: ['2019', '2020', '2021', '2022', '6000'] + unity-prefix: ['2020', '2021', '2022', '6000'] steps: - name: Find the latest Unity version id: version-select @@ -61,7 +61,7 @@ jobs: ssh-key: ${{ secrets.CI_DEPLOY_KEY }} - name: Update sample ProjectVersion.txt - if: ${{ matrix.unity-prefix == '2019' }} + if: ${{ matrix.unity-prefix == '2020' }} run: | "m_EditorVersion: ${{ steps.version-select.outputs.version }}`nm_EditorVersionWithRevision: ${{ steps.version-select.outputs.version }} (${{ steps.version-select.outputs.changeset }})" ` | Out-File "samples\unity-of-bugs\ProjectSettings\ProjectVersion.txt" diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9e5f07a..943a701a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Breaking Changes + +- Dropped support for Unity 2019. It reached End of Life in 2022 ([#2231](https://github.com/getsentry/sentry-unity/pull/2231)) + ### Features - The SDK now comes with a `SentryUserFeedback` prefab ready to be used. You can drag and drop it into your scene or diff --git a/Directory.Build.props b/Directory.Build.props index 21b3dbb64..d3cab9008 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,7 +10,7 @@ strict false - + netstandard2.0 diff --git a/package-dev/Editor/SentryUserFeedbackEditor.cs.meta b/package-dev/Editor/SentryUserFeedbackEditor.cs.meta index 5039054b7..51e8fcf6e 100644 --- a/package-dev/Editor/SentryUserFeedbackEditor.cs.meta +++ b/package-dev/Editor/SentryUserFeedbackEditor.cs.meta @@ -1,2 +1,11 @@ fileFormatVersion: 2 -guid: 788f34b6497dc4ab881dffd0e4932cd9 \ No newline at end of file +guid: 788f34b6497dc4ab881dffd0e4932cd9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package-dev/Runtime/SentryIntegrations.cs b/package-dev/Runtime/SentryIntegrations.cs index e39cbb974..1c1e64c9b 100644 --- a/package-dev/Runtime/SentryIntegrations.cs +++ b/package-dev/Runtime/SentryIntegrations.cs @@ -1,7 +1,3 @@ -#if UNITY_2020_3_OR_NEWER -#define SENTRY_SCENE_MANAGER_TRACING_INTEGRATION -#endif - #if !UNITY_EDITOR #if UNITY_WEBGL #define SENTRY_WEBGL @@ -27,21 +23,8 @@ public static void Configure(SentryUnityOptions options) { options.AddIntegration(new StartupTracingIntegration()); } -#endif -#if SENTRY_SCENE_MANAGER_TRACING_INTEGRATION - if (options.AutoSceneLoadTraces) - { - options.AddIntegration(new SceneManagerTracingIntegration()); - } #endif } - else - { -#if SENTRY_SCENE_MANAGER_TRACING_INTEGRATION - options.DiagnosticLogger?.LogDebug("Skipping SceneManagerTracing integration because performance tracing is disabled."); -#endif - } - } } @@ -136,63 +119,4 @@ public static void AfterSceneLoad() } } #endif - -#if SENTRY_SCENE_MANAGER_TRACING_INTEGRATION - public class SceneManagerTracingIntegration : ISdkIntegration - { - private static IDiagnosticLogger Logger; - - public void Register(IHub hub, SentryOptions options) - { - Logger = options.DiagnosticLogger; - - if (SceneManagerAPI.overrideAPI != null) - { - // TODO: Add a place to put a custom 'SceneManagerAPI' on the editor window so we can "decorate" it. - Logger?.LogWarning("Registering SceneManagerTracing integration - overwriting the previous SceneManagerAPI.overrideAPI."); - } - - SceneManagerAPI.overrideAPI = new SceneManagerTracingAPI(Logger); - } - } - - public class SceneManagerTracingAPI : SceneManagerAPI - { - public const string TransactionOperation = "scene.load"; - private const string SpanOperation = "scene.load"; - private readonly IDiagnosticLogger _logger; - - public SceneManagerTracingAPI(IDiagnosticLogger logger) - { - _logger = logger; - } - - protected override AsyncOperation LoadSceneAsyncByNameOrIndex(string sceneName, int sceneBuildIndex, LoadSceneParameters parameters, bool mustCompleteNextFrame) - { - _logger?.LogInfo("Creating '{0}' transaction for '{1}'.", TransactionOperation, sceneName); - - var transaction = SentrySdk.StartTransaction("scene.loading", TransactionOperation); - SentrySdk.ConfigureScope(scope => scope.Transaction = transaction); - - _logger?.LogDebug("Creating '{0}' span.", SpanOperation); - var span = SentrySdk.GetSpan()?.StartChild(SpanOperation, sceneName ?? $"buildIndex:{sceneBuildIndex}"); - - var asyncOp = base.LoadSceneAsyncByNameOrIndex(sceneName, sceneBuildIndex, parameters, mustCompleteNextFrame); - - // TODO: setExtra()? e.g. from the LoadSceneParameters: - // https://github.com/Unity-Technologies/UnityCsReference/blob/02d565cf3dd0f6b15069ba976064c75dc2705b08/Runtime/Export/SceneManager/SceneManager.cs#L30 - // Note: asyncOp.completed triggers in the next frame after finishing (so the time isn't precise). - // https://docs.unity3d.com/2020.3/Documentation/ScriptReference/AsyncOperation-completed.html - asyncOp.completed += _ => - { - _logger?.LogInfo("Finishing '{0}' transaction for '{1}'.", TransactionOperation, sceneName); - - span?.Finish(SpanStatus.Ok); - transaction.Finish(SpanStatus.Ok); - }; - - return asyncOp; - } - } -#endif } diff --git a/package-dev/Tests/Runtime/SentryIntegrationsTests.cs b/package-dev/Tests/Runtime/SentryIntegrationsTests.cs deleted file mode 100644 index 38bcfd66f..000000000 --- a/package-dev/Tests/Runtime/SentryIntegrationsTests.cs +++ /dev/null @@ -1,65 +0,0 @@ -#if UNITY_2020_3_OR_NEWER -#define SENTRY_SCENE_MANAGER_TRACING_INTEGRATION -#endif - -using System; -using System.Collections; -using NUnit.Framework; -using Sentry.Unity.Tests; -using UnityEngine.SceneManagement; -using UnityEngine.TestTools; - -namespace Sentry.Unity -{ - public class SentryIntegrationsTests - { -#if SENTRY_SCENE_MANAGER_TRACING_INTEGRATION - [UnityTest] - public IEnumerator Configure_TranceSampleRateOne_AddsSceneManagerTracingIntegration() - { - var options = new SentryUnityOptions - { - Dsn = "http://publickey@localhost:8000/12345", - TracesSampleRate = 1.0f - }; - - SentryIntegrations.Configure(options); - using var _ = InitSentrySdk(options); - - yield return null; - - Assert.IsNotNull(SceneManagerAPI.overrideAPI); - Assert.AreEqual(typeof(SceneManagerTracingAPI), SceneManagerAPI.overrideAPI.GetType()); - } - - // TODO: To be fixed: Currently fails if run after the integration has successfully been added. (because it doesn't get removed) - // [UnityTest] - // public IEnumerator Configure_TranceSampleRateZero_DoesNotAddSceneManagerTracingIntegration() - // { - // var options = new SentryUnityOptions - // { - // Dsn = "https://94677106febe46b88b9b9ae5efd18a00@o447951.ingest.sentry.io/5439417", - // TracesSampleRate = 0f - // }; - // - // SentryIntegrations.Configure(options); - // using var _ = InitSentrySdk(options); - // - // yield return null; - // - // Assert.IsNull(SceneManagerAPI.overrideAPI); - // } - - public static IDisposable InitSentrySdk(SentryUnityOptions options) - { - SentryUnity.Init(options); - return new SentryDisposable(); - } - - private sealed class SentryDisposable : IDisposable - { - public void Dispose() => SentrySdk.Close(); - } -#endif - } -} diff --git a/package-dev/Tests/Runtime/io.sentry.unity.dev.runtimetests.asmdef b/package-dev/Tests/Runtime/io.sentry.unity.dev.runtimetests.asmdef deleted file mode 100644 index c56e5a077..000000000 --- a/package-dev/Tests/Runtime/io.sentry.unity.dev.runtimetests.asmdef +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "io.sentry.unity.dev.runtimetests", - "rootNamespace": "", - "references": [ - "UnityEngine.TestRunner", - "UnityEditor.TestRunner", - "io.sentry.unity.dev.runtime" - ], - "includePlatforms": [], - "excludePlatforms": [ - "Android", - "GameCoreScarlett", - "GameCoreXboxOne", - "iOS", - "LinuxStandalone64", - "CloudRendering", - "Lumin", - "macOSStandalone", - "PS4", - "PS5", - "Stadia", - "Switch", - "tvOS", - "WSA", - "WebGL", - "WindowsStandalone32", - "WindowsStandalone64", - "XboxOne" - ], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "Sentry.dll", - "Sentry.Unity.dll", - "Sentry.Unity.Tests.dll", - "nunit.framework.dll" - ], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/samples/unity-of-bugs/Assets/Editor.meta b/samples/unity-of-bugs/Assets/Editor.meta new file mode 100644 index 000000000..68c2abf49 --- /dev/null +++ b/samples/unity-of-bugs/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f020a34d28f004fcd9ef49d9556b8c41 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset b/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset index e41049353..b45b58bff 100644 --- a/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset +++ b/samples/unity-of-bugs/Assets/Resources/Sentry/SentryOptions.asset @@ -40,6 +40,7 @@ MonoBehaviour: k__BackingField: 1 k__BackingField: 1 k__BackingField: 1 + k__BackingField: 1 k__BackingField: 100 k__BackingField: 1 k__BackingField: 0 diff --git a/samples/unity-of-bugs/Packages/manifest.json b/samples/unity-of-bugs/Packages/manifest.json index 0c707dc20..86a16e5e6 100644 --- a/samples/unity-of-bugs/Packages/manifest.json +++ b/samples/unity-of-bugs/Packages/manifest.json @@ -1,16 +1,47 @@ { "dependencies": { - "com.unity.ide.rider": "1.2.1", - "com.unity.mobile.android-logcat": "1.2.3", - "com.unity.test-framework": "1.1.31", - "com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.0", - "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.1", + "com.unity.collab-proxy": "2.0.7", + "com.unity.ide.rider": "3.0.36", + "com.unity.ide.visualstudio": "2.0.23", + "com.unity.ide.vscode": "1.2.5", + "com.unity.mobile.android-logcat": "1.3.2", + "com.unity.test-framework": "1.1.33", + "com.unity.textmeshpro": "3.0.9", + "com.unity.timeline": "1.4.8", + "com.unity.toolchain.macos-x86_64-linux-x86_64": "2.0.10", + "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10", "com.unity.ugui": "1.0.0", "io.sentry.unity.dev": "file:../../../package-dev", + "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", "com.unity.modules.ui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" } } diff --git a/samples/unity-of-bugs/Packages/packages-lock.json b/samples/unity-of-bugs/Packages/packages-lock.json index 077a76a09..d807f43db 100644 --- a/samples/unity-of-bugs/Packages/packages-lock.json +++ b/samples/unity-of-bugs/Packages/packages-lock.json @@ -1,5 +1,12 @@ { "dependencies": { + "com.unity.collab-proxy": { + "version": "2.0.7", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.ext.nunit": { "version": "1.0.6", "depth": 1, @@ -8,39 +15,55 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "1.2.1", + "version": "3.0.36", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.23", "depth": 0, "source": "registry", "dependencies": { - "com.unity.test-framework": "1.1.1" + "com.unity.test-framework": "1.1.9" }, "url": "https://packages.unity.com" }, + "com.unity.ide.vscode": { + "version": "1.2.5", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.mobile.android-logcat": { - "version": "1.2.3", + "version": "1.3.2", "depth": 0, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.sysroot": { - "version": "2.0.2", + "version": "2.0.10", "depth": 1, "source": "registry", "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.sysroot.linux-x86_64": { - "version": "2.0.1", + "version": "2.0.9", "depth": 1, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.2" + "com.unity.sysroot": "2.0.10" }, "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.31", + "version": "1.1.33", "depth": 0, "source": "registry", "dependencies": { @@ -50,23 +73,44 @@ }, "url": "https://packages.unity.com" }, + "com.unity.textmeshpro": { + "version": "3.0.9", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.timeline": { + "version": "1.4.8", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.com" + }, "com.unity.toolchain.macos-x86_64-linux-x86_64": { - "version": "2.0.0", + "version": "2.0.10", "depth": 0, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.0", - "com.unity.sysroot.linux-x86_64": "2.0.0" + "com.unity.sysroot": "2.0.10", + "com.unity.sysroot.linux-x86_64": "2.0.9" }, "url": "https://packages.unity.com" }, "com.unity.toolchain.win-x86_64-linux-x86_64": { - "version": "2.0.1", + "version": "2.0.10", "depth": 0, "source": "registry", "dependencies": { - "com.unity.sysroot": "2.0.2", - "com.unity.sysroot.linux-x86_64": "2.0.1" + "com.unity.sysroot": "2.0.10", + "com.unity.sysroot.linux-x86_64": "2.0.9" }, "url": "https://packages.unity.com" }, @@ -85,33 +129,86 @@ "source": "local", "dependencies": {} }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.androidjni": { "version": "1.0.0", "depth": 0, "source": "builtin", "dependencies": {} }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.audio": { "version": "1.0.0", "depth": 0, "source": "builtin", "dependencies": {} }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, "com.unity.modules.imageconversion": { "version": "1.0.0", - "depth": 1, + "depth": 0, "source": "builtin", "dependencies": {} }, "com.unity.modules.imgui": { "version": "1.0.0", - "depth": 1, + "depth": 0, "source": "builtin", "dependencies": {} }, "com.unity.modules.jsonserialize": { "version": "1.0.0", - "depth": 1, + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, "source": "builtin", "dependencies": {} }, @@ -123,17 +220,168 @@ "com.unity.modules.imageconversion": "1.0.0" } }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, "com.unity.modules.ui": { "version": "1.0.0", "depth": 0, "source": "builtin", "dependencies": {} }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.uielementsnative": "1.0.0" + } + }, + "com.unity.modules.uielementsnative": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, "com.unity.modules.unitywebrequest": { "version": "1.0.0", "depth": 0, "source": "builtin", "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } } } } diff --git a/samples/unity-of-bugs/ProjectSettings/PackageManagerSettings.asset b/samples/unity-of-bugs/ProjectSettings/PackageManagerSettings.asset index ca9e773f0..6457bee88 100644 --- a/samples/unity-of-bugs/ProjectSettings/PackageManagerSettings.asset +++ b/samples/unity-of-bugs/ProjectSettings/PackageManagerSettings.asset @@ -9,9 +9,12 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 13960, guid: 0000000000000000e000000000000000, type: 0} + m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} m_Name: m_EditorClassIdentifier: + m_EnablePreviewPackages: 0 + m_EnablePackageDependencies: 0 + m_AdvancedSettingsExpanded: 1 m_ScopedRegistriesSettingsExpanded: 1 oneTimeWarningShown: 0 m_Registries: @@ -20,6 +23,8 @@ MonoBehaviour: m_Url: https://packages.unity.com m_Scopes: [] m_IsDefault: 1 + m_Capabilities: 7 + m_ConfigSource: 0 m_UserSelectedRegistryName: m_UserAddingNewScopedRegistry: 0 m_RegistryInfoDraft: @@ -30,6 +35,8 @@ MonoBehaviour: m_Url: m_Scopes: [] m_IsDefault: 0 + m_Capabilities: 0 + m_ConfigSource: 0 m_Modified: 0 m_Name: m_Url: diff --git a/samples/unity-of-bugs/ProjectSettings/ProjectVersion.txt b/samples/unity-of-bugs/ProjectSettings/ProjectVersion.txt index 4c191298a..da76706d2 100644 --- a/samples/unity-of-bugs/ProjectSettings/ProjectVersion.txt +++ b/samples/unity-of-bugs/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.4.40f1 -m_EditorVersionWithRevision: 2019.4.40f1 (ffc62b691db5) +m_EditorVersion: 2020.3.48f1 +m_EditorVersionWithRevision: 2020.3.48f1 (b805b124c6b7) diff --git a/samples/unity-of-bugs/ProjectSettings/VersionControlSettings.asset b/samples/unity-of-bugs/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 000000000..dca288142 --- /dev/null +++ b/samples/unity-of-bugs/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/scripts/ci-env.ps1 b/scripts/ci-env.ps1 index 2a42b2640..448f9c53b 100644 --- a/scripts/ci-env.ps1 +++ b/scripts/ci-env.ps1 @@ -4,9 +4,6 @@ param ( ) switch ($name) { - "unity2019" { - return "2019.4.40f1" - } "unity2020" { return "2020.3.48f1" } diff --git a/src/Sentry.Unity/Integrations/SceneManagerTracingIntegration.cs b/src/Sentry.Unity/Integrations/SceneManagerTracingIntegration.cs new file mode 100644 index 000000000..e01a0d390 --- /dev/null +++ b/src/Sentry.Unity/Integrations/SceneManagerTracingIntegration.cs @@ -0,0 +1,63 @@ +using Sentry.Extensibility; +using Sentry.Integrations; +using UnityEngine.SceneManagement; + +namespace Sentry.Unity; + +internal class SceneManagerTracingIntegration : ISdkIntegration +{ + public void Register(IHub hub, SentryOptions options) + { + if (options.TracesSampleRate > 0.0f) + { + if (SceneManagerAPI.overrideAPI != null) + { + // TODO: Add a place to put a custom 'SceneManagerAPI' on the editor window so we can "decorate" it. + options.LogWarning("Registering {0} integration - overwriting the previous SceneManagerAPI.overrideAPI.", nameof(SceneManagerTracingIntegration)); + } + + SceneManagerAPI.overrideAPI = new SceneManagerTracingAPI(options.DiagnosticLogger); + } + else + { + options.LogDebug("Sample Rate set to {0}. Skipping registering {1}.", options.TracesSampleRate, nameof(SceneManagerTracingIntegration)); + } + } +} + +public class SceneManagerTracingAPI : SceneManagerAPI +{ + public const string TransactionOperation = "scene.load"; + private const string SpanOperation = "scene.load"; + private readonly IDiagnosticLogger? _logger; + + public SceneManagerTracingAPI(IDiagnosticLogger? logger) => + _logger = logger; + + protected override UnityEngine.AsyncOperation LoadSceneAsyncByNameOrIndex(string sceneName, int sceneBuildIndex, LoadSceneParameters parameters, bool mustCompleteNextFrame) + { + _logger?.LogInfo("Creating '{0}' transaction for '{1}'.", TransactionOperation, sceneName); + + var transaction = SentrySdk.StartTransaction("scene.loading", TransactionOperation); + SentrySdk.ConfigureScope(scope => scope.Transaction = transaction); + + _logger?.LogDebug("Creating '{0}' span.", SpanOperation); + var span = SentrySdk.GetSpan()?.StartChild(SpanOperation, sceneName ?? $"buildIndex:{sceneBuildIndex}"); + + var asyncOp = base.LoadSceneAsyncByNameOrIndex(sceneName, sceneBuildIndex, parameters, mustCompleteNextFrame); + + // TODO: setExtra()? e.g. from the LoadSceneParameters: + // https://github.com/Unity-Technologies/UnityCsReference/blob/02d565cf3dd0f6b15069ba976064c75dc2705b08/Runtime/Export/SceneManager/SceneManager.cs#L30 + // Note: asyncOp.completed triggers in the next frame after finishing (so the time isn't precise). + // https://docs.unity3d.com/2020.3/Documentation/ScriptReference/AsyncOperation-completed.html + asyncOp.completed += _ => + { + _logger?.LogInfo("Finishing '{0}' transaction for '{1}'.", TransactionOperation, sceneName); + + span?.Finish(SpanStatus.Ok); + transaction.Finish(SpanStatus.Ok); + }; + + return asyncOp; + } +} diff --git a/src/Sentry.Unity/SentryUnityOptions.cs b/src/Sentry.Unity/SentryUnityOptions.cs index 9ca204cd9..548ea1a2b 100644 --- a/src/Sentry.Unity/SentryUnityOptions.cs +++ b/src/Sentry.Unity/SentryUnityOptions.cs @@ -319,6 +319,7 @@ internal SentryUnityOptions(SentryMonoBehaviour behaviour, IApplication applicat this.AddIntegration(new UnityScopeIntegration(application, unityInfo)); this.AddIntegration(new UnityBeforeSceneLoadIntegration()); this.AddIntegration(new SceneManagerIntegration()); + this.AddIntegration(new SceneManagerTracingIntegration()); this.AddIntegration(new SessionIntegration(behaviour)); this.AddIntegration(new TraceGenerationIntegration(behaviour)); diff --git a/src/Sentry.Unity/UnityWebRequestTransport.cs b/src/Sentry.Unity/UnityWebRequestTransport.cs index a72dad527..7db7ad2c5 100644 --- a/src/Sentry.Unity/UnityWebRequestTransport.cs +++ b/src/Sentry.Unity/UnityWebRequestTransport.cs @@ -89,12 +89,7 @@ private UnityWebRequest CreateWebRequest(HttpRequestMessage message) private HttpResponseMessage? GetResponse(UnityWebRequest www) { - // Let's disable treating "warning:obsolete" as an error here because the alternative of putting a static - // function to user code (to be able to use #if UNITY_2019) is just ugly. -#pragma warning disable 618 - // if (www.result == UnityWebRequest.Result.ConnectionError) // Unity 2020.1+; `.result` not present on 2019 - if (www.isNetworkError) // Unity 2019; obsolete (error) on later versions -#pragma warning restore 618 + if (www.result == UnityWebRequest.Result.ConnectionError) { _options.DiagnosticLogger?.LogWarning("Failed to send request: {0}", www.error); return null; diff --git a/test/Scripts.Integration.Test/Editor/Builder.cs b/test/Scripts.Integration.Test/Editor/Builder.cs index 025fc0c9c..86d64d0b8 100644 --- a/test/Scripts.Integration.Test/Editor/Builder.cs +++ b/test/Scripts.Integration.Test/Editor/Builder.cs @@ -86,11 +86,6 @@ public static void BuildIl2CPPPlayer(BuildTarget target, BuildTargetGroup group, Debug.Log($"Builder: Creating output directory at '{outputDir}'"); Directory.CreateDirectory(outputDir); -#if !UNITY_2020_1_OR_NEWER - Debug.Log("Builder: Raising the minSdkVersion to 21"); - PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel21; -#endif - Debug.Log("Builder: Enabling minify"); #if UNITY_2020_1_OR_NEWER PlayerSettings.Android.minifyDebug = PlayerSettings.Android.minifyRelease = true; diff --git a/package-dev/Tests/Runtime/SentrySceneTracingIntegrationTests.cs b/test/Sentry.Unity.Tests/SceneManagerTracingIntegrationTests.cs similarity index 66% rename from package-dev/Tests/Runtime/SentrySceneTracingIntegrationTests.cs rename to test/Sentry.Unity.Tests/SceneManagerTracingIntegrationTests.cs index 541da7092..fbf01b0ce 100644 --- a/package-dev/Tests/Runtime/SentrySceneTracingIntegrationTests.cs +++ b/test/Sentry.Unity.Tests/SceneManagerTracingIntegrationTests.cs @@ -1,12 +1,8 @@ -#if UNITY_2020_3_OR_NEWER -#define SENTRY_SCENE_MANAGER_TRACING_INTEGRATION -#endif - using System; using System.Collections; using NUnit.Framework; using Sentry.Unity.Tests; -using UnityEngine; +using Sentry.Unity.Tests.Stubs; using UnityEngine.SceneManagement; using UnityEngine.TestTools; @@ -14,8 +10,7 @@ namespace Sentry.Unity { public class SentrySceneTracingIntegrationTests { -#if SENTRY_SCENE_MANAGER_TRACING_INTEGRATION - private SentryUnityOptions _options; + private SentryUnityOptions _options = null!; // Set in Setup private TestHttpClientHandler _testHttpClientHandler = null!; // Set in Setup private readonly TimeSpan _eventReceiveTimeout = TimeSpan.FromSeconds(1); @@ -31,19 +26,37 @@ public void SetUp() }; } + [TearDown] + public void TearDown() => SceneManagerAPI.overrideAPI = null; + [UnityTest] public IEnumerator SceneManagerTracingIntegration_DuringSceneLoad_CreatesTransaction() { - SentryIntegrations.Configure(_options); - using var _ = SentryIntegrationsTests.InitSentrySdk(_options); + // Arrange + SentryUnitySdk.Init(_options); + // Act yield return SetupSceneCoroutine("1_Bugfarm"); + // Assert var triggeredEvent = _testHttpClientHandler.GetEvent("\"type\":\"transaction\"", _eventReceiveTimeout); - Assert.That(triggeredEvent, Does.Contain(SceneManagerTracingAPI.TransactionOperation)); } + [Test] + public void SceneManagerTracingIntegration_SampleRateSetToZero_SkipsAddingIntegration() + { + // Arrange + var sceneManagerTracingIntegration = new SceneManagerTracingIntegration(); + _options.TracesSampleRate = 0.0f; + + // Act + sceneManagerTracingIntegration.Register(new TestHub(), _options); + + // Assert + Assert.IsNull(SceneManagerAPI.overrideAPI); + } + internal static IEnumerator SetupSceneCoroutine(string sceneName) { LogAssert.ignoreFailingMessages = true; @@ -52,6 +65,5 @@ internal static IEnumerator SetupSceneCoroutine(string sceneName) // skip a frame for a Unity to properly load a scene yield return null; } -#endif } }