Skip to content

feat: include build ID in release #795

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

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Include build ID in an event release info ([#795](https://github.com/getsentry/sentry-unity/pull/795))

## 0.18.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal static void Display(ScriptableSentryUnityOptions options)
GUILayout.Label("Tag Overrides", EditorStyles.boldLabel);

options.ReleaseOverride = EditorGUILayout.TextField(
new GUIContent("Override Release", "By default release is built from " +
"'Application.productName'@'Application.version'. " +
"This option is an override."),
new GUIContent("Override Release", "By default release is built from the Application info as: " +
"\"{productName}@{version}+{buildGUID}\". " +
"\nThis option is an override."),
options.ReleaseOverride);

options.EnvironmentOverride = EditorGUILayout.TextField(
Expand Down
4 changes: 4 additions & 0 deletions src/Sentry.Unity/Integrations/IApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal interface IApplication
bool IsEditor { get; }
string ProductName { get; }
string Version { get; }
string BuildGUID { get; }
string UnityVersion { get; }
string PersistentDataPath { get; }
RuntimePlatform Platform { get; }
Expand Down Expand Up @@ -41,6 +42,9 @@ private ApplicationAdapter()
public string ProductName => Application.productName;

public string Version => Application.version;

public string BuildGUID => Application.buildGUID;

public string UnityVersion => Application.unityVersion;

public string PersistentDataPath => Application.persistentDataPath;
Expand Down
5 changes: 5 additions & 0 deletions src/Sentry.Unity/SentryUnityOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Sentry.Unity.Integrations;
using Sentry.Extensibility;
Expand Down Expand Up @@ -175,6 +176,10 @@ internal SentryUnityOptions(IApplication application, bool isBuilding)
{
Release = application.Version;
}
if (!string.IsNullOrWhiteSpace(application.BuildGUID))
{
Release += $"+{application.BuildGUID}";
}

Environment = (application.IsEditor && !isBuilding)
? "editor"
Expand Down
10 changes: 6 additions & 4 deletions test/Sentry.Unity.Tests/SentryUnityOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Fixture
public TestApplication Application { get; set; } = new(
productName: "TestApplication",
version: "0.1.0",
buildGUID: "12345",
persistentDataPath: "test/persistent/data/path");
public bool IsBuilding { get; set; }

Expand All @@ -37,19 +38,20 @@ public void Ctor_Environment_IsNull(bool isEditor, bool isBuilding, string expec

var sut = _fixture.GetSut();

StringAssert.IsMatch(expectedEnvironment, sut.Environment);
Assert.AreEqual(expectedEnvironment, sut.Environment);
}

[Test]
public void Ctor_CacheDirectoryPath_IsApplicationPersistentDataPath() =>
StringAssert.IsMatch(_fixture.Application.PersistentDataPath, _fixture.GetSut().CacheDirectoryPath);
Assert.AreEqual(_fixture.Application.PersistentDataPath, _fixture.GetSut().CacheDirectoryPath);

[Test]
public void Ctor_IsGlobalModeEnabled_IsTrue() => Assert.IsTrue(_fixture.GetSut().IsGlobalModeEnabled);

[Test]
public void Ctor_Release_IsProductNameAtVersion() =>
StringAssert.IsMatch($"{_fixture.Application.ProductName}@{_fixture.Application.Version}",
public void Ctor_Release_IsProductNameAtVersionPlusBuild() =>
Assert.AreEqual(
$"{_fixture.Application.ProductName}@{_fixture.Application.Version}+{_fixture.Application.BuildGUID}",
_fixture.GetSut().Release);

[Test]
Expand Down
3 changes: 3 additions & 0 deletions test/Sentry.Unity.Tests/Stubs/TestApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ public TestApplication(
bool isEditor = true,
string productName = "",
string version = "",
string buildGUID = "",
string unityVersion = "",
string persistentDataPath = "",
RuntimePlatform platform = RuntimePlatform.WindowsEditor)
{
IsEditor = isEditor;
ProductName = productName;
Version = version;
BuildGUID = buildGUID;
UnityVersion = unityVersion;
PersistentDataPath = persistentDataPath;
Platform = platform;
Expand All @@ -28,6 +30,7 @@ public TestApplication(
public bool IsEditor { get; }
public string ProductName { get; }
public string Version { get; }
public string BuildGUID { get; }
public string UnityVersion { get; }
public string PersistentDataPath { get; }
public RuntimePlatform Platform { get; }
Expand Down