Skip to content

Commit 6daa7fe

Browse files
authored
feat: Adding the game's name to the app context (#2083)
1 parent 3943f90 commit 6daa7fe

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66

7+
- The SDK now reports the game's name as part of the app context ([2083](https://github.com/getsentry/sentry-unity/pull/2083))
78
- The SDK now reports the active scene's name as part of the `Unity Context` ([2084](https://github.com/getsentry/sentry-unity/pull/2084))
89

910
### Dependencies

src/Sentry.Unity/Integrations/UnityScopeIntegration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private static void PopulateSdk(SdkVersion sdk)
6868

6969
private void PopulateApp(App app)
7070
{
71+
app.Name = _application.ProductName;
7172
app.StartTime = MainThreadData.StartTime;
7273
var isDebugBuild = MainThreadData.IsDebugBuild;
7374
app.BuildType = isDebugBuild is null ? null : (isDebugBuild.Value ? "debug" : "release");

test/Sentry.Unity.Tests/UnityEventScopeTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,34 @@ public void DeviceUniqueIdentifierWithSendDefaultPii_IsNotNull()
259259
public void AppProtocol_Assigned()
260260
{
261261
// arrange
262+
_testApplication = new TestApplication(productName: "TestGame");
262263
var sut = new UnityScopeUpdater(_sentryOptions, _testApplication);
263264
var scope = new Scope(_sentryOptions);
264265

265266
// act
266267
sut.ConfigureScope(scope);
267268

268269
// assert
270+
Assert.IsNotNull(scope.Contexts.App.Name);
269271
Assert.IsNotNull(scope.Contexts.App.StartTime);
270272
Assert.IsNotNull(scope.Contexts.App.BuildType);
271273
}
272274

275+
[Test]
276+
public void AppProtocol_AppNameIsApplicationName()
277+
{
278+
// arrange
279+
_testApplication = new TestApplication(productName: "TestGame");
280+
var sut = new UnityScopeUpdater(_sentryOptions, _testApplication);
281+
var scope = new Scope(_sentryOptions);
282+
283+
// act
284+
sut.ConfigureScope(scope);
285+
286+
// assert
287+
Assert.AreEqual(scope.Contexts.App.Name, _testApplication.ProductName);
288+
}
289+
273290
[Test]
274291
public void UserId_SetIfEmpty()
275292
{

0 commit comments

Comments
 (0)