getsentry / sentry-unity

Development of Sentry SDK for Unity
https://docs.sentry.io/platforms/unity/
MIT License
200 stars 51 forks source link

Setting a release name in SentryBuildtimeOptionsConfiguration does not work #1136

Closed hajimeku closed 1 year ago

hajimeku commented 1 year ago

Environment

How do you use Sentry? Sentry SaaS

Which version of the SDK?

0.26

How did you install the package? (Git-URL, Assetstore)

Git-url

Which version of Unity?

2021.3.10

Is this happening in Unity (editor) or on a player like Android, iOS, Windows?

Android

Steps to Reproduce

I set my release name like this:

using System;
using UnityEngine;
using Sentry.Unity;
using Sentry.Unity.Editor;
using UnityEditor;

[CreateAssetMenu(fileName = "Assets/Plugins/Sentry/SentryBuildtimeOptionsConfiguration.asset", menuName = "Sentry/Assets/Plugins/Sentry/SentryBuildtimeOptionsConfiguration.asset", order = 999)]
public class SentryBuildtimeOptionsConfiguration : Sentry.Unity.Editor.ScriptableOptionsConfiguration
{
    /// See base class for documentation.
    /// Learn more at https://docs.sentry.io/platforms/unity/configuration/options/#programmatic-configuration
    public override void Configure(SentryUnityOptions options, SentryCliOptions cliOptions)
    {
        string identifier;
#if UNITY_ANDROID
        identifier = $"({PlayerSettings.Android.bundleVersionCode})";
#endif
#if     UNITY_IOS
        identifier = $"({PlayerSettings.iOS.buildNumber})";
#endif
        options.Release = $"GOP3@{Application.version}{identifier}_{EditorUserBuildSettings.activeBuildTarget}";
        options.AttachStacktrace = true;
    }
}

and the logs say on a build that it works: image

it is configured.. image

Expected Result

My release shows up in sentry with the name I gave it. For example GOP3@9.5.4_Android

Actual Result

It doesn't work at all and instead, I get the default name there.

It does work if you change the name in SentryRuntimeOptionsConfiguration but this is not my preferred solution.

Any logs or screenshots

bitsandfoxes commented 1 year ago

Let me give that a try locally. Looks like something is off.

hajimeku commented 1 year ago

In the AAB file the release name is also correct in the meta data of the manifest

vaind commented 1 year ago

It does work if you change the name in SentryRuntimeOptionsConfiguration but this is not my preferred solution.

My suspicion is you're setting the release name at build time, which in case of Android only affects native & java errors,e.g. https://github.com/getsentry/sentry-unity/blob/main/src/Sentry.Unity.Editor/Android/AndroidManifestConfiguration.cs#LL109C67-L109C74 and expect .net errors to share the same release name. In order to do so, you need to set it in both buildtime & runtime configuration options. The docs try to get this message across but I think they fail.

Can you please confirm you're seeing the wrong release name on issues coming from .net errors?

hajimeku commented 1 year ago

The documentation on this split in configuration is very unclear. What can be configured where is super vague. I can try to set both to the same value and see what happens but this is very annoying to configure because every platform release by default on this Unity client is a new one. It would be amazing if out of the box it would separate them on build platform already or put this in the name.

bitsandfoxes commented 1 year ago

I can try to set both to the same value and see what happens but this is very annoying to configure because every platform release by default on this Unity client is a new one.

Please give it a try and let us know if it works in your case. Thanks! I can see this being a point of unnecessary friction, especially if you want to execute the same code in both places. It doesn't make it any easier or clearer that this is due to the building process and users should ideally not have to think about that sort of thing but it should just work out of the box. We might revisit the current solution in the future.

bitsandfoxes commented 1 year ago

Hey, please feel free to reopen this issue if you're still running into problems!